| | |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.account.constant.I18nKeyConstant; |
| | | import com.xiaopeng.account.mapper.SysRoleMapper; |
| | | import com.xiaopeng.account.mapper.SysRoleMenuMapper; |
| | | import com.xiaopeng.account.mapper.XpOperationsRoleMapper; |
| | | import com.xiaopeng.account.model.dto.SysRoleAddDTO; |
| | | import com.xiaopeng.account.model.dto.SysRoleEditDTO; |
| | | import com.xiaopeng.account.model.query.SysRolePageQuery; |
| | |
| | | import com.xiaopeng.api.feignClient.operation.SysMenuClient; |
| | | import com.xiaopeng.api.model.account.SysRole; |
| | | import com.xiaopeng.api.model.account.SysUserRole; |
| | | import com.xiaopeng.api.model.account.XpOperationsRole; |
| | | import com.xiaopeng.api.model.operation.SysMenu; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.exception.ServiceException; |
| | |
| | | private final SysMenuClient sysMenuClient; |
| | | |
| | | private final SysRoleMenuMapper sysRoleMenuMapper; |
| | | private final XpOperationsRoleMapper xpOperationsRoleMapper; |
| | | |
| | | /** |
| | | * 根据角色ID查询权限组ID |
| | |
| | | public Boolean checkMenuExistRole(Long menuId) { |
| | | return sysRoleMenuMapper.checkMenuExistRole(menuId) > 0; |
| | | } |
| | | |
| | | @Override |
| | | public Set<String> selectRolePermissionByOperationUserId(Long userId) { |
| | | Set<String> roles = new HashSet<>(); |
| | | if (userId == null) { |
| | | return roles; |
| | | } |
| | | |
| | | // 查询用户关联的角色 |
| | | List<XpOperationsRole> xpOperationsRoles = xpOperationsRoleMapper.selectSysUserRoleByOperationUserId(userId); |
| | | if (CollectionUtils.isEmpty(xpOperationsRoles)) { |
| | | return roles; |
| | | } |
| | | |
| | | // 查询角色信息 |
| | | List<Long> roleIds = xpOperationsRoles.stream().map(XpOperationsRole::getRoleId).collect(Collectors.toList()); |
| | | List<SysRole> roleList= this.list(Wrappers.lambdaQuery(SysRole.class) |
| | | .in(SysRole::getId, roleIds)); |
| | | if (!CollectionUtils.isEmpty(roleList)) { |
| | | roleList.forEach(role -> { |
| | | if (role != null) { |
| | | roles.add(role.getRoleName()); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | return roles; |
| | | } |
| | | } |