Search in sources :

Example 61 with ServiceException

use of com.ruoyi.common.exception.ServiceException in project RuoYi-Vue-Oracle by yangzongzhuan.

the class SysRoleServiceImpl method checkRoleDataScope.

/**
 * 校验角色是否有数据权限
 *
 * @param roleId 角色id
 */
@Override
public void checkRoleDataScope(Long roleId) {
    if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
        SysRole role = new SysRole();
        role.setRoleId(roleId);
        List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
        if (StringUtils.isEmpty(roles)) {
            throw new ServiceException("没有权限访问角色数据!");
        }
    }
}
Also used : ServiceException(com.ruoyi.common.exception.ServiceException) SysRole(com.ruoyi.project.system.domain.SysRole)

Example 62 with ServiceException

use of com.ruoyi.common.exception.ServiceException in project RuoYi-Vue-Oracle by yangzongzhuan.

the class SysRoleServiceImpl method deleteRoleByIds.

/**
 * 批量删除角色信息
 *
 * @param roleIds 需要删除的角色ID
 * @return 结果
 */
@Override
@Transactional
public int deleteRoleByIds(Long[] roleIds) {
    for (Long roleId : roleIds) {
        checkRoleAllowed(new SysRole(roleId));
        checkRoleDataScope(roleId);
        SysRole role = selectRoleById(roleId);
        if (countUserRoleByRoleId(roleId) > 0) {
            throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName()));
        }
    }
    // 删除角色与菜单关联
    roleMenuMapper.deleteRoleMenu(roleIds);
    // 删除角色与部门关联
    roleDeptMapper.deleteRoleDept(roleIds);
    return roleMapper.deleteRoleByIds(roleIds);
}
Also used : ServiceException(com.ruoyi.common.exception.ServiceException) SysRole(com.ruoyi.project.system.domain.SysRole) Transactional(org.springframework.transaction.annotation.Transactional)

Example 63 with ServiceException

use of com.ruoyi.common.exception.ServiceException in project RuoYi-Vue-Oracle by yangzongzhuan.

the class SysConfigServiceImpl method deleteConfigByIds.

/**
 * 批量删除参数信息
 *
 * @param configIds 需要删除的参数ID
 */
@Override
public void deleteConfigByIds(Long[] configIds) {
    for (Long configId : configIds) {
        SysConfig config = selectConfigById(configId);
        if (StringUtils.equals(UserConstants.YES, config.getConfigType())) {
            throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
        }
        configMapper.deleteConfigById(configId);
        redisCache.deleteObject(getCacheKey(config.getConfigKey()));
    }
}
Also used : SysConfig(com.ruoyi.project.system.domain.SysConfig) ServiceException(com.ruoyi.common.exception.ServiceException)

Example 64 with ServiceException

use of com.ruoyi.common.exception.ServiceException in project RuoYi-Vue-Oracle 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 65 with ServiceException

use of com.ruoyi.common.exception.ServiceException in project RuoYi-Vue-Oracle 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)

Aggregations

ServiceException (com.ruoyi.common.exception.ServiceException)109 IOException (java.io.IOException)21 Transactional (org.springframework.transaction.annotation.Transactional)21 GenTable (com.ruoyi.generator.domain.GenTable)12 StringWriter (java.io.StringWriter)12 Template (org.apache.velocity.Template)12 VelocityContext (org.apache.velocity.VelocityContext)12 SysRole (com.ruoyi.common.core.domain.entity.SysRole)10 File (java.io.File)10 SysUser (com.ruoyi.common.core.domain.entity.SysUser)9 GenTableColumn (com.ruoyi.generator.domain.GenTableColumn)8 Before (org.aspectj.lang.annotation.Before)8 JSONObject (com.alibaba.fastjson.JSONObject)6 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)6 SysDept (com.ruoyi.common.core.domain.entity.SysDept)6 LoginUser (com.ruoyi.common.core.domain.model.LoginUser)6 Constants (com.ruoyi.common.constant.Constants)5 GenConstants (com.ruoyi.common.constant.GenConstants)5 StringUtils (com.ruoyi.common.utils.StringUtils)5 SysOss (com.ruoyi.system.domain.SysOss)5