|
@@ -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);
|
|
|
}
|
|
|
|
|
|
/**
|