소스 검색

fix : 游戏区服列表

bilingfeng 1 년 전
부모
커밋
a6563b08c3
12개의 변경된 파일514개의 추가작업 그리고 22개의 파일을 삭제
  1. 57 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/controller/GameServerController.java
  2. 57 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/params/GameServerAddUpdateParam.java
  3. 48 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/params/GameServerListParam.java
  4. 12 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/params/UserNameAuthListParam.java
  5. 75 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/GameServerListVO.java
  6. 12 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/UserCardVO.java
  7. 41 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IGameServerService.java
  8. 97 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameServerServiceImpl.java
  9. 19 22
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserRoleServiceImpl.java
  10. 13 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserServiceImpl.java
  11. 71 0
      game-module/game-module-mybatis/src/main/java/com/zanxiang/game/module/mybatis/entity/GameServer.java
  12. 12 0
      game-module/game-module-mybatis/src/main/java/com/zanxiang/game/module/mybatis/mapper/GameServerMapper.java

+ 57 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/controller/GameServerController.java

@@ -0,0 +1,57 @@
+package com.zanxiang.game.module.manage.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.zanxiang.erp.security.annotation.PreAuthorize;
+import com.zanxiang.game.module.manage.pojo.params.GameServerAddUpdateParam;
+import com.zanxiang.game.module.manage.pojo.params.GameServerListParam;
+import com.zanxiang.game.module.manage.pojo.vo.GameServerListVO;
+import com.zanxiang.game.module.manage.service.IGameServerService;
+import com.zanxiang.module.util.pojo.ResultVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author : lingfeng
+ * @time : 2023-08-07
+ * @description : 游戏区服接口
+ */
+@Api(tags = {"游戏区服接口"})
+@RestController
+@RequestMapping("/gameServer")
+@Slf4j
+public class GameServerController {
+
+    @Autowired
+    private IGameServerService gameServerService;
+
+    @ApiOperation(value = "新增或修改游戏区服")
+    @PostMapping(value = "/add/or/update")
+    @PreAuthorize(permissionKey = "manage:gameServer:addOrUpdate")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
+    public ResultVO<Boolean> addOrUpdate(@Validated @RequestBody GameServerAddUpdateParam param) {
+        return ResultVO.ok(gameServerService.addOrUpdate(param));
+    }
+
+    @ApiOperation(value = "游戏区服列表查询")
+    @PostMapping(value = "/list")
+    @PreAuthorize(permissionKey = "manage:gameServer:list")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameServerListVO.class)})
+    public ResultVO<IPage<GameServerListVO>> listOfPage(@Validated @RequestBody GameServerListParam param) {
+        return ResultVO.ok(gameServerService.listOfPage(param));
+    }
+
+    @ApiOperation(value = "游戏区服删除")
+    @DeleteMapping(value = "/delete")
+    @PreAuthorize(permissionKey = "manage:gameServer:delete")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
+    public ResultVO<Boolean> deleteById(@RequestParam Long id) {
+        return ResultVO.ok(gameServerService.deleteById(id));
+    }
+
+}

+ 57 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/params/GameServerAddUpdateParam.java

@@ -0,0 +1,57 @@
+package com.zanxiang.game.module.manage.pojo.params;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.time.LocalDateTime;
+
+/**
+ * @author : lingfeng
+ * @time : 2023-08-07
+ * @description : 游戏区服添加更新参数
+ */
+@Data
+public class GameServerAddUpdateParam {
+
+    /**
+     * 主键id
+     */
+    @ApiModelProperty(notes = "主键id, 传则是更新, 不传则是添加, 非必传")
+    private Long id;
+
+    /**
+     * 游戏id
+     */
+    @NotNull(message = "游戏id不可为空")
+    @ApiModelProperty(notes = "游戏id, 必传")
+    private Long gameId;
+
+    /**
+     * 区服id
+     */
+    @NotBlank(message = "区服id不可为空")
+    @ApiModelProperty(notes = "区服id, 必传")
+    private String serverId;
+
+    /**
+     * 区服名称
+     */
+    @NotBlank(message = "区服名称不可为空")
+    @ApiModelProperty(notes = "区服名称, 必传")
+    private String serverName;
+
+    /**
+     * 区服冠名
+     */
+    @ApiModelProperty(notes = "区服冠名, 非必传")
+    private String nickName;
+
+    /**
+     * 开服时间
+     */
+    @NotBlank(message = "开服时间不可为空")
+    @ApiModelProperty(notes = "开服时间, 必传")
+    private LocalDateTime startTime;
+}

+ 48 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/params/GameServerListParam.java

