|
@@ -0,0 +1,52 @@
|
|
|
+package com.zanxiang.game.module.manage.rpc.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.zanxiang.game.module.base.pojo.enums.GameAuthEnum;
|
|
|
+import com.zanxiang.game.module.base.pojo.vo.GameAuthUserVO;
|
|
|
+import com.zanxiang.game.module.base.rpc.GameAuthRpc;
|
|
|
+import com.zanxiang.game.module.manage.service.IGameAuthRoleService;
|
|
|
+import com.zanxiang.game.module.manage.service.IGameAuthService;
|
|
|
+import com.zanxiang.game.module.mybatis.entity.GameAuth;
|
|
|
+import com.zanxiang.game.module.mybatis.entity.GameAuthRole;
|
|
|
+import org.apache.dubbo.config.annotation.DubboService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+ * @author : lingfeng
|
|
|
+ * @time : 2023-08-17
|
|
|
+ * @description : 游戏授权
|
|
|
+ */
|
|
|
+@DubboService
|
|
|
+public class GameAuthRpcImpl implements GameAuthRpc {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IGameAuthRoleService gameAuthRoleService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IGameAuthService gameAuthService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<GameAuthUserVO> getGameAuthByUserIds(List<Long> userIds) {
|
|
|
+ List<GameAuthUserVO> list = new ArrayList<>();
|
|
|
+ userIds.forEach(userId -> {
|
|
|
+ GameAuthRole gameAuthRole = gameAuthRoleService.getOne(new LambdaQueryWrapper<GameAuthRole>()
|
|
|
+ .eq(GameAuthRole::getUserId, userId));
|
|
|
+ List<GameAuth> gameAuthList = gameAuthService.list(new LambdaUpdateWrapper<GameAuth>()
|
|
|
+ .eq(GameAuth::getUserId, userId));
|
|
|
+ gameAuthList.forEach(gameAuth -> list.add(this.transform(gameAuth, gameAuthRole.getAuthType())));
|
|
|
+ });
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ private GameAuthUserVO transform(GameAuth gameAuth, String authType) {
|
|
|
+ return GameAuthUserVO.builder()
|
|
|
+ .userId(gameAuth.getUserId())
|
|
|
+ .gameId(gameAuth.getGameId())
|
|
|
+ .gameAuthEnum(GameAuthEnum.getByValue(authType))
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+}
|