refactor: 管理后台用户编辑功能 is ready

This commit is contained in:
RockYang
2023-06-19 21:53:07 +08:00
parent 5f812ae649
commit 65a01f4776
7 changed files with 95 additions and 75 deletions

View File

@@ -6,6 +6,7 @@ import (
"chatplus/store/vo"
"chatplus/utils"
"chatplus/utils/resp"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
@@ -33,11 +34,11 @@ func (h *ChatRoleHandler) List(c *gin.Context) {
if userId > 0 {
var user model.User
h.db.First(&user, userId)
var roleMap map[string]int
err := utils.JsonDecode(user.ChatRoles, &roleMap)
var roleKeys []string
err := utils.JsonDecode(user.ChatRoles, &roleKeys)
if err == nil {
for index, r := range roles {
if _, ok := roleMap[r.Key]; !ok {
if utils.ContainsStr(roleKeys, r.Key) {
roles = append(roles[:index], roles[index+1:]...)
}
}