Search in sources :

Example 16 with SysDept

use of com.ruoyi.project.system.domain.SysDept in project RuoYi-Vue-fast 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.exception.ServiceException) SysDept(com.ruoyi.project.system.domain.SysDept)

Example 17 with SysDept

use of com.ruoyi.project.system.domain.SysDept in project RuoYi-Vue-fast 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.exception.ServiceException) SysDept(com.ruoyi.project.system.domain.SysDept)

Example 18 with SysDept

use of com.ruoyi.project.system.domain.SysDept in project RuoYi-Vue-fast 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.project.system.domain.SysDept) GetMapping(org.springframework.web.bind.annotation.GetMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

SysDept (com.ruoyi.project.system.domain.SysDept)18 ServiceException (com.ruoyi.common.exception.ServiceException)4 ArrayList (java.util.ArrayList)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 AjaxResult (com.ruoyi.framework.web.domain.AjaxResult)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2