diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxGameController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxGameController.java index 64e93aaab..dbecbf792 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxGameController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxGameController.java @@ -32,21 +32,17 @@ public class WxGameController extends BaseController { @ApiOperation("蒙层/游戏入口获取游戏信息") @GetMapping("getOne") - public ResultData getOne() { - WxGame wxGame = new WxGame(); + public ResultData getOne(@ModelAttribute WxGame wxGame) { + if (wxGame == null) wxGame = new WxGame(); wxGame.setTenantId(getTenantId()); wxGame.setStatus(EnumGameStatus.STATUS_THROW_IN.getCode()); // 因为有算法要求,分成两步获取 - WxGame wxGame1 = wxGameService.getOne(wxGame); - if (wxGame1 != null) { - WxGameTemplate gameTemplate = wxGameTemplateService.getById(wxGame1.getGameId()); - if (gameTemplate != null) { - wxGame1.setGameTemplate(gameTemplate); - return new ResultData(wxGame1); - } + WxGame record = wxGameService.getOne(wxGame); + if (record == null) { + return new ResultData(ErrorCode.GAME_NOT_FOUND); } - return new ResultData(ErrorCode.GAME_NOT_FOUND); + return new ResultData(record); } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java index 3242d1230..370182914 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java @@ -59,24 +59,26 @@ public class WxGameServiceImpl implements WxGameService { } @Override - public WxGame getOne(WxGame record) { - WxGame wxGame = null; + public WxGame getOne(WxGame wxGame) { + WxGame record = null; // get game's count - int countOfGame = wxGameMapper.selectCount(record); + int countOfGame = wxGameMapper.selectCount(wxGame); if (countOfGame == 1){ - wxGame = wxGameMapper.selectOne(record); + record = wxGameMapper.selectOne(wxGame); } else if (countOfGame > 1){ // random int pageNum = (int)(1+Math.random()*(countOfGame-1+1)); - PageInfo gamePageInfo = PageHelper.startPage(pageNum, 1).doSelectPageInfo(() -> wxGameMapper.findList(record)); - wxGame = gamePageInfo.getList().get(0); + PageInfo gamePageInfo = + PageHelper.startPage(pageNum, 1).doSelectPageInfo(() -> wxGameMapper.findList(wxGame)); + record = gamePageInfo.getList().get(0); } - if (wxGame != null) { - wxGame.setCouponIdsList(getParams(wxGame)); - return wxGame; + if (record != null) { + record.setGameTemplate(wxGameTemplateService.getById(record.getGameId())); + record.setCouponIdsList(getParams(record)); } - return null; + + return record; } private List getParams(WxGame record) { diff --git a/mallinkService/src/main/resources/mapper/WxGameMapper.xml b/mallinkService/src/main/resources/mapper/WxGameMapper.xml index 58cc52467..b33066804 100644 --- a/mallinkService/src/main/resources/mapper/WxGameMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxGameMapper.xml @@ -6,13 +6,14 @@ + - `id`,`tenant_id`,`game_id`,`status`,`valid_start_date`,`valid_end_date`,`triggle_action` + `id`,`tenant_id`,`game_id`,`status`,`coupon_ids`,`valid_start_date`,`valid_end_date`,`triggle_action`