lyhzzz %!s(int64=2) %!d(string=hai) anos
pai
achega
f2a3874808

+ 11 - 8
src/main/java/com/fdkankan/fusion/service/impl/TmDepartmentServiceImpl.java

@@ -64,15 +64,18 @@ public class TmDepartmentServiceImpl extends ServiceImpl<ITmDepartmentMapper, Tm
 
     @Override
     public void deleteDeptById(String deptId) {
-        List<TmDepartment> deptList = this.getDeptListByParentId(deptId);
-        if(deptList .size() >0){
-            throw new BusinessException(ResultCode.DEPT_DEL_ERROR1);
-        }
-        List<TmUser> userList = tmUserService.getByDeptId(deptId);
-        if(userList.size() >0){
-            throw new BusinessException(ResultCode.DEPT_DEL_ERROR2);
+        TmDepartment department = this.getById(deptId);
+        if(department != null){
+            List<TmDepartment> deptList = this.getDeptListByParentId(department);
+            if(deptList .size() >0){
+                throw new BusinessException(ResultCode.DEPT_DEL_ERROR1);
+            }
+            List<TmUser> userList = tmUserService.getByDeptId(deptId);
+            if(userList.size() >0){
+                throw new BusinessException(ResultCode.DEPT_DEL_ERROR2);
+            }
+            this.removeById(deptId);
         }
-        this.removeById(deptId);
     }
 
     private boolean checkDeptNameUnique(String name, String id) {