refactor: refactor the frame layout of admin module

This commit is contained in:
RockYang
2023-06-21 14:22:28 +08:00
parent 54a2181960
commit 40a4ab5410
35 changed files with 1758 additions and 334 deletions

View File

@@ -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
}

View File

@@ -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 {