package role import ( "github.com/veypi/OneAuth/cfg" "github.com/veypi/OneAuth/models" "github.com/vyes-ai/vigo" ) type createOpts struct { AppID string `parse:"path@app_id"` // 应用 ID Name string `json:"name" parse:"json"` // 角色名称 Des string `json:"des" parse:"json"` // 角色描述 } var _ = Router.Post("/", "创建角色", createRole) func createRole(x *vigo.X, opts *createOpts) (any, error) { // 创建角色 role := &models.Role{ AppID: opts.AppID, Name: opts.Name, Des: opts.Des, } // 保存到数据库 if err := cfg.DB().Create(role).Error; err != nil { return nil, err } return role, nil }