Procházet zdrojové kódy

Merge remote-tracking branch 'origin/package' into package

zhangxianyu před 10 měsíci
rodič
revize
fb7a7b7572

+ 139 - 0
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/dto/GameDTO.java

@@ -0,0 +1,139 @@
+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
+ * @time : 2024-05-23
+ * @description : 游戏信息
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class GameDTO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 超父游戏列表
+     */
+    private List<GameSupperBean> gameSupperList;
+
+    /**
+     * 获取所有游戏列表
+     *
+     * @return : 返回游戏列表
+     */
+    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 : 返回超父对象
+     */
+    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获取游戏信息
+     *
+     * @return : 返回游戏对象
+     */
+    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);
+    }
+
+    @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;
+    }
+}

+ 176 - 0
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/dto/GameServerDTO.java

@@ -0,0 +1,176 @@
+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.time.LocalDateTime;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * @author : lingfeng
+ * @time : 2024-05-23
+ * @description : 游戏区服
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class GameServerDTO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 超父游戏区服列表
+     */
+    public List<SuperGameServerBean> superGameServerList;
+
+    /**
+     * 通过游戏id获取原始区服
+     *
+     * @param gameId : 游戏id
+     * @return : 返回区服信息
+     */
+    public List<GameServerBean> getAllGameServerByGameId(Long gameId) {
+        if (CollectionUtils.isEmpty(this.superGameServerList)) {
+            return null;
+        }
+        SuperGameServerBean superGameServer = this.superGameServerList.stream()
+                .filter(superGameServerBean -> superGameServerBean.getGameIdList().contains(gameId))
+                .findFirst().orElse(null);
+        if (superGameServer == null) {
+            return null;
+        }
+        return superGameServer.getSourceGameServerList();
+    }
+
+    /**
+     * 通过超父游戏id获取原始区服
+     *
+     * @param superGameId : 超父游戏id
+     * @return : 返回区服信息
+     */
+    public List<GameServerBean> getAllGameServerBySupperGameId(Long superGameId) {
+        if (CollectionUtils.isEmpty(this.superGameServerList)) {
+            return null;
+        }
+        SuperGameServerBean superGameServer = this.superGameServerList.stream()
+                .filter(superGameServerBean -> Objects.equals(superGameId, superGameServerBean.getSuperGameId()))
+                .findFirst().orElse(null);
+        if (superGameServer == null) {
+            return null;
+        }
+        return superGameServer.getSourceGameServerList();
+    }
+
+    /**
+     * 通过游戏id,区服id获取原始区服
+     *
+     * @param gameId   : 游戏id
+     * @param serverId : 区服id
+     * @return : 返回区服信息
+     */
+    public GameServerBean getGameServerByGameId(Long gameId, String serverId) {
+        if (CollectionUtils.isEmpty(this.superGameServerList)) {
+            return null;
+        }
+        SuperGameServerBean superGameServer = this.superGameServerList.stream()
+                .filter(superGameServerBean -> superGameServerBean.getGameIdList().contains(gameId))
+                .findFirst().orElse(null);
+        if (superGameServer == null) {
+            return null;
+        }
+        return superGameServer.getSourceGameServerList().stream()
+                .filter(gameServerBean -> Objects.equals(gameServerBean.getServerId(), serverId))
+                .findFirst().orElse(null);
+    }
+
+    /**
+     * 通过游戏id,区服id获取原始区服
+     *
+     * @param superGameId : 超父游戏id
+     * @param serverId    : 区服id
+     * @return : 返回区服信息
+     */
+    public GameServerBean getGameServerBySupperGameId(Long superGameId, String serverId) {
+        if (CollectionUtils.isEmpty(this.superGameServerList)) {
+            return null;
+        }
+        SuperGameServerBean superGameServer = this.superGameServerList.stream()
+                .filter(superGameServerBean -> Objects.equals(superGameId, superGameServerBean.getSuperGameId()))
+                .findFirst().orElse(null);
+        if (superGameServer == null) {
+            return null;
+        }
+        return superGameServer.getSourceGameServerList().stream()
+                .filter(gameServerBean -> Objects.equals(gameServerBean.getServerId(), serverId))
+                .findFirst().orElse(null);
+    }
+
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    public static class SuperGameServerBean implements Serializable {
+
+        private static final long serialVersionUID = 1L;
+
+        /**
+         * 超父游戏id
+         */
+        private Long superGameId;
+
+        /**
+         * 游戏id列表
+         */
+        private List<Long> gameIdList;
+
+        /**
+         * 原始区服列表
+         */
+        private List<GameServerBean> sourceGameServerList;
+    }
+
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    public static class GameServerBean implements Serializable {
+
+        private static final long serialVersionUID = 1L;
+
+        /**
+         * 主键id
+         */
+        private Long id;
+
+        /**
+         * 超父游戏id
+         */
+        private Long superGameId;
+
+        /**
+         * 区服id
+         */
+        private String serverId;
+
+        /**
+         * 区服名称
+         */
+        private String serverName;
+
+        /**
+         * 区服冠名
+         */
+        private String nickName;
+
+        /**
+         * 开服时间
+         */
+        private LocalDateTime startTime;
+    }
+}

