mirror of https://github.com/veypi/OneAuth.git
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.
36 lines
830 B
Go
36 lines
830 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 (
|
|
"github.com/veypi/vbase/cfg"
|
|
"github.com/veypi/vbase/models"
|
|
"github.com/veypi/vigo"
|
|
)
|
|
|
|
var _ = Router.Post("/", "创建用户角色", userRolePost)
|
|
|
|
type postOpts struct {
|
|
UserID string `json:"user_id" src:"path" desc:"用户ID"`
|
|
RoleID string `json:"role_id" src:"json" desc:"角色ID"`
|
|
AppID string `json:"app_id" src:"json" desc:"应用ID"`
|
|
Status string `json:"status" src:"json" desc:"状态"`
|
|
}
|
|
|
|
func userRolePost(x *vigo.X, opts *postOpts) (*models.UserRole, error) {
|
|
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
|
|
}
|