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/app/role/get.go

27 lines
548 B
Go

package role
import (
3 months ago
"github.com/vyes-ai/vigo"
6 months ago
"github.com/veypi/OneAuth/cfg"
"github.com/veypi/OneAuth/models"
)
var _ = Router.Get("/:role_id", getRole)
func getRole(x *vigo.X) (any, error) {
// 获取角色 ID
roleID := x.Params.Get("role_id")
if roleID == "" {
return nil, vigo.NewError("role_id is required").WithCode(400)
}
// 查询数据库
role := &models.Role{}
err := cfg.DB().Where("id = ?", roleID).First(role).Error
if err != nil {
return nil, vigo.NewError("role not found").WithCode(404)
}
return role, nil
}