|
@@ -149,21 +149,16 @@ public class CompanyDeptController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('company:dept:edit')")
|
|
|
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@Validated @RequestBody CompanyDept dept)
|
|
|
- {
|
|
|
+ public AjaxResult edit(@Validated @RequestBody CompanyDept dept) {
|
|
|
+ if(dept.getParentId().equals(dept.getDeptId())) {
|
|
|
+ return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
|
|
+ }
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
dept.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
- if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
|
|
- {
|
|
|
+ if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
|
|
|
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
|
|
- }
|
|
|
- else if (dept.getParentId().equals(dept.getDeptId()))
|
|
|
- {
|
|
|
- return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
|
|
- }
|
|
|
- else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
|
|
- && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0)
|
|
|
- {
|
|
|
+ } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
|
|
+ && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) {
|
|
|
return AjaxResult.error("该部门包含未停用的子部门!");
|
|
|
}
|
|
|
dept.setUpdateBy(SecurityUtils.getUsername());
|