lyhzzz 1 year ago
parent
commit
ef9c84d042

+ 2 - 4
src/main/java/com/fdkankan/fusion/service/impl/TmDepartmentServiceImpl.java

@@ -52,12 +52,10 @@ public class TmDepartmentServiceImpl extends ServiceImpl<ITmDepartmentMapper, Tm
         if(!checkDeptNameUnique(dept.getName(),null)){
         if(!checkDeptNameUnique(dept.getName(),null)){
             throw new BusinessException(ResultCode.DEPT_NAME_EXITS);
             throw new BusinessException(ResultCode.DEPT_NAME_EXITS);
         }
         }
-        if(dept.getLevel() >4){
-            throw new BusinessException(ResultCode.DEPT_ADD_ERROR);
-        }
         List<TmDepartment> tmDepartments = new ArrayList<>();
         List<TmDepartment> tmDepartments = new ArrayList<>();
         this.getParentList(dept.getParentId(),tmDepartments);
         this.getParentList(dept.getParentId(),tmDepartments);
-        if(tmDepartments.size() >4){
+        List<TmDepartment> collect = tmDepartments.stream().filter(entity -> !entity.getId().equals("0")).collect(Collectors.toList());
+        if(collect.size() >4){
             throw new BusinessException(ResultCode.DEPT_ADD_ERROR);
             throw new BusinessException(ResultCode.DEPT_ADD_ERROR);
         }
         }
         dept.setId(IdPreEnum.DEPARTMENT_PRE.getPre() +IdUtil.getSnowflake(1).nextId() );
         dept.setId(IdPreEnum.DEPARTMENT_PRE.getPre() +IdUtil.getSnowflake(1).nextId() );