用户管理、角色管理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.InnerAuth;
|
||||||
import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth;
|
import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth;
|
||||||
import com.bonus.system.api.domain.SysUserRole;
|
import com.bonus.system.api.domain.SysUserRole;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
|
@ -135,6 +136,19 @@ public class SysRoleController extends BaseController
|
||||||
}else if (Objects.equals(role.getIsBuiltIn(), "0")) {
|
}else if (Objects.equals(role.getIsBuiltIn(), "0")) {
|
||||||
return error("内置角色不允许修改");
|
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());
|
role.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(roleService.updateRole(role));
|
return toAjax(roleService.updateRole(role));
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
|
|
|
||||||
|
|
@ -104,4 +104,13 @@ public interface SysRoleMapper
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteRoleByIds(Long[] roleIds);
|
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 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertAuthUsers(Long roleId, Long[] userIds);
|
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;
|
package com.bonus.system.service.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.bonus.common.core.web.domain.BaseEntity;
|
import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
import com.bonus.common.datascope.utils.CommonDataPermissionInfo;
|
import com.bonus.common.datascope.utils.CommonDataPermissionInfo;
|
||||||
import com.bonus.system.api.domain.SysUserRole;
|
import com.bonus.system.api.domain.SysUserRole;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -35,6 +32,7 @@ import com.bonus.system.service.ISysRoleService;
|
||||||
* @author bonus
|
* @author bonus
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class SysRoleServiceImpl implements ISysRoleService
|
public class SysRoleServiceImpl implements ISysRoleService
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -452,4 +450,14 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||||
}
|
}
|
||||||
return userRoleMapper.batchUserRole(list);
|
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,6 +108,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</if>
|
</if>
|
||||||
limit 1
|
limit 1
|
||||||
</select>
|
</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(
|
insert into sys_role(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue