“djh”
5 天以前 99132a43bf344f2aafdd9894b0762d2eedd9767b
multi-admin/src/main/java/com/gkhy/exam/admin/controller/system/SysDeptController.java
@@ -4,6 +4,7 @@
import cn.hutool.core.util.ObjectUtil;
import com.gkhy.exam.common.api.CommonResult;
import com.gkhy.exam.common.constant.UserConstant;
import com.gkhy.exam.common.domain.TreeSelect;
import com.gkhy.exam.common.domain.entity.SysDept;
import com.gkhy.exam.system.domain.SysFunctionalDistribution;
import com.gkhy.exam.system.domain.vo.DeptVo;
@@ -31,7 +32,7 @@
 * 
 * @author expert
 */
@Api(tags = "部门-业务处室")
@Api(tags = "部门管理")
@RestController
@RequestMapping("/system/dept")
public class SysDeptController
@@ -54,23 +55,32 @@
    }
    @GetMapping("/treeList")
    @ApiOperation(value = "获取部门列表树状")
    public CommonResult treeList(SysDept dept)
    {
        List<TreeSelect> treeSelects = deptService.selectDeptTreeList(dept);
        return CommonResult.success(treeSelects);
    }
    /**
     * 查询部门列表(排除节点)
     */
    //@PreAuthorize("hasAnyAuthority('system:dept:list')")
    @GetMapping("/list/exclude/{deptId}")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "deptId", dataType = "Long", required = true, value = "部门id"),
    })
    @ApiOperation(value = "查询部门列表(排除节点)")
    public CommonResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
    {
        List<SysDept> depts = deptService.getOutDeptList(new SysDept());
        depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
        return CommonResult.success(depts);
    }
//    @GetMapping("/list/exclude/{deptId}")
//    @ApiImplicitParams({
//            @ApiImplicitParam(paramType = "query", name = "deptId", dataType = "Long", required = true, value = "部门id"),
//    })
//    @ApiOperation(value = "查询部门列表(排除节点)")
//    public CommonResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
//    {
//        List<SysDept> depts = deptService.getOutDeptList(new SysDept());
//        depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
//        return CommonResult.success(depts);
//    }
    /**
     * 根据部门编号获取详细信息
@@ -182,19 +192,19 @@
     */
    //@PreAuthorize("hasAnyAuthority('system:dept:remove')")
    @DeleteMapping("/{deptId}")
    @ApiOperation(value = "删除部门门业务处室")
    @ApiOperation(value = "删除部门")
    public CommonResult remove(@PathVariable Long deptId)
    {
        if (deptService.hasChildByDeptId(deptId))
        {
            return CommonResult.failed("存在下级部门,不允许删除");
        }
        if (deptService.checkDeptExistUser(deptId))
        {
            return CommonResult.failed("部门存在用户,不允许删除");
        }
//        if (deptService.checkDeptExistUser(deptId))
//        {
//            return CommonResult.failed("部门存在用户,不允许删除");
//        }
        //todo  校验专家是否申请复用
        deptService.checkDeptDataScope(deptId);
//        deptService.checkDeptDataScope(deptId);
        return CommonResult.success(deptService.deleteDeptById(deptId));
    }
}