@@ -0,0 +1,48 @@
+package com.zanxiang.game.module.manage.pojo.params;
+
+import com.zanxiang.game.module.mybatis.entity.GameServer;
+import com.zanxiang.module.web.pojo.BaseListDTO;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.time.LocalDate;
+
+/**
+ * @author : lingfeng
+ * @time : 2023-08-07
+ * @description : 游戏区服查询提交
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class GameServerListParam extends BaseListDTO<GameServer> {
+
+    /**
+     * 游戏id
+     */
+    private Long gameId;
+
+    /**
+     * 区服id
+     */
+    private String serverId;
+
+    /**
+     * 区服名称
+     */
+    private String serverName;
+
+    /**
+     * 区服冠名
+     */
+    private String nickName;
+
+    /**
+     * 开服时间区间-开始
+     */
+    private LocalDate startTime;
+
+    /**
+     * 开服时间区间-结束
+     */
+    private LocalDate endTime;
+}

+ 12 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/params/UserNameAuthListParam.java

@@ -58,4 +58,16 @@ public class UserNameAuthListParam extends BaseListDTO<UserCard> {
     @DateTimeFormat(pattern = "yyyy-MM-dd")
     @ApiModelProperty(value = "结束时间")
     private LocalDate endDate;
+
+    /**
+     * 游戏id
+     */
+    @ApiModelProperty(notes = "最近游戏角色名称")
+    private Long gameId;
+
+    /**
+     * 最近游戏角色名称
+     */
+    @ApiModelProperty(notes = "最近游戏角色名称")
+    private String lastGameRoleName;
 }

+ 75 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/GameServerListVO.java

@@ -0,0 +1,75 @@
+package com.zanxiang.game.module.manage.pojo.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author : lingfeng
+ * @time : 2023-08-07
+ * @description : 游戏区服
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class GameServerListVO {
+
+    /**
+     * 主键id
+     */
+    @ApiModelProperty(notes = "主键id")
+    private Long id;
+
+    /**
+     * 游戏id
+     */
+    @ApiModelProperty(notes = "游戏id")
+    private Long gameId;
+
+    /**
+     * 游戏名称
+     */
+    @ApiModelProperty(notes = "游戏名称")
+    private String gameName;
+
+    /**
+     * 区服id
+     */
+    @ApiModelProperty(notes = "区服id")
+    private String serverId;
+
+    /**
+     * 区服名称
+     */
+    @ApiModelProperty(notes = "区服名称")
+    private String serverName;
+
+    /**
+     * 区服冠名
+     */
+    @ApiModelProperty(notes = "区服冠名")
+    private String nickName;
+
+    /**
+     * 开服时间
+     */
+    @ApiModelProperty(notes = "开服时间")
+    private LocalDateTime startTime;
+
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(notes = "创建时间")
+    private LocalDateTime createTime;
+
+    /**
+     * 更新时间
+     */
+    @ApiModelProperty(notes = "更新时间")
+    private LocalDateTime updateTime;
+}

+ 12 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/UserCardVO.java

