fix: 角色操作错误

This commit is contained in:
TsMask
2025-03-13 16:51:48 +08:00
parent b8cc997d09
commit 6ed3184b36
2 changed files with 2 additions and 2 deletions

View File

@@ -376,7 +376,7 @@ func (s SysRoleController) UserAuthChecked(c *gin.Context) {
var body struct {
RoleId int64 `json:"roleId" binding:"required"` // 角色ID
UserIds []int64 `json:"userIds" binding:"required"` // 用户ID组
Auth bool `json:"auth" binding:"required"` // 选择操作 添加true 取消false
Auth bool `json:"auth"` // 选择操作 添加true 取消false
}
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))

View File

@@ -83,7 +83,7 @@ func (r SysRole) insertRoleMenu(roleId int64, menuIds []int64) int64 {
// Update 修改信息
func (r SysRole) Update(sysRole model.SysRole) int64 {
rows := r.sysRoleRepository.Update(sysRole)
if rows > 0 && len(sysRole.MenuIds) > 0 {
if rows > 0 && len(sysRole.MenuIds) >= 0 {
// 删除角色与菜单关联
r.sysRoleMenuRepository.DeleteByRoleIds([]int64{sysRole.RoleId})
r.insertRoleMenu(sysRole.RoleId, sysRole.MenuIds)