Search in sources :

Example 11 with SysDept

use of com.ruoyi.system.api.domain.SysDept in project RuoYi-Cloud-Oracle by yangzongzhuan.

the class SysDeptController method excludeChild.

/**
 * 查询部门列表(排除节点)
 */
@RequiresPermissions("system:dept:list")
@GetMapping("/list/exclude/{deptId}")
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
    List<SysDept> depts = deptService.selectDeptList(new SysDept());
    Iterator<SysDept> it = depts.iterator();
    while (it.hasNext()) {
        SysDept d = (SysDept) it.next();
        if (d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")) {
            it.remove();
        }
    }
    return AjaxResult.success(depts);
}
Also used : SysDept(com.ruoyi.system.api.domain.SysDept) RequiresPermissions(com.ruoyi.common.security.annotation.RequiresPermissions) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 12 with SysDept

use of com.ruoyi.system.api.domain.SysDept in project RuoYi-Cloud-Plus by JavaLionLi.

the class SysDeptController method roleDeptTreeselect.

/**
 * 加载对应角色部门列表树
 */
@ApiOperation("加载对应角色部门列表树")
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
public R<Map<String, Object>> roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
    List<SysDept> depts = deptService.selectDeptList(new SysDept());
    Map<String, Object> ajax = new HashMap<>();
    ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
    ajax.put("depts", deptService.buildDeptTreeSelect(depts));
    return R.ok(ajax);
}
Also used : HashMap(java.util.HashMap) SysDept(com.ruoyi.system.api.domain.SysDept) ApiOperation(io.swagger.annotations.ApiOperation)

Example 13 with SysDept

use of com.ruoyi.system.api.domain.SysDept in project RuoYi-Cloud-Plus by JavaLionLi.

the class SysDeptServiceImpl method updateDeptChildren.

/**
 * 修改子元素关系
 *
 * @param deptId       被修改的部门ID
 * @param newAncestors 新的父ID集合
 * @param oldAncestors 旧的父ID集合
 */
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
    List<SysDept> children = baseMapper.selectList(new LambdaQueryWrapper<SysDept>().apply("find_in_set({0},ancestors) <> 0", deptId));
    List<SysDept> list = new ArrayList<>();
    for (SysDept child : children) {
        SysDept dept = new SysDept();
        dept.setDeptId(child.getDeptId());
        dept.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
        list.add(dept);
    }
    if (list.size() > 0) {
        baseMapper.updateBatchById(list);
    }
}
Also used : SysDept(com.ruoyi.system.api.domain.SysDept) ArrayList(java.util.ArrayList) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 14 with SysDept

use of com.ruoyi.system.api.domain.SysDept in project RuoYi-Cloud by yangzongzhuan.

the class SysDeptController method excludeChild.

/**
 * 查询部门列表(排除节点)
 */
@RequiresPermissions("system:dept:list")
@GetMapping("/list/exclude/{deptId}")
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
    List<SysDept> depts = deptService.selectDeptList(new SysDept());
    Iterator<SysDept> it = depts.iterator();
    while (it.hasNext()) {
        SysDept d = (SysDept) it.next();
        if (d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")) {
            it.remove();
        }
    }
    return AjaxResult.success(depts);
}
Also used : SysDept(com.ruoyi.system.api.domain.SysDept) RequiresPermissions(com.ruoyi.common.security.annotation.RequiresPermissions) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 15 with SysDept

use of com.ruoyi.system.api.domain.SysDept in project RuoYi-Cloud by yangzongzhuan.

the class SysDeptController method roleDeptTreeselect.

/**
 * 加载对应角色部门列表树
 */
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
    List<SysDept> depts = deptService.selectDeptList(new SysDept());
    AjaxResult ajax = AjaxResult.success();
    ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
    ajax.put("depts", deptService.buildDeptTreeSelect(depts));
    return ajax;
}
Also used : AjaxResult(com.ruoyi.common.core.web.domain.AjaxResult) SysDept(com.ruoyi.system.api.domain.SysDept) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

SysDept (com.ruoyi.system.api.domain.SysDept)25 ServiceException (com.ruoyi.common.core.exception.ServiceException)6 ArrayList (java.util.ArrayList)5 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 ApiOperation (io.swagger.annotations.ApiOperation)3 SaCheckPermission (cn.dev33.satoken.annotation.SaCheckPermission)2 AjaxResult (com.ruoyi.common.core.web.domain.AjaxResult)2 RequiresPermissions (com.ruoyi.common.security.annotation.RequiresPermissions)2 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1 Log (com.ruoyi.common.log.annotation.Log)1 SysUser (com.ruoyi.system.api.domain.SysUser)1 SysUserExportVo (com.ruoyi.system.domain.vo.SysUserExportVo)1 HashMap (java.util.HashMap)1