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.
25 lines
503 B
Go
25 lines
503 B
Go
package role
|
|
|
|
import (
|
|
"github.com/vyes-ai/vigo"
|
|
"github.com/veypi/OneAuth/cfg"
|
|
"github.com/veypi/OneAuth/models"
|
|
)
|
|
|
|
type getIDReq struct {
|
|
ID string `parse:"path@role_id"`
|
|
}
|
|
|
|
var _ = Router.Get("/{role_id}", "获取角色详情", getRole)
|
|
|
|
func getRole(x *vigo.X, req *getIDReq) (any, error) {
|
|
// 查询数据库
|
|
role := &models.Role{}
|
|
err := cfg.DB().Where("id = ?", req.ID).First(role).Error
|
|
if err != nil {
|
|
return nil, vigo.NewError("role not found").WithCode(404)
|
|
}
|
|
|
|
return role, nil
|
|
}
|