Search in sources :

Example 1 with DeptRespNodeVO

use of com.company.project.vo.resp.DeptRespNodeVO in project springboot-manager by aitangbao.

the class DeptServiceImpl method getChild.

private List<DeptRespNodeVO> getChild(String id, List<SysDept> all) {
    List<DeptRespNodeVO> list = new ArrayList<>();
    for (SysDept sysDept : all) {
        if (sysDept.getPid().equals(id)) {
            DeptRespNodeVO deptTree = new DeptRespNodeVO();
            BeanUtils.copyProperties(sysDept, deptTree);
            deptTree.setTitle(sysDept.getName());
            deptTree.setChildren(getChild(sysDept.getId(), all));
            list.add(deptTree);
        }
    }
    return list;
}
Also used : DeptRespNodeVO(com.company.project.vo.resp.DeptRespNodeVO) SysDept(com.company.project.entity.SysDept) ArrayList(java.util.ArrayList)

Example 2 with DeptRespNodeVO

use of com.company.project.vo.resp.DeptRespNodeVO in project springboot-manager by aitangbao.

the class DeptServiceImpl method deptTreeList.

@Override
public List<DeptRespNodeVO> deptTreeList(String deptId, Boolean disabled) {
    List<SysDept> list;
    if (StringUtils.isEmpty(deptId)) {
        list = sysDeptMapper.selectList(Wrappers.emptyWrapper());
    } else {
        SysDept sysDept = sysDeptMapper.selectById(deptId);
        if (sysDept == null) {
            throw new BusinessException(BaseResponseCode.DATA_ERROR);
        }
        LambdaQueryWrapper<SysDept> queryWrapper = Wrappers.<SysDept>lambdaQuery().likeRight(SysDept::getRelationCode, sysDept.getRelationCode());
        List<Object> childIds = sysDeptMapper.selectObjs(queryWrapper);
        list = sysDeptMapper.selectList(Wrappers.<SysDept>lambdaQuery().notIn(SysDept::getId, childIds));
    }
    // 默认加一个顶级方便新增顶级部门
    DeptRespNodeVO respNodeVO = new DeptRespNodeVO();
    respNodeVO.setTitle("默认顶级部门");
    respNodeVO.setId("0");
    respNodeVO.setSpread(true);
    respNodeVO.setDisabled(disabled);
    respNodeVO.setChildren(getTree(list));
    List<DeptRespNodeVO> result = new ArrayList<>();
    result.add(respNodeVO);
    return result;
}
Also used : DeptRespNodeVO(com.company.project.vo.resp.DeptRespNodeVO) BusinessException(com.company.project.common.exception.BusinessException) SysDept(com.company.project.entity.SysDept) ArrayList(java.util.ArrayList)

Example 3 with DeptRespNodeVO

use of com.company.project.vo.resp.DeptRespNodeVO in project springboot-manager by aitangbao.

the class DeptServiceImpl method getTree.

private List<DeptRespNodeVO> getTree(List<SysDept> all) {
    List<DeptRespNodeVO> list = new ArrayList<>();
    for (SysDept sysDept : all) {
        if ("0".equals(sysDept.getPid())) {
            DeptRespNodeVO deptTree = new DeptRespNodeVO();
            BeanUtils.copyProperties(sysDept, deptTree);
            deptTree.setTitle(sysDept.getName());
            deptTree.setSpread(true);
            deptTree.setChildren(getChild(sysDept.getId(), all));
            list.add(deptTree);
        }
    }
    return list;
}
Also used : DeptRespNodeVO(com.company.project.vo.resp.DeptRespNodeVO) SysDept(com.company.project.entity.SysDept) ArrayList(java.util.ArrayList)

Example 4 with DeptRespNodeVO

use of com.company.project.vo.resp.DeptRespNodeVO in project springboot-manager by aitangbao.

the class RoleServiceImpl method detailInfo.

@Override
public SysRole detailInfo(String id) {
    SysRole sysRole = sysRoleMapper.selectById(id);
    if (sysRole == null) {
        log.error("传入 的 id:{}不合法", id);
        throw new BusinessException(BaseResponseCode.DATA_ERROR);
    }
    List<PermissionRespNode> permissionRespNodes = permissionService.selectAllByTree();
    LambdaQueryWrapper<SysRolePermission> queryWrapper = Wrappers.<SysRolePermission>lambdaQuery().select(SysRolePermission::getPermissionId).eq(SysRolePermission::getRoleId, sysRole.getId());
    Set<Object> checkList = new HashSet<>(rolePermissionService.listObjs(queryWrapper));
    setChecked(permissionRespNodes, checkList);
    sysRole.setPermissionRespNodes(permissionRespNodes);
    LambdaQueryWrapper<SysRoleDeptEntity> queryWrapperDept = Wrappers.<SysRoleDeptEntity>lambdaQuery().select(SysRoleDeptEntity::getDeptId).eq(SysRoleDeptEntity::getRoleId, sysRole.getId());
    List<DeptRespNodeVO> deptRespNodes = deptService.deptTreeList(null, true);
    Set<Object> checkDeptList = new HashSet<>(sysRoleDeptService.listObjs(queryWrapperDept));
    setCheckedDept(deptRespNodes, checkDeptList);
    sysRole.setDeptRespNodes(deptRespNodes);
    return sysRole;
}
Also used : SysRolePermission(com.company.project.entity.SysRolePermission) PermissionRespNode(com.company.project.vo.resp.PermissionRespNode) DeptRespNodeVO(com.company.project.vo.resp.DeptRespNodeVO) BusinessException(com.company.project.common.exception.BusinessException) SysRole(com.company.project.entity.SysRole) SysRoleDeptEntity(com.company.project.entity.SysRoleDeptEntity) HashSet(java.util.HashSet)

Aggregations

DeptRespNodeVO (com.company.project.vo.resp.DeptRespNodeVO)4 SysDept (com.company.project.entity.SysDept)3 ArrayList (java.util.ArrayList)3 BusinessException (com.company.project.common.exception.BusinessException)2 SysRole (com.company.project.entity.SysRole)1 SysRoleDeptEntity (com.company.project.entity.SysRoleDeptEntity)1 SysRolePermission (com.company.project.entity.SysRolePermission)1 PermissionRespNode (com.company.project.vo.resp.PermissionRespNode)1 HashSet (java.util.HashSet)1