You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/api/user/role/create.go

41 lines
811 B
Go

//
// crud.go
// Copyright (C) 2025 veypi <i@veypi.com>
// 2025-05-06 15:12
// Distributed under terms of the MIT license.
//
package role
import (
6 months ago
"github.com/veypi/OneAuth/cfg"
"github.com/veypi/OneAuth/models"
3 months ago
"github.com/vyes-ai/vigo"
)
var _ = Router.Post("/", userRolePost)
type postOpts struct {
UserID string `json:"user_id" parse:"path"`
RoleID string `json:"role_id" parse:"json"`
AppID string `json:"app_id" parse:"json"`
Status string `json:"status" parse:"json"`
}
func userRolePost(x *vigo.X) (any, error) {
opts := &postOpts{}
err := x.Parse(opts)
if err != nil {
return nil, err
}
6 months ago
data := &models.UserRole{}
data.UserID = opts.UserID
data.RoleID = opts.RoleID
data.AppID = opts.AppID
data.Status = opts.Status
err = cfg.DB().Create(data).Error
return data, err
}