use of com.ruoyi.common.core.domain.entity.SysRole in project RuoYi-Vue-Plus by JavaLionLi.
the class SysRoleServiceImpl method selectRolePermissionByUserId.
/**
* 根据用户ID查询权限
*
* @param userId 用户ID
* @return 权限列表
*/
@Override
public Set<String> selectRolePermissionByUserId(Long userId) {
List<SysRole> perms = baseMapper.selectRolePermissionByUserId(userId);
Set<String> permsSet = new HashSet<>();
for (SysRole perm : perms) {
if (ObjectUtil.isNotNull(perm)) {
permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
}
}
return permsSet;
}
use of com.ruoyi.common.core.domain.entity.SysRole in project RuoYi-Vue-Plus by JavaLionLi.
the class SysRoleServiceImpl method checkRoleDataScope.
/**
* 校验角色是否有数据权限
*
* @param roleId 角色id
*/
@Override
public void checkRoleDataScope(Long roleId) {
if (!LoginHelper.isAdmin()) {
SysRole role = new SysRole();
role.setRoleId(roleId);
List<SysRole> roles = this.selectRoleList(role);
if (CollUtil.isEmpty(roles)) {
throw new ServiceException("没有权限访问角色数据!");
}
}
}
use of com.ruoyi.common.core.domain.entity.SysRole in project RuoYi-Flowable-Plus by KonBAI-Q.
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()));
}
}
List<Long> ids = Arrays.asList(roleIds);
// 删除角色与菜单关联
roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().in(SysRoleMenu::getRoleId, ids));
// 删除角色与部门关联
roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().in(SysRoleDept::getRoleId, ids));
return baseMapper.deleteBatchIds(ids);
}
use of com.ruoyi.common.core.domain.entity.SysRole in project wumei-smart by kerwincui.
the class CategoryServiceImpl method insertCategory.
/**
* 新增产品分类
*
* @param category 产品分类
* @return 结果
*/
@Override
public int insertCategory(Category category) {
SysUser user = getLoginUser().getUser();
List<SysRole> roles = user.getRoles();
if (roles == null || roles.size() == 0) {
return 0;
}
// 系统管理员
if (roles.stream().anyMatch(a -> a.getRoleKey().equals("admin"))) {
category.setIsSys(1);
}
category.setTenantId(user.getUserId());
category.setTenantName(user.getUserName());
category.setCreateTime(DateUtils.getNowDate());
return categoryMapper.insertCategory(category);
}
use of com.ruoyi.common.core.domain.entity.SysRole in project wumei-smart by kerwincui.
the class FirmwareServiceImpl method insertFirmware.
/**
* 新增产品固件
*
* @param firmware 产品固件
* @return 结果
*/
@Override
public int insertFirmware(Firmware firmware) {
SysUser user = getLoginUser().getUser();
List<SysRole> roles = user.getRoles();
if (roles == null || roles.size() == 0) {
return 0;
}
// 系统管理员
if (roles.stream().anyMatch(a -> a.getRoleKey().equals("admin"))) {
firmware.setIsSys(1);
}
firmware.setTenantId(user.getUserId());
firmware.setTenantName(user.getUserName());
firmware.setCreateTime(DateUtils.getNowDate());
return firmwareMapper.insertFirmware(firmware);
}
Aggregations