Browse Source

feat : 游戏模块接口代码提交

bilingfeng 2 years ago
parent
commit
8822601a3f
19 changed files with 932 additions and 36 deletions
  1. 43 0
      game-module/game-manage/src/main/java/com/zanxiang/manage/controller/GameAppletController.java
  2. 47 15
      game-module/game-manage/src/main/java/com/zanxiang/manage/controller/GameController.java
  3. 67 0
      game-module/game-manage/src/main/java/com/zanxiang/manage/domain/params/GameAccountUpdateParam.java
  4. 40 0
      game-module/game-manage/src/main/java/com/zanxiang/manage/domain/params/GameDockParam.java
  5. 6 0
      game-module/game-manage/src/main/java/com/zanxiang/manage/domain/params/GameUpdateParam.java
  6. 29 0
      game-module/game-manage/src/main/java/com/zanxiang/manage/domain/params/GuideGameUpdateParam.java
  7. 35 0
      game-module/game-manage/src/main/java/com/zanxiang/manage/domain/params/RelationGameUpdateParam.java
  8. 67 0
      game-module/game-manage/src/main/java/com/zanxiang/manage/domain/vo/GameAccountVO.java
  9. 6 0
      game-module/game-manage/src/main/java/com/zanxiang/manage/domain/vo/GameChoiceVO.java
  10. 55 0
      game-module/game-manage/src/main/java/com/zanxiang/manage/domain/vo/GameDockVO.java
  11. 7 1
      game-module/game-manage/src/main/java/com/zanxiang/manage/domain/vo/GameInfoVO.java
  12. 86 0
      game-module/game-manage/src/main/java/com/zanxiang/manage/domain/vo/GameRelationVO.java
  13. 30 0
      game-module/game-manage/src/main/java/com/zanxiang/manage/service/GameAppletService.java
  14. 50 5
      game-module/game-manage/src/main/java/com/zanxiang/manage/service/GameService.java
  15. 69 0
      game-module/game-manage/src/main/java/com/zanxiang/manage/service/Impl/GameAppletServiceImpl.java
  16. 200 15
      game-module/game-manage/src/main/java/com/zanxiang/manage/service/Impl/GameServiceImpl.java
  17. 79 0
      game-module/game-mybatis/src/main/java/com/zanxiang/mybatis/entity/GameApplet.java
  18. 12 0
      game-module/game-mybatis/src/main/java/com/zanxiang/mybatis/mapper/GameAppletMapper.java
  19. 4 0
      game-module/game-mybatis/src/main/resources/mapper/GameAppletMapper.xml

+ 43 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/controller/GameAppletController.java

@@ -0,0 +1,43 @@
+package com.zanxiang.manage.controller;
+
+import com.zanxiang.common.domain.ResultVo;
+import com.zanxiang.manage.domain.params.GameAccountUpdateParam;
+import com.zanxiang.manage.domain.vo.GameAccountVO;
+import com.zanxiang.manage.service.GameAppletService;
+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 : 2022-07-08
+ * @description : 微信小游戏(小程序)
+ */
+@Api(tags = {"微信小游戏(小程序)"})
+@RestController
+@RequestMapping("/game/applet")
+@Slf4j
+public class GameAppletController {
+
+    @Autowired
+    private GameAppletService gameAppletService;
+
+    @ApiOperation(value = "获取账号信息配置")
+    @GetMapping(value = "/info")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameAccountVO.class)})
+    public ResultVo<GameAccountVO> getGameAccount(@RequestParam Long id) {
+        return new ResultVo<>(gameAppletService.getGameAccount(id));
+    }
+
+    @ApiOperation(value = "游戏基本信息查询")
+    @PostMapping(value = "/add/or/update")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
+    public ResultVo<Boolean> gameAccountAddOrUpdate(@Validated @RequestBody GameAccountUpdateParam param) {
+        return new ResultVo<>(gameAppletService.gameAccountAddOrUpdate(param));
+    }
+}

+ 47 - 15
game-module/game-manage/src/main/java/com/zanxiang/manage/controller/GameController.java

@@ -2,11 +2,8 @@ package com.zanxiang.manage.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.zanxiang.common.domain.ResultVo;
-import com.zanxiang.manage.domain.params.GameAddParam;
-import com.zanxiang.manage.domain.params.GameListParam;
-import com.zanxiang.manage.domain.vo.GameChoiceVO;
-import com.zanxiang.manage.domain.vo.GameInfoVO;
-import com.zanxiang.manage.domain.vo.GameListVO;
+import com.zanxiang.manage.domain.params.*;
+import com.zanxiang.manage.domain.vo.*;
 import com.zanxiang.manage.service.GameService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -14,6 +11,7 @@ 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.*;
 
 import java.util.List;
