用户管理、角色管理BUG修复
This commit is contained in:
parent
347137f249
commit
21bcc2f4b9
|
|
@ -10,6 +10,7 @@ import com.bonus.common.log.enums.OperaType;
|
|||
import com.bonus.common.security.annotation.InnerAuth;
|
||||
import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth;
|
||||
import com.bonus.system.api.domain.SysUserRole;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
|
|
@ -135,6 +136,19 @@ public class SysRoleController extends BaseController
|
|||
}else if (Objects.equals(role.getIsBuiltIn(), "0")) {
|
||||
return error("内置角色不允许修改");
|
||||
}
|
||||
// 查询角色是否绑定了用户、角色级别是否修改、角色状态是否修改
|
||||
List<Integer> result = roleService.selectCountUserByRoleId(role);
|
||||
if(CollectionUtils.isNotEmpty(result)){
|
||||
Integer isUpdate = result.get(0);
|
||||
Integer isBandUser = result.get(1);
|
||||
Integer useStatus = result.get(2);
|
||||
if(isBandUser != 0 && isUpdate == 0){
|
||||
return error("角色已关联用户无法修改角色级别");
|
||||
}
|
||||
if(isBandUser != 0 && useStatus == 0){
|
||||
return error("角色已关联用户无法修改角色状态");
|
||||
}
|
||||
}
|
||||
role.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(roleService.updateRole(role));
|
||||
}catch (Exception e){
|
||||
|
|
|
|||
|
|
@ -104,4 +104,13 @@ public interface SysRoleMapper
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteRoleByIds(Long[] roleIds);
|
||||
|
||||
/**
|
||||
* 查询角色是否绑定了用户、角色级别是否修改、角色状态是否修改
|
||||
* @param role
|
||||
* @return int
|
||||
* @author cwchen
|
||||
* @date 2025/8/26 14:58
|
||||
*/
|
||||
List<Integer> selectCountUserByRoleId(SysRole role);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,4 +170,13 @@ public interface ISysRoleService
|
|||
* @return 结果
|
||||
*/
|
||||
public int insertAuthUsers(Long roleId, Long[] userIds);
|
||||
|
||||
/**
|
||||
* 查询角色是否绑定了用户、角色级别是否修改、角色状态是否修改
|
||||
* @param role
|
||||
* @return int
|
||||
* @author cwchen
|
||||
* @date 2025/8/26 14:56
|
||||
*/
|
||||
List<Integer> selectCountUserByRoleId(SysRole role);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
package com.bonus.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import com.bonus.common.datascope.utils.CommonDataPermissionInfo;
|
||||
import com.bonus.system.api.domain.SysUserRole;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -35,6 +32,7 @@ import com.bonus.system.service.ISysRoleService;
|
|||
* @author bonus
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SysRoleServiceImpl implements ISysRoleService
|
||||
{
|
||||
@Autowired
|
||||
|
|
@ -452,4 +450,14 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|||
}
|
||||
return userRoleMapper.batchUserRole(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> selectCountUserByRoleId(SysRole role) {
|
||||
try {
|
||||
return Optional.ofNullable(roleMapper.selectCountUserByRoleId(role)).orElse(new ArrayList<>());
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,8 +108,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
limit 1
|
||||
</select>
|
||||
<!--查询角色是否绑定了用户、角色级别是否修改-->
|
||||
<select id="selectCountUserByRoleId" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) FROM sys_role WHERE role_id = #{roleId} AND role_level = #{roleLevel}
|
||||
UNION ALL
|
||||
SELECT COUNT(*) FROM sys_user WHERE role_id = #{roleId} AND del_flag = 0
|
||||
UNION ALL
|
||||
SELECT COUNT(*) FROM sys_role WHERE role_id = #{roleId} AND status = #{status}
|
||||
</select>
|
||||
|
||||
<insert id="insertRole" parameterType="com.bonus.system.api.domain.SysRole" useGeneratedKeys="true" keyProperty="roleId">
|
||||
<insert id="insertRole" parameterType="com.bonus.system.api.domain.SysRole" useGeneratedKeys="true" keyProperty="roleId">
|
||||
insert into sys_role(
|
||||
<if test="roleId != null and roleId != 0">role_id,</if>
|
||||
<if test="roleName != null and roleName != ''">role_name,</if>
|
||||
|
|
|
|||
Loading…
Reference in New Issue