@Override public GameRoom update(Long id, GameRoomDto.Update updateDto) { final GameRoom gameRoom = getById(id); if (updateDto.getName() != null && !updateDto.getName().isEmpty()) { gameRoom.setName(updateDto.getName()); } if (updateDto.getOwner() != null) { gameRoom.setOwner(updateDto.getOwner()); } if (updateDto.getPlayers() != null) { gameRoom.getPlayers().clear(); gameRoom.setPlayers(updateDto.getPlayers()); } if (updateDto.getSetting() != null) { gameRoom.setSetting(updateDto.getSetting()); } if (updateDto.getGameCount() != null) { updateDto.setGameCount(updateDto.getGameCount()); } if (updateDto.getPlayerRankMap() != null) { gameRoom.getPlayerRankMap().clear(); gameRoom.setPlayerRankMap(updateDto.getPlayerRankMap()); } gameRoom.setUpdated(new Date()); return update(gameRoom); }
private void fillInitData(final GameRoom gameRoom) { gameRoom.setStatus(Status.NORMAL); gameRoom.getPlayers().add(gameRoom.getOwner()); gameRoom.getPlayerRankMap().put(1, gameRoom.getOwner()); final Date now = new Date(); gameRoom.setCreated(now); gameRoom.setUpdated(now); gameRoom.setEnabled(Enabled.TRUE); }
private void deleteOperation(GameRoom gameRoom) throws JsonProcessingException { gameRoom.setEnabled(Enabled.FALSE); gameRoom.getPlayers().clear(); gameRoom.getPlayerRankMap().clear(); gameRoom.setDeleted(new Date()); }