|
@@ -59,6 +59,17 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
+ //对比部门上级id是否被修改过了
|
|
|
+ private boolean compareSuperiorId(Integer id1, Integer id2) {
|
|
|
+ if (id1 == null) {
|
|
|
+ return id2 == null;
|
|
|
+ } else if (id2 == null) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return id1.equals(id2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//更新部门
|
|
|
@Override
|
|
|
public HttpRespMsg updateDepartment(Integer departmentId, String departmentName, Integer superiorId,
|
|
@@ -69,7 +80,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|
|
Department department = departmentMapper.selectById(departmentId);
|
|
|
if (!department.getCompanyId().equals(companyId)) {
|
|
|
httpRespMsg.setError("不能修改其他公司的部门");
|
|
|
- } else if (!department.getSuperiorId().equals(superiorId) && checkBranch(departmentId)) {
|
|
|
+ } else if (!compareSuperiorId(department.getSuperiorId(), superiorId) && checkBranch(departmentId)) {
|
|
|
httpRespMsg.setError("不能在有子级部门时修改父级部门");
|
|
|
} else if (superiorId != null && departmentMapper.selectCount(new QueryWrapper<Department>()
|
|
|
.eq("department_id", superiorId)
|