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
769 B
Go
36 lines
769 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/OneAuth/cfg"
|
|
"github.com/veypi/OneAuth/models"
|
|
"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, opts *postOpts) (any, 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
|
|
}
|