Search in sources :

Example 16 with SysDept

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

the class SysDeptServiceImpl method getChildList.

/**
 * 得到子节点列表
 */
private List<SysDept> getChildList(List<SysDept> list, SysDept t) {
    List<SysDept> tlist = new ArrayList<SysDept>();
    Iterator<SysDept> it = list.iterator();
    while (it.hasNext()) {
        SysDept n = (SysDept) it.next();
        if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) {
            tlist.add(n);
        }
    }
    return tlist;
}
Also used : SysDept(com.ruoyi.system.api.domain.SysDept) ArrayList(java.util.ArrayList)

Example 17 with SysDept

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

the class SysDeptServiceImpl method checkDeptNameUnique.

/**
 * 校验部门名称是否唯一
 *
 * @param dept 部门信息
 * @return 结果
 */
@Override
public String checkDeptNameUnique(SysDept dept) {
    Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
    SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
    if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) {
        return UserConstants.NOT_UNIQUE;
    }
    return UserConstants.UNIQUE;
}
Also used : SysDept(com.ruoyi.system.api.domain.SysDept)

Example 18 with SysDept

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

the class SysDeptServiceImpl method getChildList.

/**
 * 得到子节点列表
 */
private List<SysDept> getChildList(List<SysDept> list, SysDept t) {
    List<SysDept> tlist = new ArrayList<SysDept>();
    Iterator<SysDept> it = list.iterator();
    while (it.hasNext()) {
        SysDept n = (SysDept) it.next();
        if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) {
            tlist.add(n);
        }
    }
    return tlist;
}
Also used : SysDept(com.ruoyi.system.api.domain.SysDept) ArrayList(java.util.ArrayList)

Example 19 with SysDept

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

the class SysDeptServiceImpl method insertDept.

/**
 * 新增保存部门信息
 *
 * @param dept 部门信息
 * @return 结果
 */
@Override
public int insertDept(SysDept dept) {
    SysDept info = deptMapper.selectDeptById(dept.getParentId());
    // 如果父节点不为正常状态,则不允许新增子节点
    if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
        throw new ServiceException("部门停用,不允许新增");
    }
    dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
    return deptMapper.insertDept(dept);
}
Also used : ServiceException(com.ruoyi.common.core.exception.ServiceException) SysDept(com.ruoyi.system.api.domain.SysDept)

Example 20 with SysDept

use of com.ruoyi.system.api.domain.SysDept in project RuoYi-Cloud 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.system.api.domain.SysDept) ArrayList(java.util.ArrayList)

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