代码提交
This commit is contained in:
parent
83478dfffa
commit
f6cbf24b67
|
|
@ -33,8 +33,7 @@ import com.bonus.system.service.ISysDeptService;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/dept")
|
@RequestMapping("/system/dept")
|
||||||
public class SysDeptController extends BaseController
|
public class SysDeptController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDeptService deptService;
|
private ISysDeptService deptService;
|
||||||
|
|
||||||
|
|
@ -43,8 +42,7 @@ public class SysDeptController extends BaseController
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:dept:list")
|
@RequiresPermissions("system:dept:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult list(SysDept dept)
|
public AjaxResult list(SysDept dept) {
|
||||||
{
|
|
||||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||||
return success(depts);
|
return success(depts);
|
||||||
}
|
}
|
||||||
|
|
@ -53,10 +51,9 @@ public class SysDeptController extends BaseController
|
||||||
* 查询部门列表(排除节点)
|
* 查询部门列表(排除节点)
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:dept:list")
|
@RequiresPermissions("system:dept:list")
|
||||||
@SysLog(title = "部门管理", businessType = OperaType.QUERY,module = "部门管理->查询部门列表", details = "查询部门列表")
|
@SysLog(title = "部门管理", businessType = OperaType.QUERY, module = "部门管理->查询部门列表", details = "查询部门列表")
|
||||||
@GetMapping("/list/exclude/{deptId}")
|
@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<SysDept> depts = deptService.selectDeptList(new SysDept());
|
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||||
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
|
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
|
||||||
return success(depts);
|
return success(depts);
|
||||||
|
|
@ -67,9 +64,8 @@ public class SysDeptController extends BaseController
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:dept:query")
|
@RequiresPermissions("system:dept:query")
|
||||||
@GetMapping(value = "/{deptId}")
|
@GetMapping(value = "/{deptId}")
|
||||||
@SysLog(title = "部门管理", businessType = OperaType.QUERY,module = "部门管理->根据部门编号获取详细信息", details = "根据部门编号获取详细信息")
|
@SysLog(title = "部门管理", businessType = OperaType.QUERY, module = "部门管理->根据部门编号获取详细信息", details = "根据部门编号获取详细信息")
|
||||||
public AjaxResult getInfo(@PathVariable Long deptId)
|
public AjaxResult getInfo(@PathVariable Long deptId) {
|
||||||
{
|
|
||||||
deptService.checkDeptDataScope(deptId);
|
deptService.checkDeptDataScope(deptId);
|
||||||
return success(deptService.selectDeptById(deptId));
|
return success(deptService.selectDeptById(deptId));
|
||||||
}
|
}
|
||||||
|
|
@ -78,12 +74,10 @@ public class SysDeptController extends BaseController
|
||||||
* 新增部门
|
* 新增部门
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:dept:add")
|
@RequiresPermissions("system:dept:add")
|
||||||
@SysLog(title = "部门管理", businessType = OperaType.INSERT,module = "部门管理->新增部门", details = "新增部门")
|
@SysLog(title = "部门管理", businessType = OperaType.INSERT, module = "部门管理->新增部门", details = "新增部门")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysDept dept)
|
public AjaxResult add(@Validated @RequestBody SysDept dept) {
|
||||||
{
|
if (!deptService.checkDeptNameUnique(dept)) {
|
||||||
if (!deptService.checkDeptNameUnique(dept))
|
|
||||||
{
|
|
||||||
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
}
|
}
|
||||||
dept.setCreateBy(getUsername());
|
dept.setCreateBy(getUsername());
|
||||||
|
|
@ -94,22 +88,29 @@ public class SysDeptController extends BaseController
|
||||||
* 修改部门
|
* 修改部门
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:dept:edit")
|
@RequiresPermissions("system:dept:edit")
|
||||||
@SysLog(title = "部门管理", businessType = OperaType.UPDATE,module = "部门管理->修改部门", details = "修改部门")
|
@SysLog(title = "部门管理", businessType = OperaType.UPDATE, module = "部门管理->修改部门", details = "修改部门")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysDept dept)
|
public AjaxResult edit(@Validated @RequestBody SysDept dept) {
|
||||||
{
|
|
||||||
Long deptId = dept.getDeptId();
|
Long deptId = dept.getDeptId();
|
||||||
|
// 如果该部门已被使用,则无法修改
|
||||||
|
Integer num = deptService.getTransferApplyDeptId(deptId);
|
||||||
|
if (num > 0) {
|
||||||
|
return error("该部门或其子部门已被档案申请使用,请勿修改");
|
||||||
|
}
|
||||||
|
Integer num1 = deptService.getSysUserDeptId(deptId);
|
||||||
|
if (num1 > 0) {
|
||||||
|
return error("该部门或其子部门已被用户管理使用,请勿修改");
|
||||||
|
}
|
||||||
|
Integer num2 = deptService.getTransferIssueDeptId(deptId);
|
||||||
|
if (num2 > 0) {
|
||||||
|
return error("该部门或其子部门已被档案移交问题管理,请勿修改");
|
||||||
|
}
|
||||||
deptService.checkDeptDataScope(deptId);
|
deptService.checkDeptDataScope(deptId);
|
||||||
if (!deptService.checkDeptNameUnique(dept))
|
if (!deptService.checkDeptNameUnique(dept)) {
|
||||||
{
|
|
||||||
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
}
|
} else if (dept.getParentId().equals(deptId)) {
|
||||||
else if (dept.getParentId().equals(deptId))
|
|
||||||
{
|
|
||||||
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||||
}
|
} else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) {
|
||||||
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
|
|
||||||
{
|
|
||||||
return error("该部门包含未停用的子部门!");
|
return error("该部门包含未停用的子部门!");
|
||||||
}
|
}
|
||||||
dept.setUpdateBy(getUsername());
|
dept.setUpdateBy(getUsername());
|
||||||
|
|
@ -120,16 +121,26 @@ public class SysDeptController extends BaseController
|
||||||
* 删除部门
|
* 删除部门
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:dept:remove")
|
@RequiresPermissions("system:dept:remove")
|
||||||
@SysLog(title = "部门管理", businessType = OperaType.DELETE,module = "部门管理->删除部门", details = "删除部门")
|
@SysLog(title = "部门管理", businessType = OperaType.DELETE, module = "部门管理->删除部门", details = "删除部门")
|
||||||
@DeleteMapping("/{deptId}")
|
@DeleteMapping("/{deptId}")
|
||||||
public AjaxResult remove(@PathVariable Long deptId)
|
public AjaxResult remove(@PathVariable Long deptId) {
|
||||||
{
|
// 如果该部门已被使用,则无法删除
|
||||||
if (deptService.hasChildByDeptId(deptId))
|
Integer num = deptService.getTransferApplyDeptId(deptId);
|
||||||
{
|
if (num > 0) {
|
||||||
|
return error("该部门或其子部门已被档案申请使用,请勿删除");
|
||||||
|
}
|
||||||
|
Integer num1 = deptService.getSysUserDeptId(deptId);
|
||||||
|
if (num1 > 0) {
|
||||||
|
return error("该部门或其子部门已被用户管理使用,请勿删除");
|
||||||
|
}
|
||||||
|
Integer num2 = deptService.getTransferIssueDeptId(deptId);
|
||||||
|
if (num2 > 0) {
|
||||||
|
return error("该部门或其子部门已被档案移交问题管理,请勿删除");
|
||||||
|
}
|
||||||
|
if (deptService.hasChildByDeptId(deptId)) {
|
||||||
return warn("存在下级部门,不允许删除");
|
return warn("存在下级部门,不允许删除");
|
||||||
}
|
}
|
||||||
if (deptService.checkDeptExistUser(deptId))
|
if (deptService.checkDeptExistUser(deptId)) {
|
||||||
{
|
|
||||||
return warn("部门存在用户,不允许删除");
|
return warn("部门存在用户,不允许删除");
|
||||||
}
|
}
|
||||||
deptService.checkDeptDataScope(deptId);
|
deptService.checkDeptDataScope(deptId);
|
||||||
|
|
|
||||||
|
|
@ -115,4 +115,10 @@ public interface SysDeptMapper
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteDeptById(Long deptId);
|
public int deleteDeptById(Long deptId);
|
||||||
|
|
||||||
|
Integer getTransferApplyDeptId(Long deptId);
|
||||||
|
|
||||||
|
Integer getSysUserDeptId(Long deptId);
|
||||||
|
|
||||||
|
Integer getTransferIssueDeptId(Long deptId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,4 +121,10 @@ public interface ISysDeptService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteDeptById(Long deptId);
|
public int deleteDeptById(Long deptId);
|
||||||
|
|
||||||
|
Integer getTransferApplyDeptId(Long deptId);
|
||||||
|
|
||||||
|
Integer getSysUserDeptId(Long deptId);
|
||||||
|
|
||||||
|
Integer getTransferIssueDeptId(Long deptId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -297,6 +297,21 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
return deptMapper.deleteDeptById(deptId);
|
return deptMapper.deleteDeptById(deptId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getTransferApplyDeptId(Long deptId) {
|
||||||
|
return deptMapper.getTransferApplyDeptId(deptId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getSysUserDeptId(Long deptId) {
|
||||||
|
return deptMapper.getSysUserDeptId(deptId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getTransferIssueDeptId(Long deptId) {
|
||||||
|
return deptMapper.getTransferIssueDeptId(deptId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 递归列表
|
* 递归列表
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -86,8 +86,59 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<include refid="selectDeptVo"/>
|
<include refid="selectDeptVo"/>
|
||||||
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
|
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getTransferApplyDeptId" resultType="java.lang.Integer">
|
||||||
|
WITH RECURSIVE DeptTree AS (
|
||||||
|
SELECT dept_id
|
||||||
|
FROM da_ky_sys_dept
|
||||||
|
WHERE dept_id = #{deptId}
|
||||||
|
|
||||||
<insert id="insertDept" parameterType="SysDept">
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT d.dept_id
|
||||||
|
FROM da_ky_sys_dept d
|
||||||
|
INNER JOIN DeptTree dt ON d.parent_id = dt.dept_id
|
||||||
|
)
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM da_ky_transfer_apply t
|
||||||
|
INNER JOIN DeptTree dt ON t.dept_id = dt.dept_id
|
||||||
|
WHERE t.del_flag = '1'
|
||||||
|
</select>
|
||||||
|
<select id="getSysUserDeptId" resultType="java.lang.Integer">
|
||||||
|
WITH RECURSIVE DeptTree AS (
|
||||||
|
SELECT dept_id
|
||||||
|
FROM da_ky_sys_dept
|
||||||
|
WHERE dept_id = #{deptId}
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT d.dept_id
|
||||||
|
FROM da_ky_sys_dept d
|
||||||
|
INNER JOIN DeptTree dt ON d.parent_id = dt.dept_id
|
||||||
|
)
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM da_ky_sys_user t
|
||||||
|
INNER JOIN DeptTree dt ON t.dept_id = dt.dept_id
|
||||||
|
WHERE t.del_flag = '0'
|
||||||
|
</select>
|
||||||
|
<select id="getTransferIssueDeptId" resultType="java.lang.Integer">
|
||||||
|
WITH RECURSIVE DeptTree AS (
|
||||||
|
SELECT dept_id
|
||||||
|
FROM da_ky_sys_dept
|
||||||
|
WHERE dept_id = #{deptId}
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT d.dept_id
|
||||||
|
FROM da_ky_sys_dept d
|
||||||
|
INNER JOIN DeptTree dt ON d.parent_id = dt.dept_id
|
||||||
|
)
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM da_ky_transfer_issue t
|
||||||
|
INNER JOIN DeptTree dt ON t.dept_id = dt.dept_id
|
||||||
|
WHERE t.del_flag = '1'
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertDept" parameterType="SysDept">
|
||||||
insert into da_ky_sys_dept(
|
insert into da_ky_sys_dept(
|
||||||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||||
<if test="parentId != null and parentId != 0">parent_id,</if>
|
<if test="parentId != null and parentId != 0">parent_id,</if>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue