|
|
@@ -143,6 +143,12 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements Ga
|
|
|
@Override
|
|
|
public boolean saveGame(Game game) {
|
|
|
if(game.getId() == null){
|
|
|
+ LambdaQueryWrapper<Game> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(Game::getOrderNum,game.getOrderNum());
|
|
|
+ Long count = gameMapper.selectCount(lambdaQueryWrapper);
|
|
|
+ if (count > 0){
|
|
|
+ throw new RuntimeException("显示顺序不能重复");
|
|
|
+ }
|
|
|
game.setId(IdWorker.getId());
|
|
|
Game gameDb = gameMapper.selectMaxGameCode();
|
|
|
Integer gamecode = Integer.parseInt(gameDb.getGameCode())+1;
|
|
|
@@ -156,6 +162,14 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements Ga
|
|
|
}
|
|
|
Game gameUpdate = this.getById(game.getId());
|
|
|
if (ObjectUtils.isNotNull(gameUpdate)){
|
|
|
+ if (game.getOrderNum() != gameUpdate.getOrderNum()){
|
|
|
+ LambdaQueryWrapper<Game> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(Game::getOrderNum,game.getOrderNum());
|
|
|
+ Long count = gameMapper.selectCount(lambdaQueryWrapper);
|
|
|
+ if (count > 0){
|
|
|
+ throw new RuntimeException("显示顺序不能重复");
|
|
|
+ }
|
|
|
+ }
|
|
|
// 修改游戏 同步数据给用户游戏
|
|
|
GameUser gameUser = new GameUser();
|
|
|
gameUser.setTotalNum(game.getTotalNum());
|