浏览代码

fix : 游戏授权模块修改

bilingfeng 1 年之前
父节点
当前提交
c388efebb8

+ 25 - 1
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/vo/GameAuthUserVO.java

@@ -33,12 +33,36 @@ public class GameAuthUserVO implements Serializable {
     private GameAuthEnum gameAuthEnum;
 
     /**
-     * 游戏id列表
+     * 角色授权
+     */
+    private String gameAuth;
+
+    /**
+     * 授权游戏id列表
      */
     private List<Long> gameIdList;
 
+    /**
+     * 授权游戏列表
+     */
+    private List<GameAuthBean> gameAuthBeanList;
+
     /**
      * 投手列表
      */
     private List<Long> pitcherList;
+
+    @Data
+    public static class GameAuthBean {
+
+        /**
+         * 游戏id
+         */
+        private Long gameId;
+
+        /**
+         * 是否包含自然量
+         */
+        private Boolean defaultAgent;
+    }
 }

+ 1 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/ManageApplication.java

@@ -21,7 +21,7 @@ public class ManageApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(ManageApplication.class, args);
-        System.out.println("赞象Manage服务启动成功 <区服新增excel方式上线> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 <游戏授权模块修改> ( ´・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 18 - 2
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/params/GameAuthAddParam.java

@@ -30,9 +30,25 @@ public class GameAuthAddParam {
     private List<Long> userIdList;
 
     /**
-     * 游戏id列表
+     * 游戏授权列表
      */
     @NotNull(message = "游戏id列表不可为空")
     @ApiModelProperty(notes = "游戏id列表, 所有游戏下拉选择")
-    private List<Long> gameIdList;
+    private List<GameAuthBean> gameAuthList;
+
+    @Data
+    public static class GameAuthBean {
+
+        /**
+         * 游戏id
+         */
+        @ApiModelProperty(notes = "游戏id")
+        private Long gameId;
+
+        /**
+         * 是否包含自然量
+         */
+        @ApiModelProperty(notes = "是否包含自然量")
+        private Boolean defaultAgent;
+    }
 }

+ 6 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/GameAuthVO.java

@@ -26,6 +26,12 @@ public class GameAuthVO {
     @ApiModelProperty(notes = "游戏id")
     private Long gameId;
 
+    /**
+     * 是否包含自然量
+     */
+    @ApiModelProperty(notes = "是否包含自然量")
+    private Boolean defaultAgent;
+
     /**
      * 游戏名称
      */

+ 7 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/rpc/impl/GameAuthRpcImpl.java

@@ -12,6 +12,7 @@ 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 com.zanxiang.module.util.bean.BeanUtil;
 import com.zanxiang.module.util.exception.BaseException;
 import com.zanxiang.module.util.pojo.ResultVO;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -84,12 +85,18 @@ public class GameAuthRpcImpl implements GameAuthRpc {
                 && !pitcherList.contains(SecurityUtil.getUserId())) {
             pitcherList.add(SecurityUtil.getUserId());
         }
+        //游戏授权列表
+        List<GameAuthUserVO.GameAuthBean> gameAuthBeanList = gameAuthService.list(new LambdaQueryWrapper<GameAuth>()
+                .eq(GameAuth::getUserId, SecurityUtil.getUserId()).in(GameAuth::getGameId, tuple2.getT2())
+        ).stream().map(gameAuth -> BeanUtil.copy(gameAuth, GameAuthUserVO.GameAuthBean.class)).collect(Collectors.toList());
         //构造返回
         return ResultVO.ok(GameAuthUserVO.builder()
                 .userId(SecurityUtil.getUserId())
                 .gameIdList(tuple2.getT2())
                 .gameAuthEnum(gameAuthEnum)
+                .gameAuth(gameAuthEnum.getValue())
                 .pitcherList(pitcherList)
+                .gameAuthBeanList(gameAuthBeanList)
                 .build());
     }
 }

+ 7 - 6
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameAuthServiceImpl.java

@@ -64,7 +64,7 @@ public class GameAuthServiceImpl extends ServiceImpl<GameAuthMapper, GameAuth> i
     @Transactional(rollbackFor = Exception.class)
     public boolean gameAuthAdd(GameAuthAddParam param) {
         List<Long> userIdList = param.getUserIdList();
-        List<Long> gameIdList = param.getGameIdList();
+        List<GameAuthAddParam.GameAuthBean> gameAuthList = param.getGameAuthList();
         List<GameAuth> addList = new ArrayList<>();
         userIdList.forEach(userId -> {
             //判断角色是否正确
@@ -75,15 +75,15 @@ public class GameAuthServiceImpl extends ServiceImpl<GameAuthMapper, GameAuth> i
                 throw new BaseException("参数错误, 提交得用户存在权限不匹配");
             }
             //循环添加
-            gameIdList.forEach(gameId -> {
+            gameAuthList.forEach(gameAuthBean -> {
                 //判断提交的参数数据是否已经存在
                 if (super.count(new LambdaQueryWrapper<GameAuth>()
-                        .eq(GameAuth::getGameId, gameId)
+                        .eq(GameAuth::getGameId, gameAuthBean.getGameId())
                         .eq(GameAuth::getUserId, userId)
                 ) > 0) {
                     throw new BaseException("参数错误, 提交的用户存在重复权限");
                 }
-                addList.add(this.transform(gameId, userId));
+                addList.add(this.transform(gameAuthBean, userId));
             });
         });
         if (addList.isEmpty()) {
@@ -92,15 +92,16 @@ public class GameAuthServiceImpl extends ServiceImpl<GameAuthMapper, GameAuth> i
         return super.saveBatch(addList);
     }
 
-    private GameAuth transform(Long gameId, Long userId) {
+    private GameAuth transform(GameAuthAddParam.GameAuthBean gameAuthBean, Long userId) {
         return GameAuth.builder()
-                .gameId(gameId)
+                .gameId(gameAuthBean.getGameId())
                 .userId(userId)
                 .isDelete(DeleteEnum.NO.getCode())
                 .createBy(SecurityUtil.getUserId())
                 .createTime(LocalDateTime.now())
                 .updateBy(SecurityUtil.getUserId())
                 .updateTime(LocalDateTime.now())
+                .defaultAgent(gameAuthBean.getDefaultAgent())
                 .build();
     }
 

+ 5 - 0
game-module/game-module-mybatis/src/main/java/com/zanxiang/game/module/mybatis/entity/GameAuth.java

@@ -65,4 +65,9 @@ public class GameAuth implements Serializable {
      * 更新时间
      */
     private LocalDateTime updateTime;
+
+    /**
+     * 是否包含自然量
+     */
+    private Boolean defaultAgent;
 }