Bladeren bron

添加超级管理员不可编辑或停用的拦截

v_HuilingDeng 4 jaren geleden
bovenliggende
commit
7eef306fdf

+ 8 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/RoleManagerServiceImpl.java

@@ -57,6 +57,7 @@ public class RoleManagerServiceImpl implements RoleManagerService {
      * 创建角色
      **/
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void createRole(CreateRoleReq req) {
         //1-查询上级角色信息
         UserRole parentRole = getRoleByCode(req.getParentRoleCode());
@@ -126,7 +127,11 @@ public class RoleManagerServiceImpl implements RoleManagerService {
      * 修改角色
      **/
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void updateRole(UpdateRoleReq req) {
+        if("admin".equals(req.getRoleCode())){
+            throw new BusinessException("超级管理员不可编辑。");
+        }
         //1-查询角色信息
         UserRole userRole = getRoleByCode(req.getRoleCode());
         AssertUtil.isNull(userRole,"角色不存在");
@@ -399,6 +404,9 @@ public class RoleManagerServiceImpl implements RoleManagerService {
 
         //循环禁用
         for(String roleCode:roleCodeList){
+            if("admin".equals(roleCode)){
+                throw new BusinessException("超级管理员不可停用。");
+            }
             //1-查询角色
             UserRole role = getRoleByCode(roleCode);
             AssertUtil.isNull(role,"角色不存在");