Prechádzať zdrojové kódy

feat : 角色授权分组新增参数01

bilingfeng 11 mesiacov pred
rodič
commit
81e4860262

+ 110 - 12
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/dto/GameDTO.java

@@ -1,8 +1,16 @@
 package com.zanxiang.game.module.base.pojo.dto;
 
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
 
 /**
  * @author : lingfeng
@@ -10,32 +18,122 @@ import java.io.Serializable;
  * @description : 游戏信息
  */
 @Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
 public class GameDTO implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
     /**
-     * 游戏ID
+     * 超父游戏列表
      */
-    private Long id;
+    private List<GameSupperBean> gameSupperList;
 
     /**
-     * 游戏名称
+     * 获取所有游戏列表
+     *
+     * @return : 返回游戏列表
      */
-    private String name;
+    public List<GameBean> getAllGameList() {
+        if (CollectionUtils.isEmpty(this.gameSupperList)) {
+            return Collections.emptyList();
+        }
+        List<GameBean> gameList = new ArrayList<>();
+        this.gameSupperList.forEach(gameSupperBean -> gameList.addAll(gameSupperBean.getGameList()));
+        return gameList;
+    }
 
     /**
-     * 游戏类型
+     * 根据超父获游戏获取超父信息
+     *
+     * @param gameSupperId : 超父游戏id
+     * @return : 返回超父对象
      */
-    private Long category;
+    public GameSupperBean getGameListByGameSupperId(Long gameSupperId) {
+        if (CollectionUtils.isEmpty(this.gameSupperList)) {
+            return null;
+        }
+        return this.gameSupperList.stream()
+                .filter(gameSupperBean -> Objects.equals(gameSupperBean.getId(), gameSupperId))
+                .findFirst().orElse(null);
+    }
 
     /**
-     * 父游戏id
+     * 根据游戏id获取游戏信息
+     *
+     * @return : 返回游戏对象
      */
-    private Long parentId;
+    public GameBean getGameSupperByGameId(Long gameId) {
+        if (CollectionUtils.isEmpty(this.gameSupperList)) {
+            return null;
+        }
+        return this.gameSupperList.stream().map(GameSupperBean::getGameList).findFirst()
+                .map(gameList -> gameList.stream().filter(gameBean -> Objects.equals(gameBean.getId(), gameId))
+                        .findFirst().orElse(null))
+                .orElse(null);
+    }
 
-    /**
-     * 超父游戏id
-     */
-    private Long superGameId;
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    public static class GameSupperBean implements Serializable {
+
+        private static final long serialVersionUID = 1L;
+
+        /**
+         * 游戏id
+         */
+        private Long id;
+
+        /**
+         * CP信息主键id
+         */
+        private Long cpId;
+
+        /**
+         * 游戏名称
+         */
+        private String name;
+
+        /**
+         * 子游戏列表
+         */
+        private List<GameBean> gameList;
+    }
+
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    public static class GameBean implements Serializable {
+
+        private static final long serialVersionUID = 1L;
+
+        /**
+         * 游戏id
+         */
+        private Long id;
+
+        /**
+         * 游戏名称
+         */
+        private String name;
+
+        /**
+         * 游戏类型
+         */
+        private Long category;
+
+        /**
+         * 父游戏id
+         */
+        private Long parentId;
+
+        /**
+         * 超父游戏id
+         */
+        private Long superGameId;
+    }
 }

+ 2 - 4
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/rpc/IGameRpc.java

@@ -3,8 +3,6 @@ package com.zanxiang.game.module.base.rpc;
 import com.zanxiang.game.module.base.pojo.dto.GameDTO;
 import com.zanxiang.module.util.pojo.ResultVO;
 
-import java.util.List;
-
 /**
  * @author : lingfeng
  * @time : 2024-05-23
@@ -13,9 +11,9 @@ import java.util.List;
 public interface IGameRpc {
 
     /**
-     * 获取所有游戏
+     * 获取游戏信息
      *
      * @return : 返回游戏列表
      */
-    ResultVO<List<GameDTO>> getAllGameList();
+    ResultVO<GameDTO> getAllGameList();
 }

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

@@ -23,7 +23,7 @@ public class ManageApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(ManageApplication.class, args);
-        System.out.println("赞象Manage服务启动成功 < (角色授权分组接口修改´・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 < (角色授权分组接口修改´1・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 8 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/controller/GameAuthGroupController.java

@@ -69,6 +69,14 @@ public class GameAuthGroupController {
         return ResultVO.ok(gameAuthRoleGroupService.listOfPage(param));
     }
 
+    @ApiOperation(value = "授权角色是否组长更新")
+    @PutMapping(value = "/role/leader/update")
+    @PreAuthorize(permissionKey = "manage:gameAuthGroupRole:leaderUpdate")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameAuthRoleGroupVO.class)})
+    public ResultVO<Boolean> leaderUpdate(@RequestParam Long groupId, @RequestParam Long userId, @RequestParam Boolean isLeader) {
+        return ResultVO.ok(gameAuthRoleGroupService.leaderUpdate(groupId, userId, isLeader));
+    }
+
     @ApiOperation(value = "授权分组添加")
     @PostMapping(value = "/role/add")
     @PreAuthorize(permissionKey = "manage:gameAuthGroupRole:add")

+ 25 - 4
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/rpc/impl/GameRpcImpl.java

@@ -4,14 +4,18 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.zanxiang.game.module.base.pojo.dto.GameDTO;
 import com.zanxiang.game.module.base.rpc.IGameRpc;
 import com.zanxiang.game.module.manage.service.IGameService;
