|
@@ -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) {
|