@@ -85,6 +85,18 @@ public class UserCardVO {
     @ApiModelProperty(notes = "更新时间")
     private LocalDateTime updateTime;
 
+    /**
+     * 游戏id
+     */
+    @ApiModelProperty(notes = "游戏id")
+    private Long gameId;
+
+    /**
+     * 游戏名称
+     */
+    @ApiModelProperty(notes = "游戏名称")
+    private String gameName;
+
     /**
      * 最近游戏角色名称
      */

+ 41 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IGameServerService.java

@@ -0,0 +1,41 @@
+package com.zanxiang.game.module.manage.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.zanxiang.game.module.manage.pojo.params.GameServerAddUpdateParam;
+import com.zanxiang.game.module.manage.pojo.params.GameServerListParam;
+import com.zanxiang.game.module.manage.pojo.vo.GameServerListVO;
+import com.zanxiang.game.module.mybatis.entity.GameServer;
+
+/**
+ * @author : lingfeng
+ * @time : 2023-08-07
+ * @description : 游戏区服
+ */
+public interface IGameServerService extends IService<GameServer> {
+
+
+    /**
+     * 添加或更新
+     *
+     * @param param 参数
+     * @return boolean
+     */
+    boolean addOrUpdate(GameServerAddUpdateParam param);
+
+    /**
+     * 列表页面
+     *
+     * @param param 参数
+     * @return {@link IPage}<{@link GameServerListVO}>
+     */
+    IPage<GameServerListVO> listOfPage(GameServerListParam param);
+
+    /**
+     * 删除通过id
+     *
+     * @param id id
+     * @return boolean
+     */
+    boolean deleteById(Long id);
+}

+ 97 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameServerServiceImpl.java

@@ -0,0 +1,97 @@
+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.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zanxiang.game.module.base.pojo.enums.DeleteEnum;
+import com.zanxiang.game.module.manage.pojo.dto.GameDTO;
+import com.zanxiang.game.module.manage.pojo.params.GameServerAddUpdateParam;
+import com.zanxiang.game.module.manage.pojo.params.GameServerListParam;
+import com.zanxiang.game.module.manage.pojo.vo.GameServerListVO;
+import com.zanxiang.game.module.manage.service.IGameServerService;
+import com.zanxiang.game.module.manage.service.IGameService;
+import com.zanxiang.game.module.mybatis.entity.GameServer;
+import com.zanxiang.game.module.mybatis.mapper.GameServerMapper;
+import com.zanxiang.module.util.bean.BeanUtil;
+import com.zanxiang.module.util.exception.BaseException;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.logging.log4j.util.Strings;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.util.Objects;
+
+/**
+ * @author : lingfeng
+ * @time : 2023-08-07
+ * @description : 游戏区服
+ */
+@Slf4j
+@Service
+public class GameServerServiceImpl extends ServiceImpl<GameServerMapper, GameServer> implements IGameServerService {
+
+    @Autowired
+    private IGameService gameService;
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean addOrUpdate(GameServerAddUpdateParam param) {
+        //判断单游戏内区服id不可重复
+        if (super.count(new LambdaQueryWrapper<GameServer>()
+                .eq(GameServer::getGameId, param.getGameId())
+                .eq(GameServer::getServerId, param.getServerId())
+                .ne(param.getId() != null, GameServer::getId, param.getId())
+        ) > 0) {
+            throw new BaseException("该游戏区服id已存在, 禁止添加或者修改");
+        }
+        //添加或者更新
+        return super.saveOrUpdate(this.transform(param));
+    }
+
+    private GameServer transform(GameServerAddUpdateParam param) {
+        return GameServer.builder()
+                .id(param.getId())
+                .gameId(param.getGameId())
+                .serverId(param.getServerId())
+                .serverName(param.getServerName())
+                .nickName(param.getNickName())
+                .startTime(param.getStartTime())
+                .isDelete(DeleteEnum.NO.getCode())
+                .createTime(param.getId() == null ? null : LocalDateTime.now())
+                .updateTime(LocalDateTime.now())
+                .build();
+    }
+
+    @Override
+    public IPage<GameServerListVO> listOfPage(GameServerListParam param) {
+        return page(param.toPage(), new QueryWrapper<GameServer>().lambda()
+                .eq(param.getGameId() != null, GameServer::getGameId, param.getGameId())
+                .eq(param.getServerId() != null, GameServer::getServerId, param.getServerId())
+                .like(Strings.isNotBlank(param.getServerName()), GameServer::getServerName, param.getServerName())
+                .like(Strings.isNotBlank(param.getNickName()), GameServer::getNickName, param.getNickName())
+                .ge(param.getStartTime() != null, GameServer::getStartTime, param.getStartTime() == null ? null : LocalDateTime.of(param.getStartTime(), LocalTime.MIN))
+                .le(param.getEndTime() != null, GameServer::getStartTime, param.getEndTime() == null ? null : LocalDateTime.of(param.getEndTime(), LocalTime.MAX))
+                .orderByDesc(GameServer::getUpdateTime)
+        ).convert(this::toVo);
+    }
+
+    private GameServerListVO toVo(GameServer gameServer) {
+        if (Objects.isNull(gameServer)) {
+            return null;
+        }
+        GameServerListVO gameServerListVO = BeanUtil.copy(gameServer, GameServerListVO.class);
+        GameDTO gameDTO = gameService.getById(gameServer.getGameId());
+        gameServerListVO.setGameName(gameDTO == null ? null : gameDTO.getName());
+        return gameServerListVO;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean deleteById(Long id) {
+        return super.removeById(id);
+    }
+}

+ 19 - 22
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserRoleServiceImpl.java

@@ -12,7 +12,6 @@ import com.zanxiang.game.module.manage.pojo.dto.*;
 import com.zanxiang.game.module.manage.pojo.params.GameUserRoleListParam;
 import com.zanxiang.game.module.manage.pojo.vo.GameUserRoleListVO;
 import com.zanxiang.game.module.manage.pojo.vo.GameUserRoleVO;
-import com.zanxiang.game.module.manage.pojo.vo.GameUserVO;
 import com.zanxiang.game.module.manage.service.*;
 import com.zanxiang.game.module.mybatis.entity.Agent;
 import com.zanxiang.game.module.mybatis.entity.GameUserRole;
@@ -78,29 +77,27 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
         if (CollectionUtils.isEmpty(gameUserRoleList)) {
             return Collections.emptyList();
         }
-        List<GameUserRoleVO> list = new ArrayList<>();
-        gameUserRoleList.forEach(role -> {
+        //玩家信息
+        UserDTO userDTO = userService.getById(userId);
+        //游戏信息
+        GameDTO gameDTO = gameService.getById(userDTO.getGameId());
+        //渠道信息
+        String agentName;
+        if (Objects.equals(userDTO.getAgentId(), Agent.DEFAULT_AGENT)) {
+            agentName = Agent.DEFAULT_AGENT_NAME;
+        } else {
+            Agent agent = agentService.getById(userDTO.getAgentId());
+            agentName = agent.getAgentName();
+        }
+        return gameUserRoleList.stream().map(role -> {
             GameUserRoleVO gameUserRoleVO = BeanUtil.copy(role, GameUserRoleVO.class);
-            if (gameUserRoleVO == null) {
-                return;
-            }
             //设置游戏名称
-            GameDTO gameDTO = gameService.getById(role.getGameId());
-            if (gameDTO != null) {
-                gameUserRoleVO.setGameName(gameDTO.getName());
-                gameUserRoleVO.setGameCategoryName(GameCategoryEnum.getNameByCategory(gameDTO.getCategory()));
-            }
-            //玩家游戏信息
-            GameUserVO gameUserVO = gameUserService.getById(role.getGameUserId());
-            if (gameUserVO != null) {
-                Agent agent = agentService.getById(gameUserVO.getAgentId());
-                if (agent != null) {
-                    gameUserRoleVO.setAgentName(agent.getAgentName());
-                }
-            }
-            list.add(gameUserRoleVO);
-        });
-        return list;
+            gameUserRoleVO.setGameName(gameDTO.getName());
+            gameUserRoleVO.setGameCategoryName(GameCategoryEnum.getNameByCategory(gameDTO.getCategory()));
+            //设置渠道信息
+            gameUserRoleVO.setAgentName(agentName);
+            return gameUserRoleVO;
+        }).collect(Collectors.toList());
     }
 
     @Override

+ 13 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserServiceImpl.java

@@ -39,6 +39,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import reactor.util.function.Tuple2;
 
+import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
@@ -106,6 +107,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         h5User.setMobile(mobile);
         h5User.setRelationUserId(user.getId());
         h5User.setRelationCreateTime(LocalDateTime.now());
+        //充值统计数据归零设置
+        h5User.setSessionKey(null);
+        h5User.setRechargeCount(0);
+        h5User.setRechargeMoney(BigDecimal.ZERO);
+        h5User.setLastRechargeTime(null);
         super.save(h5User);
         //复制玩家信息
         GameUser gameUser = gameUserService.getOne(new LambdaQueryWrapper<GameUser>()
@@ -250,6 +256,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         userListVO.setLastGameRoleName(gameUserRole == null ? null : gameUserRole.getRoleName());
         //注册充值时间差
         userListVO.setRegPayTimeDiff(DateUtils.getRegPayTimeDiff(userListVO.getCreateTime(), userListVO.getLastRechargeTime()));
+        //设置关联游戏名称
+        if (userListVO.getRelationUserId() != null) {
+            User relationUser = super.getById(userListVO.getRelationUserId());
+            GameDTO relationGame = gameService.getById(relationUser.getGameId());
+            userListVO.setRelationGameId(relationGame.getId());
+            userListVO.setRelationGameName(relationGame.getName());
+        }
         //返回
         return userListVO;
     }

+ 71 - 0
game-module/game-module-mybatis/src/main/java/com/zanxiang/game/module/mybatis/entity/GameServer.java

@@ -0,0 +1,71 @@
+package com.zanxiang.game.module.mybatis.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.*;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * @author : lingfeng
+ * @time : 2023-08-07
+ * @description : 游戏区服
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@ToString
+@Builder
+@TableName("t_game_server")
+public class GameServer implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 游戏id
+     */
+    private Long gameId;
+
+    /**
+     * 区服id
+     */
+    private String serverId;
+
+    /**
+     * 区服名称
+     */
+    private String serverName;
+
+    /**
+     * 区服冠名
+     */
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
+    private String nickName;
+
+    /**
+     * 开服时间
+     */
+    private LocalDateTime startTime;
+
+    /**
+     * 1 删除  0 正常
+     */
+    @TableLogic
+    private Integer isDelete;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+}

+ 12 - 0
game-module/game-module-mybatis/src/main/java/com/zanxiang/game/module/mybatis/mapper/GameServerMapper.java

@@ -0,0 +1,12 @@
+package com.zanxiang.game.module.mybatis.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zanxiang.game.module.mybatis.entity.GameServer;
+
+/**
+ * @author : lingfeng
+ * @time : 2023-08-07
+ * @description : 游戏区服
+ */
+public interface GameServerMapper extends BaseMapper<GameServer> {
+}