|
|
|
@@ -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<WxGame> gamePageInfo = PageHelper.startPage(pageNum, 1).doSelectPageInfo(() -> wxGameMapper.findList(record)); |
|
|
|
wxGame = gamePageInfo.getList().get(0); |
|
|
|
PageInfo<WxGame> 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<Object> getParams(WxGame record) { |
|
|
|
|