+import com.zanxiang.game.module.manage.service.IGameSupperService;
 import com.zanxiang.game.module.mybatis.entity.Game;
+import com.zanxiang.game.module.mybatis.entity.GameSupper;
 import com.zanxiang.module.util.bean.BeanUtil;
 import com.zanxiang.module.util.pojo.ResultVO;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 /**
@@ -22,15 +26,32 @@ import java.util.stream.Collectors;
 @DubboService
 public class GameRpcImpl implements IGameRpc {
 
+    @Autowired
+    private IGameSupperService gameSupperService;
+
     @Autowired
     private IGameService gameService;
 
     @Override
-    public ResultVO<List<GameDTO>> getAllGameList() {
+    public ResultVO<GameDTO> getAllGameList() {
+        //超父游戏列表
+        List<GameSupper> gameSupperList = gameSupperService.list();
+        //游戏列表
         List<Game> gameList = gameService.list();
-        if (CollectionUtils.isEmpty(gameList)) {
-            return ResultVO.ok(Collections.emptyList());
+        //不存在数据
+        if (CollectionUtils.isEmpty(gameSupperList) || CollectionUtils.isEmpty(gameList)) {
+            return ResultVO.ok(GameDTO.builder().gameSupperList(Collections.emptyList()).build());
         }
-        return ResultVO.ok(gameList.stream().map(game -> BeanUtil.copy(game, GameDTO.class)).collect(Collectors.toList()));
+        List<GameDTO.GameSupperBean> gameSupperBeanList = new ArrayList<>();
+        gameSupperList.forEach(gameSupper -> {
+            List<GameDTO.GameBean> gameBeanList = gameList.stream()
+                    .filter(game -> Objects.equals(game.getSuperGameId(), gameSupper.getId()))
+                    .map(game -> BeanUtil.copy(game, GameDTO.GameBean.class))
+                    .collect(Collectors.toList());
+            GameDTO.GameSupperBean gameSupperBean = BeanUtil.copy(gameSupper, GameDTO.GameSupperBean.class);
+            gameSupperBean.setGameList(gameBeanList);
+            gameSupperBeanList.add(gameSupperBean);
+        });
+        return ResultVO.ok(GameDTO.builder().gameSupperList(gameSupperBeanList).build());
     }
 }

+ 10 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IGameAuthRoleGroupService.java

@@ -14,6 +14,16 @@ import com.zanxiang.game.module.mybatis.entity.GameAuthRoleGroup;
  */
 public interface IGameAuthRoleGroupService extends IService<GameAuthRoleGroup> {
 
+    /**
+     * 是否组长更新
+     *
+     * @param groupId  : 分组id
+     * @param userId   : 用户id
+     * @param isLeader : 是否组长
+     * @return : 返回执行结果
+     */
+    boolean leaderUpdate(Long groupId, Long userId, boolean isLeader);
+
     /**
      * 根据id删除
      *

+ 23 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameAuthRoleGroupServiceImpl.java

@@ -2,6 +2,7 @@ package com.zanxiang.game.module.manage.service.impl;
 
 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;
@@ -15,6 +16,7 @@ import com.zanxiang.game.module.manage.pojo.vo.GameAuthRoleGroupVO;
 import com.zanxiang.game.module.manage.service.IGameAuthRoleGroupService;
 import com.zanxiang.game.module.mybatis.entity.GameAuthRoleGroup;
 import com.zanxiang.game.module.mybatis.mapper.GameAuthRoleGroupMapper;
+import com.zanxiang.module.util.JsonUtil;
 import com.zanxiang.module.util.bean.BeanUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -55,7 +57,17 @@ public class GameAuthRoleGroupServiceImpl extends ServiceImpl<GameAuthRoleGroupM
         List<Long> userIdList = records.stream().map(GameAuthRoleGroupVO::getUserId)
                 .distinct().collect(Collectors.toList());
         Map<Long, String> userNameMap = sysUserRpc.getUserNameByIds(userIdList).getData();
+
+        log.error("获取授权角色名字, userNameMap : {}", JsonUtil.toString(userNameMap));
+
         records.forEach(r -> r.setUserName(userNameMap.get(r.getUserId())));
+
+        log.error("设置名字之后, records : {}", JsonUtil.toString(records));
+
+
+        log.error("设置名字之后, gameAuthRoleGroupPage : {}", JsonUtil.toString(gameAuthRoleGroupPage));
+
+
         return gameAuthRoleGroupPage;
     }
 
@@ -66,6 +78,17 @@ public class GameAuthRoleGroupServiceImpl extends ServiceImpl<GameAuthRoleGroupM
         return BeanUtil.copy(gameAuthRoleGroup, GameAuthRoleGroupVO.class);
     }
 
+    @Override
+    public boolean leaderUpdate(Long groupId, Long userId, boolean isLeader) {
+        return super.update(new LambdaUpdateWrapper<GameAuthRoleGroup>()
+                .set(GameAuthRoleGroup::getIsLeader, isLeader)
+                .set(GameAuthRoleGroup::getUpdateBy, SecurityUtil.getUserId())
+                .set(GameAuthRoleGroup::getUpdateTime, LocalDateTime.now())
+                .eq(GameAuthRoleGroup::getGroupId, groupId)
+                .eq(GameAuthRoleGroup::getUserId, userId)
+        );
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean groupAddUser(GameAuthRoleGroupAddParam param) {