fix: 角色操作错误
This commit is contained in:
@@ -376,7 +376,7 @@ func (s SysRoleController) UserAuthChecked(c *gin.Context) {
|
|||||||
var body struct {
|
var body struct {
|
||||||
RoleId int64 `json:"roleId" binding:"required"` // 角色ID
|
RoleId int64 `json:"roleId" binding:"required"` // 角色ID
|
||||||
UserIds []int64 `json:"userIds" 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 {
|
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ func (r SysRole) insertRoleMenu(roleId int64, menuIds []int64) int64 {
|
|||||||
// Update 修改信息
|
// Update 修改信息
|
||||||
func (r SysRole) Update(sysRole model.SysRole) int64 {
|
func (r SysRole) Update(sysRole model.SysRole) int64 {
|
||||||
rows := r.sysRoleRepository.Update(sysRole)
|
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.sysRoleMenuRepository.DeleteByRoleIds([]int64{sysRole.RoleId})
|
||||||
r.insertRoleMenu(sysRole.RoleId, sysRole.MenuIds)
|
r.insertRoleMenu(sysRole.RoleId, sysRole.MenuIds)
|
||||||
|
|||||||
Reference in New Issue
Block a user