mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-05 16:53:46 +08:00
refactor: refactor the frame layout of admin module
This commit is contained in:
@@ -136,7 +136,7 @@ func authorizeMiddleware(s *AppServer) gin.HandlerFunc {
|
||||
if c.Request.URL.Path == "/api/user/login" ||
|
||||
c.Request.URL.Path == "/api/admin/login" ||
|
||||
c.Request.URL.Path == "/api/user/register" ||
|
||||
c.Request.URL.Path == "/api/config/get" {
|
||||
c.Request.URL.Path == "/api/admin/config/get" {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -30,23 +30,24 @@ func (h *ChatRoleHandler) List(c *gin.Context) {
|
||||
resp.ERROR(c, "No roles found,"+res.Error.Error())
|
||||
return
|
||||
}
|
||||
userId := h.GetInt(c, "user_id", 0)
|
||||
if userId > 0 {
|
||||
var user model.User
|
||||
h.db.First(&user, userId)
|
||||
var roleKeys []string
|
||||
err := utils.JsonDecode(user.ChatRoles, &roleKeys)
|
||||
if err == nil {
|
||||
for index, r := range roles {
|
||||
if utils.ContainsStr(roleKeys, r.Key) {
|
||||
roles = append(roles[:index], roles[index+1:]...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
user, err := utils.GetLoginUser(c, h.db)
|
||||
if err != nil {
|
||||
resp.NotAuth(c)
|
||||
return
|
||||
}
|
||||
var roleKeys []string
|
||||
err = utils.JsonDecode(user.ChatRoles, &roleKeys)
|
||||
if err != nil {
|
||||
resp.ERROR(c, "角色解析失败!")
|
||||
return
|
||||
}
|
||||
// 转成 vo
|
||||
var roleVos = make([]vo.ChatRole, 0)
|
||||
for _, r := range roles {
|
||||
if !utils.ContainsStr(roleKeys, r.Key) {
|
||||
continue
|
||||
}
|
||||
var v vo.ChatRole
|
||||
err := utils.CopyObject(r, &v)
|
||||
if err == nil {
|
||||
|
||||
Reference in New Issue
Block a user