This commit is contained in:
苏尹岚
2021-01-20 14:25:46 +08:00
parent 15068e28f9
commit 142990b2a6

View File

@@ -163,7 +163,6 @@ func UpdateUserRole(ctx *jxcontext.Context, userIDs []string, roleIDs []int) (er
userRoleMap[v.UserID] = append(userRoleMap[v.UserID], v.RoleID) userRoleMap[v.UserID] = append(userRoleMap[v.UserID], v.RoleID)
} }
} }
fmt.Println("userRoleMap", userRoleMap)
for _, userID := range userIDs { for _, userID := range userIDs {
nowRoleIDs := userRoleMap[userID] nowRoleIDs := userRoleMap[userID]
for _, nowRoleID := range nowRoleIDs { for _, nowRoleID := range nowRoleIDs {
@@ -172,16 +171,12 @@ func UpdateUserRole(ctx *jxcontext.Context, userIDs []string, roleIDs []int) (er
} }
nowRoleIDMap[nowRoleID] = 1 nowRoleIDMap[nowRoleID] = 1
} }
fmt.Println("nowRoleIDMap", nowRoleIDMap)
fmt.Println("roleIDMap", roleIDMap)
for roleID, _ := range roleIDMap { for roleID, _ := range roleIDMap {
if nowRoleIDMap[roleID] == 0 { if nowRoleIDMap[roleID] == 0 {
addUserRoleMap[userID] = append(addUserRoleMap[userID], roleID) addUserRoleMap[userID] = append(addUserRoleMap[userID], roleID)
} }
} }
} }
fmt.Println("1 ", addUserRoleMap)
fmt.Println("2 ", deleteUserRoleMap)
dao.Begin(db) dao.Begin(db)
defer func() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {
@@ -250,7 +245,7 @@ func UpdateRoleMenu(ctx *jxcontext.Context, roleIDs, menuIDs []int) (err error)
} }
nowMenuIDMap[nowMenuID] = 1 nowMenuIDMap[nowMenuID] = 1
} }
for _, menuID := range menuIDMap { for menuID, _ := range menuIDMap {
if nowMenuIDMap[menuID] == 0 { if nowMenuIDMap[menuID] == 0 {
addRoleMenuMap[menuID] = append(addRoleMenuMap[menuID], menuID) addRoleMenuMap[menuID] = append(addRoleMenuMap[menuID], menuID)
} }