Search in sources :

Example 16 with SysRole

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

the class SysRoleServiceImpl method checkRoleNameUnique.

/**
 * 校验角色名称是否唯一
 *
 * @param role 角色信息
 * @return 结果
 */
@Override
public String checkRoleNameUnique(SysRole role) {
    Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
    SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName());
    if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
        return UserConstants.NOT_UNIQUE;
    }
    return UserConstants.UNIQUE;
}
Also used : SysRole(com.ruoyi.system.api.domain.SysRole)

Example 17 with SysRole

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

the class SysRoleServiceImpl method checkRoleNameUnique.

/**
 * 校验角色名称是否唯一
 *
 * @param role 角色信息
 * @return 结果
 */
@Override
public String checkRoleNameUnique(SysRole role) {
    Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
    SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName());
    if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
        return UserConstants.NOT_UNIQUE;
    }
    return UserConstants.UNIQUE;
}
Also used : SysRole(com.ruoyi.system.api.domain.SysRole)

Example 18 with SysRole

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

the class SysRoleServiceImpl method checkRoleKeyUnique.

/**
 * 校验角色权限是否唯一
 *
 * @param role 角色信息
 * @return 结果
 */
@Override
public String checkRoleKeyUnique(SysRole role) {
    Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
    SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey());
    if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
        return UserConstants.NOT_UNIQUE;
    }
    return UserConstants.UNIQUE;
}
Also used : SysRole(com.ruoyi.system.api.domain.SysRole)

Example 19 with SysRole

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

the class SysRoleServiceImpl method selectRolesByUserId.

/**
 * 根据用户ID查询角色
 *
 * @param userId 用户ID
 * @return 角色列表
 */
@Override
public List<SysRole> selectRolesByUserId(Long userId) {
    List<SysRole> userRoles = roleMapper.selectRolePermissionByUserId(userId);
    List<SysRole> roles = selectRoleAll();
    for (SysRole role : roles) {
        for (SysRole userRole : userRoles) {
            if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) {
                role.setFlag(true);
                break;
            }
        }
    }
    return roles;
}
Also used : SysRole(com.ruoyi.system.api.domain.SysRole)

Example 20 with SysRole

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

the class SysRoleServiceImpl method deleteRoleByIds.

/**
 * 批量删除角色信息
 *
 * @param roleIds 需要删除的角色ID
 * @return 结果
 */
@Override
@Transactional(rollbackFor = Exception.class)
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.core.exception.ServiceException) SysRole(com.ruoyi.system.api.domain.SysRole) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

SysRole (com.ruoyi.system.api.domain.SysRole)24 UserConstants (com.ruoyi.common.core.constant.UserConstants)6 R (com.ruoyi.common.core.domain.R)6 ServiceException (com.ruoyi.common.core.exception.ServiceException)6 StringUtils (com.ruoyi.common.core.utils.StringUtils)6 BaseController (com.ruoyi.common.core.web.controller.BaseController)6 Log (com.ruoyi.common.log.annotation.Log)6 BusinessType (com.ruoyi.common.log.enums.BusinessType)6 SysUser (com.ruoyi.system.api.domain.SysUser)6 ISysPermissionService (com.ruoyi.system.service.ISysPermissionService)6 ISysPostService (com.ruoyi.system.service.ISysPostService)6 ISysRoleService (com.ruoyi.system.service.ISysRoleService)6 ISysUserService (com.ruoyi.system.service.ISysUserService)6 IOException (java.io.IOException)6 Collectors (java.util.stream.Collectors)6 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 ArrayUtils (org.apache.commons.lang3.ArrayUtils)6 Validated (org.springframework.validation.annotation.Validated)6 MultipartFile (org.springframework.web.multipart.MultipartFile)6 ExcelUtil (com.ruoyi.common.core.utils.poi.ExcelUtil)4