Browse Source

fix : 游戏区服逻辑修改1

bilingfeng 1 year ago
parent
commit
141025b3b4

+ 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服务启动成功 <解决bug调试修改3> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 <用户导安卓兼容> ( ´・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 2 - 2
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/controller/UserController.java

@@ -150,7 +150,7 @@ public class UserController {
     @PatchMapping(value = "/applet/to/h5")
     @PreAuthorize(permissionKey = "manage:user:appletToH5")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
-    public ResultVO<Boolean> appletToH5(@RequestParam Long userId, @RequestParam String mobile) {
-        return ResultVO.ok(userService.appletToH5(userId, mobile));
+    public ResultVO<Boolean> appletToH5(@RequestParam Long userId, @RequestParam String mobile, @RequestParam Integer type) {
+        return ResultVO.ok(userService.appletToH5(userId, mobile, type));
     }
 }

+ 10 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/dto/GameDTO.java

@@ -96,4 +96,14 @@ public class GameDTO {
      * 超父游戏id
      */
     private Long superGameId;
+
+    /**
+     * 安卓游戏id
+     */
+    private Long androidGameId;
+
+    /**
+     * ios游戏id
+     */
+    private Long iosGameId;
 }

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

@@ -5,7 +5,7 @@ import lombok.Data;
 
 import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
-import java.util.List;
+import java.util.Set;
 
 /**
  * @author : lingfeng
@@ -26,5 +26,5 @@ public class IpBanAddParam {
      * ip列表
      */
     @NotEmpty(message = "ip列表不可为空")
-    private List<String> ipList;
+    private Set<String> ipList;
 }

+ 2 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IUserService.java

@@ -26,9 +26,10 @@ public interface IUserService extends IService<User> {
      *
      * @param userId 用户id
      * @param mobile 移动
+     * @param type   类型
      * @return {@link Boolean}
      */
-    Boolean appletToH5(Long userId, String mobile);
+    Boolean appletToH5(Long userId, String mobile, Integer type);
 
     /**
      * 获取用户微信

+ 2 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/IpBanServiceImpl.java

@@ -69,7 +69,8 @@ public class IpBanServiceImpl extends ServiceImpl<IpBanMapper, IpBan> implements
         List<IpBan> list = new ArrayList<>();
         param.getIpList().forEach(ip -> {
             //先查询是否已经存在
-            IpBan ipBan = super.getOne(new LambdaQueryWrapper<IpBan>().eq(IpBan::getIp, ip));
+            IpBan ipBan = super.getOne(new LambdaQueryWrapper<IpBan>()
+                    .eq(IpBan::getGameId, param.getGameId()).eq(IpBan::getIp, ip));
             if (ipBan == null) {
                 ipBan = IpBan.builder()
                         .ip(ip)

+ 18 - 6
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserServiceImpl.java

@@ -85,20 +85,32 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Boolean appletToH5(Long userId, String mobile) {
+    public Boolean appletToH5(Long userId, String mobile, Integer type) {
         //用户信息
         User user = super.getById(userId);
         if (user == null) {
             throw new BaseException("参数错误, 用户信息不存在");
         }
+        GameDTO gameDTO;
         //查询H5游戏
-        GameDTO h5GameDTO = gameService.getById(gameService.getById(user.getGameId()).getH5GameId());
-        if (h5GameDTO == null) {
-            throw new BaseException("参数错误, 关联H5游戏信息不存在");
+        if (type == 1) {
+            gameDTO = gameService.getById(gameService.getById(user.getGameId()).getH5GameId());
+        } else if (type == 2) {
+            //查询安卓游戏
+            gameDTO = gameService.getById(gameService.getById(user.getGameId()).getAndroidGameId());
+        } else if (type == 3) {
+            //查询ios游戏
+            gameDTO = gameService.getById(gameService.getById(user.getGameId()).getIosGameId());
+        } else {
+            throw new BaseException("参数错误, 导量类型不存在");
+        }
+        //判断关联游戏是否存在
+        if (gameDTO == null) {
+            throw new BaseException("参数错误, 关联导量游戏信息不存在");
         }
         //判断手机号是否被该游戏其他用户绑定
         int count = super.count(new LambdaQueryWrapper<User>()
-                .eq(User::getGameId, h5GameDTO.getId())
+                .eq(User::getGameId, gameDTO.getId())
                 .eq(User::getMobile, mobile));
         if (count > 0) {
             throw new BaseException("参数错误, 该手机号已被该游戏其他玩家信息绑定");
@@ -106,7 +118,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         //复制用户信息
         User h5User = BeanUtil.copy(user, User.class);
         h5User.setId(null);
-        h5User.setGameId(h5GameDTO.getId());
+        h5User.setGameId(gameDTO.getId());
         h5User.setMobile(mobile);
         h5User.setRelationUserId(user.getId());
         h5User.setRelationCreateTime(LocalDateTime.now());