Search in sources :

Example 1 with SysDept

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

Example 2 with SysDept

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

the class SysDeptServiceImpl method updateDept.

/**
 * 修改保存部门信息
 *
 * @param dept 部门信息
 * @return 结果
 */
@Override
public int updateDept(SysDept dept) {
    SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
    SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
    if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
        String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
        String oldAncestors = oldDept.getAncestors();
        dept.setAncestors(newAncestors);
        updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
    }
    int result = deptMapper.updateDept(dept);
    if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) && !StringUtils.equals("0", dept.getAncestors())) {
        // 如果该部门是启用状态,则启用该部门的所有上级部门
        updateParentDeptStatusNormal(dept);
    }
    return result;
}
Also used : SysDept(com.ruoyi.system.api.domain.SysDept)

Example 3 with SysDept

use of com.ruoyi.system.api.domain.SysDept in project RuoYi-Cloud 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 4 with SysDept

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

the class SysDeptServiceImpl method checkDeptDataScope.

/**
 * 校验部门是否有数据权限
 *
 * @param deptId 部门id
 */
@Override
public void checkDeptDataScope(Long deptId) {
    if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
        SysDept dept = new SysDept();
        dept.setDeptId(deptId);
        List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
        if (StringUtils.isEmpty(depts)) {
            throw new ServiceException("没有权限访问部门数据!");
        }
    }
}
Also used : ServiceException(com.ruoyi.common.core.exception.ServiceException) SysDept(com.ruoyi.system.api.domain.SysDept)

Example 5 with SysDept

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

the class SysDeptServiceImpl method updateDept.

/**
 * 修改保存部门信息
 *
 * @param dept 部门信息
 * @return 结果
 */
@Override
public int updateDept(SysDept dept) {
    SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
    SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
    if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
        String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
        String oldAncestors = oldDept.getAncestors();
        dept.setAncestors(newAncestors);
        updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
    }
    int result = deptMapper.updateDept(dept);
    if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) && !StringUtils.equals("0", dept.getAncestors())) {
        // 如果该部门是启用状态,则启用该部门的所有上级部门
        updateParentDeptStatusNormal(dept);
    }
    return result;
}
Also used : SysDept(com.ruoyi.system.api.domain.SysDept)

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