|
@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.zanxiang.erp.base.ErpServer;
|
|
|
+import com.zanxiang.erp.base.pojo.vo.SysGameUserGroupRpcVO;
|
|
|
+import com.zanxiang.erp.base.rpc.ISysGameUserGroupRpc;
|
|
|
import com.zanxiang.erp.base.rpc.ISysUserRpc;
|
|
|
import com.zanxiang.erp.security.util.SecurityUtil;
|
|
|
import com.zanxiang.game.module.base.pojo.enums.DeleteEnum;
|
|
@@ -54,6 +57,9 @@ public class GameAuthServiceImpl extends ServiceImpl<GameAuthMapper, GameAuth> i
|
|
|
@DubboReference(providedBy = ErpServer.SERVER_DUBBO_NAME)
|
|
|
private ISysUserRpc sysUserRpc;
|
|
|
|
|
|
+ @DubboReference(providedBy = ErpServer.SERVER_DUBBO_NAME)
|
|
|
+ private ISysGameUserGroupRpc sysGameUserGroupRpc;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean gameAuthAdd(GameAuthAddParam param) {
|
|
@@ -148,19 +154,23 @@ public class GameAuthServiceImpl extends ServiceImpl<GameAuthMapper, GameAuth> i
|
|
|
|
|
|
@Override
|
|
|
public Tuple2<String, List<Long>> getUserGameList(String userId) {
|
|
|
+ //查询用户权限角色
|
|
|
+ GameAuthRole gameAuthRole = gameAuthRoleService.getOne(new LambdaQueryWrapper<GameAuthRole>()
|
|
|
+ .eq(GameAuthRole::getUserId, SecurityUtil.getUserId()));
|
|
|
+ if (!SecurityUtil.isAdmin() && gameAuthRole == null) {
|
|
|
+ throw new BaseException("参数错误, 无法查询到用户的权限角色信息");
|
|
|
+ }
|
|
|
//超管权限
|
|
|
- if (SecurityUtil.isAdmin()) {
|
|
|
+ if (SecurityUtil.isAdmin() && Objects.equals(gameAuthRole.getAuthType(), GameAuthEnum.MANAGE.getValue())) {
|
|
|
List<Long> gameIdList = super.list(new LambdaQueryWrapper<GameAuth>()
|
|
|
.eq(Strings.isNotBlank(userId), GameAuth::getUserId, Strings.isBlank(userId) ? null : Long.valueOf(userId))
|
|
|
).stream().map(GameAuth::getGameId).collect(Collectors.toList());
|
|
|
- return Tuples.of(GameAuthEnum.ADMIN.getValue(), gameIdList);
|
|
|
- }
|
|
|
- //非超管权限
|
|
|
- GameAuthRole gameAuthRole = gameAuthRoleService.getOne(new LambdaQueryWrapper<GameAuthRole>()
|
|
|
- .eq(GameAuthRole::getUserId, SecurityUtil.getUserId()));
|
|
|
- if (gameAuthRole == null) {
|
|
|
- throw new BaseException("参数错误, 无法查询到用户的权限角色信息");
|
|
|
+ if (SecurityUtil.isAdmin()) {
|
|
|
+ return Tuples.of(GameAuthEnum.ADMIN.getValue(), gameIdList);
|
|
|
+ }
|
|
|
+ return Tuples.of(gameAuthRole.getAuthType(), gameIdList);
|
|
|
}
|
|
|
+ //非超管权限查询
|
|
|
List<Long> gameIdList = super.list(new LambdaQueryWrapper<GameAuth>()
|
|
|
.eq(Strings.isBlank(userId), GameAuth::getUserId, SecurityUtil.getUserId())
|
|
|
.eq(Strings.isNotBlank(userId), GameAuth::getUserId, Strings.isBlank(userId) ? null : Long.valueOf(userId))
|
|
@@ -168,4 +178,49 @@ public class GameAuthServiceImpl extends ServiceImpl<GameAuthMapper, GameAuth> i
|
|
|
//返回角色权限以及游戏
|
|
|
return Tuples.of(gameAuthRole.getAuthType(), gameIdList);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<Long, String> agentUserChoiceList() {
|
|
|
+ //判断是否是组长
|
|
|
+ SysGameUserGroupRpcVO sysGameUserGroupRpcVO = sysGameUserGroupRpc.getByGroupUser(SecurityUtil.getCompanyId(),
|
|
|
+ SecurityUtil.getUserId()).getData();
|
|
|
+ //判断运营
|
|
|
+ GameAuthRole gameAuthRole = gameAuthRoleService.getOne(new LambdaQueryWrapper<GameAuthRole>()
|
|
|
+ .eq(GameAuthRole::getUserId, SecurityUtil.getUserId()));
|
|
|
+ //所有投手
|
|
|
+ List<Long> pitcherIdList = gameAuthRoleService.list(new LambdaQueryWrapper<GameAuthRole>()
|
|
|
+ .eq(GameAuthRole::getAuthType, GameAuthEnum.PITCHER.getValue())
|
|
|
+ ).stream().map(GameAuthRole::getUserId).collect(Collectors.toList());
|
|
|
+ //游戏权限
|
|
|
+ Tuple2<String, List<Long>> userGameTuple2 = this.getUserGameList(null);
|
|
|
+ if (CollectionUtils.isEmpty(userGameTuple2.getT2())) {
|
|
|
+ throw new BaseException("未查询到用户游戏列表");
|
|
|
+ }
|
|
|
+ List<GameAuth> gameAuthList;
|
|
|
+ //超管或者管理员
|
|
|
+ if (SecurityUtil.isAdmin() || Objects.equals(gameAuthRole.getAuthType(), GameAuthEnum.MANAGE.getValue())) {
|
|
|
+ gameAuthList = super.list(new LambdaQueryWrapper<GameAuth>()
|
|
|
+ .in(GameAuth::getUserId, pitcherIdList));
|
|
|
+ } else if (Objects.equals(gameAuthRole.getAuthType(), GameAuthEnum.OPERATE.getValue())) {
|
|
|
+ //运营权限
|
|
|
+ gameAuthList = super.list(new LambdaQueryWrapper<GameAuth>()
|
|
|
+ .in(GameAuth::getGameId, userGameTuple2.getT2())
|
|
|
+ .in(GameAuth::getUserId, pitcherIdList));
|
|
|
+ } else if (sysGameUserGroupRpcVO != null) {
|
|
|
+ //组长权限, 获取组员id, 查询组内所有人
|
|
|
+ Collection<Long> memberUserIdList = sysGameUserGroupRpc.memberUserIds(SecurityUtil.getCompanyId(),
|
|
|
+ SecurityUtil.getUserId()).getData();
|
|
|
+ List<Long> userIdList = memberUserIdList.stream().filter(pitcherIdList::contains).collect(Collectors.toList());
|
|
|
+ gameAuthList = super.list(new LambdaQueryWrapper<GameAuth>()
|
|
|
+ .in(GameAuth::getGameId, userGameTuple2.getT2())
|
|
|
+ .in(GameAuth::getUserId, userIdList));
|
|
|
+ } else {
|
|
|
+ gameAuthList = super.list(new LambdaQueryWrapper<GameAuth>()
|
|
|
+ .in(GameAuth::getGameId, userGameTuple2.getT2())
|
|
|
+ .eq(GameAuth::getUserId, SecurityUtil.getUserId()));
|
|
|
+ }
|
|
|
+ return sysUserRpc.getUserNameByIds(gameAuthList.stream().map(GameAuth::getUserId)
|
|
|
+ .distinct().collect(Collectors.toList())
|
|
|
+ ).getData();
|
|
|
+ }
|
|
|
}
|