瀏覽代碼

feat : 游戏接口修改

bilingfeng 2 年之前
父節點
當前提交
f09e4cee12

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

@@ -33,11 +33,11 @@ public class GameController {
     private GameService gameService;
 
     @ApiOperation(value = "新增游戏")
-    @PostMapping(value = "/add")
+    @PostMapping(value = "/add/or/update")
     @PreAuthorize(permissionKey = "sdk:game:add")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameListVO.class)})
-    public ResultVO<Boolean> gameAdd(@Validated @RequestBody GameAddParam param) {
-        return new ResultVO<>(gameService.gameAdd(param));
+    public ResultVO<Boolean> gameAddOrUpdate(@Validated @RequestBody GameAddParam param) {
+        return new ResultVO<>(gameService.gameAddOrUpdate(param));
     }
 
     @ApiOperation(value = "游戏基本信息查询")

+ 18 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/params/GameAddParam.java

@@ -16,6 +16,12 @@ import java.util.List;
 @Data
 public class GameAddParam {
 
+    /**
+     * 主键id, 传值为更新, 不传值为新增
+     */
+    @ApiModelProperty(notes = "cpId")
+    private Long id;
+
     /**
      * cpId
      */
@@ -63,4 +69,16 @@ public class GameAddParam {
     @ApiModelProperty(notes = "父游戏id")
     private Long parentGameId;
 
+    /**
+     * CP回调地址
+     */
+    @ApiModelProperty(notes = "CP回调地址")
+    private String cpPaybackUrl;
+
+    /**
+     * 游戏地址
+     */
+    @ApiModelProperty(notes = "游戏地址")
+    private String gameUrl;
+
 }

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

@@ -80,7 +80,7 @@ public interface GameService extends IService<Game> {
      * @param param : 游戏新增参数
      * @return : 返回添加结果
      */
-    Boolean gameAdd(GameAddParam param);
+    Boolean gameAddOrUpdate(GameAddParam param);
 
     /**
      * 查询游戏列表

+ 26 - 12
game-module/game-manage/src/main/java/com/zanxiang/manage/service/Impl/GameServiceImpl.java

@@ -318,24 +318,38 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements Ga
      * @return : 返回添加结果
      */
     @Override
-    public Boolean gameAdd(GameAddParam param) {
+    public Boolean gameAddOrUpdate(GameAddParam param) {
         //游戏分类处理
         List<Long> classifyList = param.getClassifyList();
         Map<String, String> map = this.getClassifyMap(classifyList);
-        Game game = Game.builder()
-                .cpId(param.getCpId())
-                .name(param.getName())
-                .shareScale(param.getShareScale())
-                .category(param.getCategory())
-                .classify(map.get("classify"))
-                .classifyParent(map.get("classifyParent"))
-                .createTime(LocalDateTime.now())
-                .updateTime(LocalDateTime.now())
-                .build();
+        //主键id
+        Long id = param.getId();
+        Game game;
+        if (id == null) {
+            game = Game.builder()
+                    .cpId(param.getCpId())
+                    .name(param.getName())
+                    .shareScale(param.getShareScale())
+                    .category(param.getCategory())
+                    .classify(map.get("classify"))
+                    .classifyParent(map.get("classifyParent"))
+                    .createTime(LocalDateTime.now())
+                    .updateTime(LocalDateTime.now())
+                    .build();
+        } else {
+            game = super.getById(id);
+            game.setCpId(param.getCpId());
+            game.setName(param.getName());
+            game.setShareScale(param.getShareScale());
+            game.setClassify(map.get("classify"));
+            game.setClassifyParent(map.get("classifyParent"));
+            game.setUpdateTime(LocalDateTime.now());
+        }
+        //设置父游戏id
         if (!Objects.equals(param.getIsParentGame(), Boolean.TRUE) && param.getParentGameId() != null) {
             game.setParentId(param.getParentGameId());
         }
-        return super.save(game);
+        return super.saveOrUpdate(game);
     }
 
     /**