+ 19 - 0
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/rpc/IGameRpc.java

@@ -0,0 +1,19 @@
+package com.zanxiang.game.module.base.rpc;
+
+import com.zanxiang.game.module.base.pojo.dto.GameDTO;
+import com.zanxiang.module.util.pojo.ResultVO;
+
+/**
+ * @author : lingfeng
+ * @time : 2024-05-23
+ * @description : 游戏相关接口
+ */
+public interface IGameRpc {
+
+    /**
+     * 获取游戏信息
+     *
+     * @return : 返回游戏列表
+     */
+    ResultVO<GameDTO> getAllGameList();
+}

+ 19 - 0
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/rpc/IGameServerRpc.java

@@ -0,0 +1,19 @@
+package com.zanxiang.game.module.base.rpc;
+
+import com.zanxiang.game.module.base.pojo.dto.GameServerDTO;
+import com.zanxiang.module.util.pojo.ResultVO;
+
+/**
+ * @author : lingfeng
+ * @time : 2024-05-23
+ * @description : 游戏区服
+ */
+public interface IGameServerRpc {
+
+    /**
+     * 获取游戏所有区服
+     *
+     * @return : 返回游戏区服对象
+     */
+    ResultVO<GameServerDTO> getAllServerList();
+}

+ 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服务启动成功 < (角色授权分组接口修改´3・・)ノ(._.`) \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")

+ 9 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/params/GameAuthRoleGroupListParam.java

@@ -5,6 +5,8 @@ import com.zanxiang.module.web.pojo.BaseListDTO;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
+
 /**
  * @author : lingfeng
  * @time : 2024-05-21
@@ -13,6 +15,13 @@ import lombok.Data;
 @Data
 public class GameAuthRoleGroupListParam extends BaseListDTO<GameAuthRoleGroup> {
 
+    /**
+     * 分组id
+     */
+    @NotNull(message = "分组id不可为空")
+    @ApiModelProperty(notes = "分组id, 必传")
+    private Long groupId;
+
     /**
      * 用户id
      */

+ 57 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/rpc/impl/GameRpcImpl.java

@@ -0,0 +1,57 @@
+package com.zanxiang.game.module.manage.rpc.impl;
+
+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;
+
+/**
+ * @author : lingfeng
+ * @time : 2024-05-23
+ * @description : 游戏相关接口
+ */
+@DubboService
+public class GameRpcImpl implements IGameRpc {
+
+    @Autowired
+    private IGameSupperService gameSupperService;
+
+    @Autowired
+    private IGameService gameService;
+
+    @Override
+    public ResultVO<GameDTO> getAllGameList() {
+        //超父游戏列表
+        List<GameSupper> gameSupperList = gameSupperService.list();
+        //游戏列表
+        List<Game> gameList = gameService.list();
+        //不存在数据
+        if (CollectionUtils.isEmpty(gameSupperList) || CollectionUtils.isEmpty(gameList)) {
+            return ResultVO.ok(GameDTO.builder().gameSupperList(Collections.emptyList()).build());
+        }
+        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());
+    }
+}

+ 71 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/rpc/impl/GameServerRpcImpl.java

@@ -0,0 +1,71 @@
+package com.zanxiang.game.module.manage.rpc.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zanxiang.game.module.base.pojo.dto.GameServerDTO;
+import com.zanxiang.game.module.base.rpc.IGameServerRpc;
+import com.zanxiang.game.module.manage.service.IGameServerService;
+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.GameServer;
+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.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author : lingfeng
+ * @time : 2024-05-23
+ * @description : 游戏区服接口
+ */
+@DubboService
+public class GameServerRpcImpl implements IGameServerRpc {
+
+    @Autowired
+    private IGameSupperService gameSupperService;
+
+    @Autowired
+    private IGameService gameService;
+
+    @Autowired
+    private IGameServerService gameServerService;
+
+    @Override
+    public ResultVO<GameServerDTO> getAllServerList() {
+        //超父游戏列表
+        List<Long> supperGameIdList = gameSupperService.list(new LambdaQueryWrapper<GameSupper>()
+                .select(GameSupper::getId)
+        ).stream().map(GameSupper::getId).collect(Collectors.toList());
+        //区服列表
+        List<GameServerDTO.SuperGameServerBean> superGameServerList = new ArrayList<>();
+        supperGameIdList.forEach(supperGameId -> {
+            //查询超父对应的子游戏
+            List<Long> gameIdList = gameService.list(new LambdaQueryWrapper<Game>()
+                    .select(Game::getId)
+                    .eq(Game::getSuperGameId, supperGameId)
+            ).stream().map(Game::getId).collect(Collectors.toList());
+            //超父对应的区服
+            List<GameServerDTO.GameServerBean> gameServerBeanList = gameServerService.list(new LambdaQueryWrapper<GameServer>()
+                    .eq(GameServer::getGameId, supperGameId)
+                    .eq(GameServer::getIsSourceServer, Boolean.TRUE)
+            ).stream().map(gameServer -> {
+                GameServerDTO.GameServerBean gameServerBean = BeanUtil.copy(gameServer, GameServerDTO.GameServerBean.class);
+                gameServerBean.setSuperGameId(supperGameId);
+                return gameServerBean;
+            }).collect(Collectors.toList());
+            //添加到集合
+            superGameServerList.add(GameServerDTO.SuperGameServerBean.builder()
+                    .superGameId(supperGameId)
+                    .gameIdList(gameIdList)
+                    .sourceGameServerList(gameServerBeanList)
+                    .build());
+        });
+        //返回
+        return ResultVO.ok(GameServerDTO.builder().superGameServerList(superGameServerList).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删除
      *

+ 13 - 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;
@@ -43,6 +44,7 @@ public class GameAuthRoleGroupServiceImpl extends ServiceImpl<GameAuthRoleGroupM
     @Override
     public IPage<GameAuthRoleGroupVO> listOfPage(GameAuthRoleGroupListParam param) {
         IPage<GameAuthRoleGroupVO> gameAuthRoleGroupPage = page(param.toPage(), new QueryWrapper<GameAuthRoleGroup>().lambda()
+                .eq(GameAuthRoleGroup::getGroupId, param.getGroupId())
                 .eq(param.getUserId() != null, GameAuthRoleGroup::getUserId, param.getUserId())
                 .eq(param.getIsLeader() != null, GameAuthRoleGroup::getIsLeader, param.getIsLeader())
                 .orderByDesc(GameAuthRoleGroup::getCreateTime)
@@ -65,6 +67,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) {