@@ -35,29 +33,63 @@ public class GameController {
     @ApiOperation(value = "新增游戏")
     @PostMapping(value = "/add")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameListVO.class)})
-    public ResultVo<Boolean> gameAdd(@RequestBody GameAddParam param) {
+    public ResultVo<Boolean> gameAdd(@Validated @RequestBody GameAddParam param) {
         return new ResultVo<>(gameService.gameAdd(param));
     }
 
-    @ApiOperation(value = "游戏基本信息更新")
-    @GetMapping(value = "/game/info")
+    @ApiOperation(value = "游戏基本信息查询")
+    @GetMapping(value = "/detail/info")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameInfoVO.class)})
     public ResultVo<GameInfoVO> getGameInfo(@RequestParam Long id) {
         return new ResultVo<>(gameService.getGameInfo(id));
     }
 
-//    @ApiOperation(value = "游戏账号信息")
-//    @PostMapping(value = "/game/update")
-//    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameListVO.class)})
-//    public ResultVo<IPage<GameListVO>> gameUpdate(@RequestBody GameListParam param) {
-//        return new ResultVo<>(gameService.gameList(param));
-//    }
+    @ApiOperation(value = "游戏基本信息更新")
+    @PostMapping(value = "/detail/update")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
+    public ResultVo<Boolean> gameUpdate(@Validated @RequestBody GameUpdateParam param) {
+        return new ResultVo<>(gameService.updateGameInfo(param));
+    }
+
+    @ApiOperation(value = "游戏对接参数获取展示")
+    @GetMapping(value = "/dock/info")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameDockVO.class)})
+    public ResultVo<GameDockVO> getGameDock(@RequestParam Long id) {
+        return new ResultVo<>(gameService.getGameDock(id));
+    }
+
+    @ApiOperation(value = "游戏对接参数更新更新")
+    @PostMapping(value = "/dock/update")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
+    public ResultVo<Boolean> gameDockUpdate(@Validated @RequestBody GameDockParam param) {
+        return new ResultVo<>(gameService.gameDockUpdate(param));
+    }
 
+    @ApiOperation(value = "获取游戏关联信息")
+    @GetMapping(value = "/relation/info")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameRelationVO.class)})
+    public ResultVo<GameRelationVO> getGameRelation(@RequestParam Long id) {
+        return new ResultVo<>(gameService.getGameRelation(id));
+    }
+
+    @ApiOperation(value = "关联游戏更新")
+    @PostMapping(value = "/relation/update")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
+    public ResultVo<Boolean> relationGameUpdate(@Validated @RequestBody RelationGameUpdateParam param) {
+        return new ResultVo<>(gameService.relationGameUpdate(param));
+    }
+
+    @ApiOperation(value = "导量游戏更新")
+    @PostMapping(value = "/guide/update")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameListVO.class)})
+    public ResultVo<Boolean> guideGameUpdateUpdate(@Validated @RequestBody GuideGameUpdateParam param) {
+        return new ResultVo<>(gameService.guideGameUpdateUpdate(param));
+    }
 
     @ApiOperation(value = "游戏列表查询")
     @PostMapping(value = "/list")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameListVO.class)})
