Search in sources :

Example 6 with SysDept

use of com.ruoyi.common.core.domain.entity.SysDept in project RuoYi-Vue-Plus by JavaLionLi.

the class SysDeptController method excludeChild.

/**
 * 查询部门列表(排除节点)
 */
@ApiOperation("查询部门列表(排除节点)")
@SaCheckPermission("system:dept:list")
@GetMapping("/list/exclude/{deptId}")
public R<List<SysDept>> excludeChild(@ApiParam("部门ID") @PathVariable(value = "deptId", required = false) Long deptId) {
    List<SysDept> depts = deptService.selectDeptList(new SysDept());
    depts.removeIf(d -> d.getDeptId().equals(deptId) || ArrayUtil.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
    return R.ok(depts);
}
Also used : SysDept(com.ruoyi.common.core.domain.entity.SysDept) ApiOperation(io.swagger.annotations.ApiOperation) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Example 7 with SysDept

use of com.ruoyi.common.core.domain.entity.SysDept in project wumei-smart by kerwincui.

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.domain.AjaxResult) SysDept(com.ruoyi.common.core.domain.entity.SysDept) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 8 with SysDept

use of com.ruoyi.common.core.domain.entity.SysDept in project wumei-smart by kerwincui.

the class SysDeptServiceImpl method buildDeptTree.

/**
 * 构建前端所需要树结构
 *
 * @param depts 部门列表
 * @return 树结构列表
 */
@Override
public List<SysDept> buildDeptTree(List<SysDept> depts) {
    List<SysDept> returnList = new ArrayList<SysDept>();
    List<Long> tempList = new ArrayList<Long>();
    for (SysDept dept : depts) {
        tempList.add(dept.getDeptId());
    }
    for (Iterator<SysDept> iterator = depts.iterator(); iterator.hasNext(); ) {
        SysDept dept = (SysDept) iterator.next();
        // 如果是顶级节点, 遍历该父节点的所有子节点
        if (!tempList.contains(dept.getParentId())) {
            recursionFn(depts, dept);
            returnList.add(dept);
        }
    }
    if (returnList.isEmpty()) {
        returnList = depts;
    }
    return returnList;
}
Also used : SysDept(com.ruoyi.common.core.domain.entity.SysDept) ArrayList(java.util.ArrayList)

Example 9 with SysDept

use of com.ruoyi.common.core.domain.entity.SysDept in project wumei-smart by kerwincui.

the class SysDeptServiceImpl method recursionFn.

/**
 * 递归列表
 */
private void recursionFn(List<SysDept> list, SysDept t) {
    // 得到子节点列表
    List<SysDept> childList = getChildList(list, t);
    t.setChildren(childList);
    for (SysDept tChild : childList) {
        if (hasChild(list, tChild)) {
            recursionFn(list, tChild);
        }
    }
}
Also used : SysDept(com.ruoyi.common.core.domain.entity.SysDept)

Example 10 with SysDept

use of com.ruoyi.common.core.domain.entity.SysDept in project RuoYi-Vue by yangzongzhuan.

the class SysDeptServiceImpl method buildDeptTree.

/**
 * 构建前端所需要树结构
 *
 * @param depts 部门列表
 * @return 树结构列表
 */
@Override
public List<SysDept> buildDeptTree(List<SysDept> depts) {
    List<SysDept> returnList = new ArrayList<SysDept>();
    List<Long> tempList = new ArrayList<Long>();
    for (SysDept dept : depts) {
        tempList.add(dept.getDeptId());
    }
    for (SysDept dept : depts) {
        // 如果是顶级节点, 遍历该父节点的所有子节点
        if (!tempList.contains(dept.getParentId())) {
            recursionFn(depts, dept);
            returnList.add(dept);
        }
    }
    if (returnList.isEmpty()) {
        returnList = depts;
    }
    return returnList;
}
Also used : SysDept(com.ruoyi.common.core.domain.entity.SysDept) ArrayList(java.util.ArrayList)

Aggregations

SysDept (com.ruoyi.common.core.domain.entity.SysDept)39 ServiceException (com.ruoyi.common.exception.ServiceException)8 ArrayList (java.util.ArrayList)7 GetMapping (org.springframework.web.bind.annotation.GetMapping)6 SaCheckPermission (cn.dev33.satoken.annotation.SaCheckPermission)4 ApiOperation (io.swagger.annotations.ApiOperation)4 AjaxResult (com.ruoyi.common.core.domain.AjaxResult)3 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)3 Log (com.ruoyi.common.annotation.Log)2 SysUser (com.ruoyi.common.core.domain.entity.SysUser)2 SysUserExportVo (com.ruoyi.system.domain.vo.SysUserExportVo)2 HashMap (java.util.HashMap)2 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1 CustomException (com.ruoyi.common.exception.CustomException)1