Search in sources :

Example 11 with SysDept

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

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 12 with SysDept

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

the class SysDeptController method excludeChild.

/**
 * 查询部门列表(排除节点)
 */
@PreAuthorize("@ss.hasPermi('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.common.core.domain.entity.SysDept) GetMapping(org.springframework.web.bind.annotation.GetMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 13 with SysDept

use of com.ruoyi.common.core.domain.entity.SysDept in project hocassian-media-matrix by hokaso.

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.common.core.domain.entity.SysDept) ArrayList(java.util.ArrayList)

Example 14 with SysDept

use of com.ruoyi.common.core.domain.entity.SysDept in project hocassian-media-matrix by hokaso.

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 CustomException("部门停用,不允许新增");
    }
    dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
    return deptMapper.insertDept(dept);
}
Also used : SysDept(com.ruoyi.common.core.domain.entity.SysDept) CustomException(com.ruoyi.common.exception.CustomException)

Example 15 with SysDept

use of com.ruoyi.common.core.domain.entity.SysDept in project hocassian-media-matrix by hokaso.

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)

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