-    public ResultVo<IPage<GameListVO>> gameList(@RequestBody GameListParam param) {
+    public ResultVo<IPage<GameListVO>> gameList(@Validated @RequestBody GameListParam param) {
         return new ResultVo<>(gameService.gameList(param));
     }
 

+ 67 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/params/GameAccountUpdateParam.java

@@ -0,0 +1,67 @@
+package com.zanxiang.manage.domain.params;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-07-08
+ * @description : 游戏账号信息配置更新
+ */
+@Data
+public class GameAccountUpdateParam {
+
+    /**
+     * 主键id
+     */
+    @ApiModelProperty(notes = "主键id, 不传则是新增, 传则是更新")
+    private Long id;
+
+    /**
+     * 游戏id
+     */
+    @ApiModelProperty(notes = "游戏id")
+    private Long gameId;
+
+    /**
+     * 小程序appId
+     */
+    @ApiModelProperty(notes = "小程序appId")
+    private String appId;
+
+    /**
+     * 小程序原始id
+     */
+    @ApiModelProperty(notes = "小程序原始id")
+    private String ghId;
+
+    /**
+     * 登录账号
+     */
+    @ApiModelProperty(notes = "登录账号")
+    private String account;
+
+    /**
+     * 登录密码
+     */
+    @ApiModelProperty(notes = "登录密码")
+    private String password;
+
+    /**
+     * 管理员微信
+     */
+    @ApiModelProperty(notes = "管理员微信")
+    private String adminVx;
+
+    /**
+     * 公司主体信息
+     */
+    @ApiModelProperty(notes = "公司主体信息")
+    private String company;
+
+    /**
+     * 小程序密钥
+     */
+    @ApiModelProperty(notes = "小程序密钥")
+    private String appSecret;
+}

+ 40 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/params/GameDockParam.java

@@ -0,0 +1,40 @@
+package com.zanxiang.manage.domain.params;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-07-08
+ * @description : 对接参数
+ */
+@Data
+public class GameDockParam {
+
+    /**
+     * 游戏id
+     */
+    @NotNull(message = "游戏id不可为空")
+    @ApiModelProperty(notes = "游戏id")
+    private Long id;
+
+    /**
+     * 游戏appId
+     */
+    @ApiModelProperty(notes = "游戏appId")
+    private String appId;
+
+    /**
+     * 密钥secret
+     */
+    @ApiModelProperty(notes = "密钥secret")
+    private String appSecret;
+
+    /**
+     * 游戏key
+     */
+    @ApiModelProperty(notes = "游戏key")
+    private String appKey;
+}

+ 6 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/params/GameUpdateParam.java

@@ -31,6 +31,12 @@ public class GameUpdateParam {
     @ApiModelProperty(notes = "cpId")
     private Long cpId;
 
+    /**
+     * 是主父游戏
+     */
+    @ApiModelProperty(notes = "是否主游戏")
+    private Boolean isParentGame;
+
     /**
      * 游戏分类id, 多个
      */

+ 29 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/params/GuideGameUpdateParam.java

@@ -0,0 +1,29 @@
+package com.zanxiang.manage.domain.params;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-07-08
+ * @description : 导量游戏更新参数
+ */
+@Data
+public class GuideGameUpdateParam {
+
+    /**
+     * 游戏主键id
+     */
+    @NotNull(message = "游戏主键id不可为空")
+    @ApiModelProperty(notes = "游戏主键id")
+    private Long id;
+
+    /**
+     * 导量游戏id
+     */
+    @NotNull(message = "导量游戏id不可为空")
+    @ApiModelProperty(notes = "导量游戏id")
+    private Long guideGameId;
+}

+ 35 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/params/RelationGameUpdateParam.java

@@ -0,0 +1,35 @@
+package com.zanxiang.manage.domain.params;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-07-08
+ * @description : 关联游戏更新参数
+ */
+@Data
+public class RelationGameUpdateParam {
+
+    /**
+     * 游戏主键id
+     */
+    @NotNull(message = "游戏主键id不可为空")
+    @ApiModelProperty(notes = "游戏主键id")
+    private Long id;
+
+    /**
+     * 关联主游戏id
+     */
+    @ApiModelProperty(notes = "关联主游戏id")
+    private Long parentId;
+
+    /**
+     * 关联H5游戏id
+     */
+    @ApiModelProperty(notes = "游戏主键id")
+    private Long h5GameId;
+
+}

+ 67 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/vo/GameAccountVO.java

@@ -0,0 +1,67 @@
+package com.zanxiang.manage.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-07-08
+ * @description : 账号信息配置
+ */
+@Data
+public class GameAccountVO {
+
+    /**
+     * 主键id
+     */
+    @ApiModelProperty(notes = "主键id")
+    private Long id;
+
+    /**
+     * 游戏id
+     */
+    @ApiModelProperty(notes = "游戏id")
+    private Long gameId;
+
+    /**
+     * 小程序appId
+     */
+    @ApiModelProperty(notes = "小程序appId")
+    private String appId;
+
+    /**
+     * 小程序原始id
+     */
+    @ApiModelProperty(notes = "小程序原始id")
+    private String ghId;
+
+    /**
+     * 登录账号
+     */
+    @ApiModelProperty(notes = "登录账号")
+    private String account;
+
+    /**
+     * 登录密码
+     */
+    @ApiModelProperty(notes = "登录密码")
+    private String password;
+
+    /**
+     * 管理员微信
+     */
+    @ApiModelProperty(notes = "管理员微信")
+    private String adminVx;
+
+    /**
+     * 公司主体信息
+     */
+    @ApiModelProperty(notes = "公司主体信息")
+    private String company;
+
+    /**
+     * 小程序密钥
+     */
+    @ApiModelProperty(notes = "小程序密钥")
+    private String appSecret;
+}

+ 6 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/vo/GameChoiceVO.java

@@ -22,4 +22,10 @@ public class GameChoiceVO {
      */
     @ApiModelProperty(notes = "游戏名称")
     private String name;
+
+    /**
+     * 游戏应用类型id
+     */
+    @ApiModelProperty(notes = "游戏应用类型id")
+    private Long category;
 }

+ 55 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/vo/GameDockVO.java

@@ -0,0 +1,55 @@
+package com.zanxiang.manage.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-07-08
+ * @description : 对接参数显示
+ */
+@Data
+public class GameDockVO {
+
+    /**
+     * cpId
+     */
+    @ApiModelProperty(notes = "cpId")
+    private Long cpId;
+
+    /**
+     * cp名称
+     */
+    @ApiModelProperty(notes = "cp名称")
+    private String cpName;
+
+    /**
+     * 游戏id
+     */
+    @ApiModelProperty(notes = "游戏id")
+    private Long id;
+
+    /**
+     * 游戏名称
+     */
+    @ApiModelProperty(notes = "游戏名称")
+    private String name;
+
+    /**
+     * 游戏appId
+     */
+    @ApiModelProperty(notes = "游戏appId")
+    private String appId;
+
+    /**
+     * 密钥secret
+     */
+    @ApiModelProperty(notes = "密钥secret")
+    private String appSecret;
+
+    /**
+     * 游戏key
+     */
+    @ApiModelProperty(notes = "游戏key")
+    private String appKey;
+}

+ 7 - 1
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/vo/GameInfoVO.java

@@ -25,6 +25,12 @@ public class GameInfoVO {
     @ApiModelProperty(notes = "游戏名称")
     private String name;
 
+    /**
+     * 是主父游戏
+     */
+    @ApiModelProperty(notes = "是否主游戏")
+    private Boolean isParentGame;
+
     /**
      * cpId
      */
@@ -89,7 +95,7 @@ public class GameInfoVO {
      * 导量游戏名字
      */
     @ApiModelProperty(notes = "导量游戏名字")
-    private Long guideGameName;
+    private String guideGameName;
 
     /**
      * 游戏宣传语

+ 86 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/vo/GameRelationVO.java

@@ -0,0 +1,86 @@
+package com.zanxiang.manage.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-07-08
+ * @description : 游戏关联信息
+ */
+@Data
+public class GameRelationVO {
+
+    /**
+     * 游戏id
+     */
+    @ApiModelProperty(notes = "游戏id")
+    private Long id;
+
+    /**
+     * 游戏名称
+     */
+    @ApiModelProperty(notes = "游戏名称")
+    private String name;
+
+    /**
+     * 主游戏id
+     */
+    @ApiModelProperty(notes = "主游戏id")
+    private Long parentId;
+
+    /**
+     * 主游戏名称
+     */
+    @ApiModelProperty(notes = "主游戏名称")
+    private String parentName;
+
+    /**
+     * 主游戏应用类型id
+     */
+    @ApiModelProperty(notes = "主游戏应用类型id")
+    private Long parentCategoryId;
+
+    /**
+     * 主游戏应用类型名称
+     */
+    @ApiModelProperty(notes = "主游戏应用类型名称")
+    private String parentCategoryName;
+
+    /**
+     * 关联H5游戏id
+     */
+    @ApiModelProperty(notes = "关联H5游戏id")
+    private Long h5GameId;
+
+    /**
+     * 关联H5游戏名称
+     */
+    @ApiModelProperty(notes = "关联H5游戏名称")
+    private String h5GameName;
+
+    /**
+     * 导量游戏id
+     */
+    @ApiModelProperty(notes = "导量游戏id")
+    private Long guideGameId;
+
+    /**
+     * 导量游戏名字
+     */
+    @ApiModelProperty(notes = "导量游戏名字")
+    private String guideGameName;
+
+    /**
+     * 导量游戏应用类型id
+     */
+    @ApiModelProperty(notes = "导量游戏应用类型id")
+    private Long guideCategoryId;
+
+    /**
+     * 导量游戏应用类型名称
+     */
+    @ApiModelProperty(notes = "导量游戏应用类型名称")
+    private String guideCategoryName;
+
+}

+ 30 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/service/GameAppletService.java

@@ -0,0 +1,30 @@
+package com.zanxiang.manage.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.zanxiang.manage.domain.params.GameAccountUpdateParam;
+import com.zanxiang.manage.domain.vo.GameAccountVO;
+import com.zanxiang.mybatis.entity.GameApplet;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-07-08
+ * @description : 微信小游戏(小程序)
+ */
+public interface GameAppletService extends IService<GameApplet> {
+
+    /**
+     * 获取账号信息配置
+     *
+     * @param id : 游戏id
+     * @return : 账号配置信息
+     */
+    GameAccountVO getGameAccount(Long id);
+
+    /**
+     * 获取账号信息配置
+     *
+     * @param param : 更新参数
+     * @return : 账号配置信息
+     */
+    Boolean gameAccountAddOrUpdate(GameAccountUpdateParam param);
+}

+ 50 - 5
game-module/game-manage/src/main/java/com/zanxiang/manage/service/GameService.java

@@ -3,11 +3,8 @@ package com.zanxiang.manage.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zanxiang.manage.domain.dto.GameDTO;
-import com.zanxiang.manage.domain.params.GameAddParam;
-import com.zanxiang.manage.domain.params.GameListParam;
-import com.zanxiang.manage.domain.vo.GameChoiceVO;
-import com.zanxiang.manage.domain.vo.GameInfoVO;
-import com.zanxiang.manage.domain.vo.GameListVO;
+import com.zanxiang.manage.domain.params.*;
+import com.zanxiang.manage.domain.vo.*;
 import com.zanxiang.mybatis.entity.Game;
 
 import java.util.List;
@@ -20,6 +17,46 @@ import java.util.Map;
  */
 public interface GameService extends IService<Game> {
 
+    /**
+     * 获取游戏对接参数
+     *
+     * @param id : 游戏id
+     * @return : 信息展示
+     */
+    GameDockVO getGameDock(Long id);
+
+    /**
+     * 参数对接更新
+     *
+     * @param param : 对接参数
+     * @return : 返回更新结果
+     */
+    Boolean gameDockUpdate(GameDockParam param);
+
+    /**
+     * 获取游戏关联信息
+     *
+     * @param id : 游戏id
+     * @return : 返回游戏关联信息
+     */
+    GameRelationVO getGameRelation(Long id);
+
+    /**
+     * 导量游戏更新
+     *
+     * @param param : 关联游戏更新参数
+     * @return : 返回更新结果
+     */
+    Boolean guideGameUpdateUpdate(GuideGameUpdateParam param);
+
+    /**
+     * 关联游戏更新
+     *
+     * @param param : 关联游戏更新参数
+     * @return : 返回更新结果
+     */
+    Boolean relationGameUpdate(RelationGameUpdateParam param);
+
     /**
      * 获取游戏基本信息
      *
@@ -28,6 +65,14 @@ public interface GameService extends IService<Game> {
      */
     GameInfoVO getGameInfo(Long gameId);
 
+    /**
+     * 游戏基本信息更新
+     *
+     * @param param : 游戏更新参数
+     * @return : 返回更新结果
+     */
+    Boolean updateGameInfo(GameUpdateParam param);
+
     /**
      * 新增游戏
      *

+ 69 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/service/Impl/GameAppletServiceImpl.java

@@ -0,0 +1,69 @@
+package com.zanxiang.manage.service.Impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zanxiang.common.utils.bean.BeanUtils;
+import com.zanxiang.manage.domain.params.GameAccountUpdateParam;
+import com.zanxiang.manage.domain.vo.GameAccountVO;
+import com.zanxiang.manage.service.GameAppletService;
+import com.zanxiang.mybatis.entity.GameApplet;
+import com.zanxiang.mybatis.mapper.GameAppletMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-07-08
+ * @description : 微信小游戏(小程序)
+ */
+@Slf4j
+@Service
+public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApplet> implements GameAppletService {
+
+    /**
+     * 获取账号信息配置
+     *
+     * @param id : 游戏id
+     * @return : 账号配置信息
+     */
+    @Override
+    public GameAccountVO getGameAccount(Long id) {
+        GameApplet gameApplet = super.getOne(new LambdaQueryWrapper<GameApplet>()
+                .eq(GameApplet::getGameId, id));
+        if (gameApplet == null) {
+            GameAccountVO vo = new GameAccountVO();
+            vo.setGameId(id);
+            return vo;
+        }
+        return BeanUtils.copy(gameApplet, GameAccountVO.class);
+    }
+
+    /**
+     * 账号配置信息更新或者添加
+     *
+     * @param param : 更新参数
+     * @return : 账号配置信息
+     */
+    @Override
+    public Boolean gameAccountAddOrUpdate(GameAccountUpdateParam param) {
+        GameApplet gameApplet;
+        if (param.getId() == null) {
+            gameApplet = new GameApplet();
+            gameApplet.setCreateTime(LocalDateTime.now());
+            gameApplet.setGameId(param.getGameId());
+        } else {
+            gameApplet = super.getById(param.getId());
+        }
+        gameApplet.setAppId(param.getAppId());
+        gameApplet.setGhId(param.getGhId());
+        gameApplet.setAccount(param.getAccount());
+        gameApplet.setPassword(param.getPassword());
+        gameApplet.setAdminVx(param.getAdminVx());
+        gameApplet.setCompany(param.getCompany());
+        gameApplet.setAppSecret(param.getAppSecret());
+        gameApplet.setUpdateTime(LocalDateTime.now());
+        return super.saveOrUpdate(gameApplet);
+    }
+}

+ 200 - 15
game-module/game-manage/src/main/java/com/zanxiang/manage/service/Impl/GameServiceImpl.java

@@ -8,13 +8,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zanxiang.common.enums.GameCategoryEnum;
 import com.zanxiang.common.utils.bean.BeanUtils;
 import com.zanxiang.manage.domain.dto.GameDTO;
-import com.zanxiang.manage.domain.params.GameAddParam;
-import com.zanxiang.manage.domain.params.GameListParam;
-import com.zanxiang.manage.domain.params.GameUpdateParam;
+import com.zanxiang.manage.domain.params.*;
 import com.zanxiang.manage.domain.vo.*;
 import com.zanxiang.manage.service.*;
 import com.zanxiang.mybatis.entity.Cp;
 import com.zanxiang.mybatis.entity.Game;
+import com.zanxiang.mybatis.entity.GameApplet;
+import com.zanxiang.mybatis.entity.GameCategory;
 import com.zanxiang.mybatis.mapper.GameMapper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -49,6 +49,182 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements Ga
     @Autowired
     private CpService cpService;
 
+    @Autowired
+    private GameAppletService gameAppletService;
+
+    /**
+     * 获取游戏对接参数
+     *
+     * @param id : 游戏id
+     * @return : 信息展示
+     */
+    @Override
+    public GameDockVO getGameDock(Long id) {
+        Game game = super.getById(id);
+        GameDockVO gameDockVO = BeanUtils.copy(game, GameDockVO.class);
+        if (gameDockVO == null) {
+            return null;
+        }
+        Cp cp = cpService.getById(gameDockVO.getCpId());
+        if (cp != null) {
+            gameDockVO.setCpName(cp.getCpName());
+        }
+        GameApplet gameApplet = gameAppletService.getOne(new LambdaQueryWrapper<GameApplet>().eq(GameApplet::getGameId, gameDockVO.getId()));
+        if (gameApplet != null) {
+            gameDockVO.setAppId(gameApplet.getAppId());
+            gameDockVO.setAppSecret(gameApplet.getAppSecret());
+        }
+        return gameDockVO;
+    }
+
+    /**
+     * 参数对接更新
+     *
+     * @param param : 对接参数
+     * @return : 返回更新结果
+     */
+    @Override
+    public Boolean gameDockUpdate(GameDockParam param) {
+        if (Strings.isNotBlank(param.getAppKey())) {
+            super.update(new LambdaUpdateWrapper<Game>()
+                    .set(Game::getAppKey, param.getAppKey())
+                    .set(Game::getUpdateTime, LocalDateTime.now())
+                    .eq(Game::getId, param.getId()));
+        }
+        if (Strings.isBlank(param.getAppId()) && Strings.isBlank(param.getAppSecret())) {
+            return Boolean.TRUE;
+        }
+        GameApplet gameApplet = gameAppletService.getOne(new LambdaQueryWrapper<GameApplet>()
+                .eq(GameApplet::getGameId, param.getId()));
+        if (gameApplet == null) {
+            gameApplet = GameApplet.builder()
+                    .gameId(param.getId())
+                    .createTime(LocalDateTime.now())
+                    .build();
+        }
+        gameApplet.setUpdateTime(LocalDateTime.now());
+        if (Strings.isNotBlank(param.getAppId())) {
+            gameApplet.setAppId(param.getAppId());
+        }
+        if (Strings.isNotBlank(param.getAppSecret())) {
+            gameApplet.setAppSecret(param.getAppSecret());
+        }
+        return gameAppletService.saveOrUpdate(gameApplet);
+    }
+
+    /**
+     * 获取游戏关联信息
+     *
+     * @param id : 游戏id
+     * @return : 返回游戏关联信息
+     */
+    @Override
+    public GameRelationVO getGameRelation(Long id) {
+        Game game = super.getById(id);
+        GameRelationVO gameRelationVO = BeanUtils.copy(game, GameRelationVO.class);
+        if (gameRelationVO == null) {
+            return null;
+        }
+        Map<Long, Game> gameMap = this.getGameRelationMap(Collections.singletonList(game));
+        //没有关联游戏
+        if (gameMap.isEmpty()) {
+            return gameRelationVO;
+        }
+        //设置关联游戏名字
+        if (Objects.equals(gameRelationVO.getParentId(), 0L)) {
+            gameRelationVO.setParentId(game.getId());
+            gameRelationVO.setParentName(game.getName());
+            gameRelationVO.setParentCategoryId(game.getCategory());
+        } else {
+            //非主游戏
+            if (gameRelationVO.getParentId() != null && gameMap.containsKey(gameRelationVO.getParentId())) {
+                gameRelationVO.setParentName(gameMap.get(gameRelationVO.getParentId()).getName());
+                gameRelationVO.setParentCategoryId(gameMap.get(gameRelationVO.getParentId()).getCategory());
+            }
+        }
+        if (gameRelationVO.getGuideGameId() != null && gameMap.containsKey(gameRelationVO.getGuideGameId())) {
+            gameRelationVO.setGuideGameName(gameMap.get(gameRelationVO.getGuideGameId()).getName());
+            gameRelationVO.setGuideCategoryId(gameMap.get(gameRelationVO.getGuideGameId()).getCategory());
+        }
+        if (gameRelationVO.getH5GameId() != null && gameMap.containsKey(gameRelationVO.getH5GameId())) {
+            gameRelationVO.setH5GameName(gameMap.get(gameRelationVO.getH5GameId()).getName());
+        }
+        //设置关联游戏应用类型名字
+        Set<Long> categoryIdSet = new HashSet<>();
+        if (gameRelationVO.getParentCategoryId() != null) {
+            categoryIdSet.add(gameRelationVO.getParentCategoryId());
+        }
+        if (gameRelationVO.getGuideCategoryId() != null) {
+            categoryIdSet.add(gameRelationVO.getGuideCategoryId());
+        }
+        Map<Long, GameCategory> categoryMap = gameCategoryService.listByIds(categoryIdSet).stream()
+                .collect(Collectors.toMap(GameCategory::getId, Function.identity()));
+        if (gameRelationVO.getParentCategoryId() != null && categoryMap.containsKey(gameRelationVO.getParentCategoryId())) {
+            gameRelationVO.setParentCategoryName(categoryMap.get(gameRelationVO.getParentCategoryId()).getName());
+        }
+        if (gameRelationVO.getGuideCategoryId() != null && categoryMap.containsKey(gameRelationVO.getGuideCategoryId())) {
+            gameRelationVO.setGuideCategoryName(categoryMap.get(gameRelationVO.getGuideCategoryId()).getName());
+        }
+        return gameRelationVO;
+    }
+
+    /**
+     * 获取游戏的关联map
+     *
+     * @param gameList : 游戏列表
+     * @return : 返回游戏列表
+     */
+    private Map<Long, Game> getGameRelationMap(List<Game> gameList) {
+        Set<Long> gameIdSet = new HashSet<>();
+        gameList.forEach(game -> {
+            if (game.getParentId() != null && !Objects.equals(game.getParentId(), 0L)) {
+                gameIdSet.add(game.getParentId());
+            }
+            if (game.getH5GameId() != null) {
+                gameIdSet.add(game.getH5GameId());
+            }
+            if (game.getGuideGameId() != null) {
+                gameIdSet.add(game.getGuideGameId());
+            }
+        });
+        if (gameIdSet.isEmpty()) {
+            return Collections.emptyMap();
+        }
+        return super.listByIds(gameIdSet).stream().collect(Collectors.toMap(Game::getId, Function.identity()));
+    }
+
+    /**
+     * 导量游戏更新
+     *
+     * @param param : 关联游戏更新参数
+     * @return : 返回更新结果
+     */
+    @Override
+    public Boolean guideGameUpdateUpdate(GuideGameUpdateParam param) {
+        return super.update(new LambdaUpdateWrapper<Game>()
+                .set(param.getGuideGameId() != null, Game::getGuideGameId, param.getGuideGameId())
+                .set(Game::getUpdateTime, LocalDateTime.now())
+                .eq(Game::getId, param.getId()));
+    }
+
+    /**
+     * 关联游戏更新
+     *
+     * @param param : 关联游戏更新参数
+     * @return : 返回更新结果
+     */
+    @Override
+    public Boolean relationGameUpdate(RelationGameUpdateParam param) {
+        if (param.getParentId() == null && param.getH5GameId() == null) {
+            return Boolean.FALSE;
+        }
+        return super.update(new LambdaUpdateWrapper<Game>()
+                .set(param.getParentId() != null, Game::getParentId, param.getParentId())
+                .set(param.getH5GameId() != null, Game::getH5GameId, param.getH5GameId())
+                .set(Game::getUpdateTime, LocalDateTime.now())
+                .eq(Game::getId, param.getId()));
+    }
+
     /**
      * 获取游戏基本信息
      *
@@ -78,29 +254,37 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements Ga
             GameCategoryVO gameCategoryVO = gameCategoryService.getById(game.getCategory());
             gameInfoVO.setCategory(BeanUtils.copy(gameCategoryVO, GameCategoryParentVO.class));
         }
-        //游戏名字
-        List<Long> gameIdList = new ArrayList<>();
+        //是否主游戏
+        gameInfoVO.setIsParentGame(Objects.equals(gameInfoVO.getParentId(), 0L));
+        //关联游戏查询
+        Map<Long, Game> gameMap = this.getGameRelationMap(Collections.singletonList(game));
+        //没有关联游戏
+        if (gameMap.isEmpty()) {
+            return gameInfoVO;
+        }
+        //设置关联游戏名字
         if (gameInfoVO.getParentId() != null && !Objects.equals(gameInfoVO.getParentId(), 0L)) {
-            gameIdList.add(gameInfoVO.getParentId());
+            gameInfoVO.setParentName(gameMap.get(gameInfoVO.getParentId()).getName());
+        } else {
+            gameInfoVO.setParentId(game.getId());
+            gameInfoVO.setParentName(game.getName());
         }
         if (gameInfoVO.getH5GameId() != null) {
-            gameIdList.add(gameInfoVO.getH5GameId());
+            gameInfoVO.setH5GameName(gameMap.get(gameInfoVO.getH5GameId()).getName());
         }
         if (gameInfoVO.getGuideGameId() != null) {
-            gameIdList.add(gameInfoVO.getGuideGameId());
+            gameInfoVO.setGuideGameName(gameMap.get(gameInfoVO.getGuideGameId()).getName());
         }
-        List<Game> gameList = super.listByIds(gameIdList);
-
-
         return gameInfoVO;
     }
 
     /**
-     * 获取游戏基本信息
+     * 游戏基本信息更新
      *
      * @param param : 游戏更新参数
      * @return : 返回更新结果
      */
+    @Override
     public Boolean updateGameInfo(GameUpdateParam param) {
         //游戏分类处理
         List<Long> classifyList = param.getClassifyList();
@@ -112,7 +296,9 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements Ga
                 .set(Strings.isNotBlank(map.get("classifyParent")), Game::getClassifyParent, map.get("classifyParent"))
                 .set(param.getCategory() != null, Game::getCategory, param.getCategory())
                 .set(param.getShareScale() != null, Game::getShareScale, param.getShareScale())
-                .set(param.getParentId() != null, Game::getParentId, param.getParentId())
+                .set(Objects.equals(param.getIsParentGame(), Boolean.TRUE), Game::getParentId, 0L)
+                .set(!Objects.equals(param.getIsParentGame(), Boolean.TRUE) && param.getParentId() != null,
+                        Game::getParentId, param.getParentId())
                 .set(param.getH5GameId() != null, Game::getH5GameId, param.getH5GameId())
                 .set(param.getGuideGameId() != null, Game::getGuideGameId, param.getGuideGameId())
                 .set(Strings.isNotBlank(param.getPublicity()), Game::getPublicity, param.getPublicity())
@@ -124,7 +310,6 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements Ga
                 .eq(Game::getId, param.getId()));
     }
 
-
     /**
      * 新增游戏
      *
@@ -240,7 +425,7 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements Ga
      */
     @Override
     public List<GameChoiceVO> choiceList() {
-        List<Game> gameList = super.list(new LambdaQueryWrapper<Game>().select(Game::getId, Game::getName));
+        List<Game> gameList = super.list(new LambdaQueryWrapper<Game>().select(Game::getId, Game::getName, Game::getCategory));
         return BeanUtils.copyList(gameList, GameChoiceVO.class);
     }
 

+ 79 - 0
game-module/game-mybatis/src/main/java/com/zanxiang/mybatis/entity/GameApplet.java

@@ -0,0 +1,79 @@
+package com.zanxiang.mybatis.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-07-08
+ * @description : 游戏小程序信息
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@ToString
+@Builder
+@TableName("h_game_applet")
+public class GameApplet {
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 游戏id
+     */
+    private Long gameId;
+
+    /**
+     * 小程序appId
+     */
+    private String appId;
+
+    /**
+     * 小程序密钥
+     */
+    private String appSecret;
+
+    /**
+     * 小程序原始id
+     */
+    private String ghId;
+
+    /**
+     * 登录账号
+     */
+    private String account;
+
+    /**
+     * 登录密码
+     */
+    private String password;
+
+    /**
+     * 管理员微信
+     */
+    private String adminVx;
+
+    /**
+     * 公司主体信息
+     */
+    private String company;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+}

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

@@ -0,0 +1,12 @@
+package com.zanxiang.mybatis.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zanxiang.mybatis.entity.GameApplet;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-07-08
+ * @description : ${description}
+ */
+public interface GameAppletMapper extends BaseMapper<GameApplet> {
+}

+ 4 - 0
game-module/game-mybatis/src/main/resources/mapper/GameAppletMapper.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zanxiang.mybatis.mapper.GameAppletMapper">
+</mapper>