|
|
@@ -1,6 +1,7 @@
|
|
|
package com.xunmei.system.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.xunmei.common.core.domain.R;
|
|
|
import com.xunmei.common.core.utils.StringUtils;
|
|
|
import com.xunmei.common.core.web.controller.BaseController;
|
|
|
import com.xunmei.common.core.web.domain.AjaxResult;
|
|
|
@@ -25,13 +26,12 @@ import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 部门信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @author xunmei
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/dept")
|
|
|
-public class SysDeptController extends BaseController
|
|
|
-{
|
|
|
+public class SysDeptController extends BaseController {
|
|
|
@Autowired
|
|
|
private ISysDeptService deptService;
|
|
|
@Autowired
|
|
|
@@ -53,8 +53,7 @@ public class SysDeptController extends BaseController
|
|
|
*/
|
|
|
@RequiresPermissions("system:dept:list")
|
|
|
@GetMapping("/list/exclude/{deptId}")
|
|
|
- public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
|
|
|
- {
|
|
|
+ public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
|
|
|
List<SysOrg> depts = orgService.list();
|
|
|
depts.removeIf(d -> d.getId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getPath(), "-"), deptId + ""));
|
|
|
return success(depts);
|
|
|
@@ -65,8 +64,7 @@ public class SysDeptController extends BaseController
|
|
|
*/
|
|
|
@RequiresPermissions("system:dept:query")
|
|
|
@GetMapping(value = "/{deptId}")
|
|
|
- public AjaxResult getInfo(@PathVariable Long deptId)
|
|
|
- {
|
|
|
+ public AjaxResult getInfo(@PathVariable Long deptId) {
|
|
|
// deptService.checkDeptDataScope(deptId);
|
|
|
return success(orgService.getById(deptId));
|
|
|
}
|
|
|
@@ -77,10 +75,8 @@ public class SysDeptController extends BaseController
|
|
|
@RequiresPermissions("system:dept:add")
|
|
|
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
- public AjaxResult add(@Validated @RequestBody SysOrg dept)
|
|
|
- {
|
|
|
- if (orgService.list(new QueryWrapper<SysOrg>().eq("name",dept.getName())).size()>0)
|
|
|
- {
|
|
|
+ public AjaxResult add(@Validated @RequestBody SysOrg dept) {
|
|
|
+ if (orgService.list(new QueryWrapper<SysOrg>().eq("name", dept.getName())).size() > 0) {
|
|
|
return error("新增部门'" + dept.getName() + "'失败,部门名称已存在");
|
|
|
}
|
|
|
dept.setCreateBy(SecurityUtils.getUsername());
|
|
|
@@ -95,17 +91,12 @@ public class SysDeptController extends BaseController
|
|
|
@RequiresPermissions("system:dept:edit")
|
|
|
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@Validated @RequestBody SysOrg dept)
|
|
|
- {
|
|
|
+ public AjaxResult edit(@Validated @RequestBody SysOrg dept) {
|
|
|
Long deptId = dept.getId();
|
|
|
// deptService.checkDeptDataScope(deptId);
|
|
|
- if (orgService.list(new QueryWrapper<SysOrg>().eq("name",dept.getName()).eq("deleted",0L)).size()>1)
|
|
|
- {
|
|
|
+ if (orgService.list(new QueryWrapper<SysOrg>().eq("name", dept.getName()).eq("deleted", 0L)).size() > 1) {
|
|
|
return error("修改部门'" + dept.getName() + "'失败,部门名称已存在");
|
|
|
- }
|
|
|
- else
|
|
|
- if (dept.getParentId().equals(deptId))
|
|
|
- {
|
|
|
+ } else if (dept.getParentId().equals(deptId)) {
|
|
|
return error("修改部门'" + dept.getName() + "'失败,上级部门不能是自己");
|
|
|
}
|
|
|
// else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getIsLock()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
|
|
|
@@ -123,14 +114,11 @@ public class SysDeptController extends BaseController
|
|
|
@RequiresPermissions("system:dept:remove")
|
|
|
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{deptId}")
|
|
|
- public AjaxResult remove(@PathVariable Long deptId)
|
|
|
- {
|
|
|
- if (orgService.list(new QueryWrapper<SysOrg>().eq("parent_id",deptId).eq("deleted",0L)).size()>0)
|
|
|
- {
|
|
|
+ public AjaxResult remove(@PathVariable Long deptId) {
|
|
|
+ if (orgService.list(new QueryWrapper<SysOrg>().eq("parent_id", deptId).eq("deleted", 0L)).size() > 0) {
|
|
|
return warn("存在下级部门,不允许删除");
|
|
|
}
|
|
|
- if (userService.list(new QueryWrapper<SysUser>().eq("org_id",deptId).eq("deleted",0L)).size()>0)
|
|
|
- {
|
|
|
+ if (userService.list(new QueryWrapper<SysUser>().eq("org_id", deptId).eq("deleted", 0L)).size() > 0) {
|
|
|
return warn("部门存在用户,不允许删除");
|
|
|
}
|
|
|
// deptService.checkDeptDataScope(deptId);
|
|
|
@@ -146,13 +134,31 @@ public class SysDeptController extends BaseController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
* @param dept
|
|
|
- * @return
|
|
|
- * 获取部门树(真部门)
|
|
|
+ * @return 获取部门树(真部门)
|
|
|
*/
|
|
|
@GetMapping("/sysDeptTree")
|
|
|
public AjaxResult sysDeptTree(SysDept dept) {
|
|
|
return success(deptService.selectDeptTreeList(dept));
|
|
|
}
|
|
|
+
|
|
|
+ @GetMapping("/selectCheckSubOrgIdList")
|
|
|
+ public List<Long> selectCheckSubOrgIdList(Long orgId) {
|
|
|
+ return orgService.selectCheckSubOrgIdList(orgId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/selectSysOrgById")
|
|
|
+ public SysOrg selectSysOrgById(Long id) {
|
|
|
+ return orgService.selectSysOrgById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/listByIds")
|
|
|
+ public List<SysOrg> listByIds(List<Long> ids) {
|
|
|
+ return orgService.listByIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/findListByOrgType")
|
|
|
+ public List<Long> findListByOrgType(Integer execOrgType) {
|
|
|
+ return orgService.findListByOrgType(execOrgType);
|
|
|
+ }
|
|
|
}
|