public void updateBettingMatch(UpdateBettingMatchInfo updateBettingMatchInfo) { BettingMatch bettingMatch = bettingMatchRepo.findOne(updateBettingMatchInfo.getBettingMatchId()); if (!bettingMatch.isActivated()) { if (updateBettingMatchInfo.getExpiredTime().isAfter(LocalDateTime.now())) { Group group = groupRepo.findOne(updateBettingMatchInfo.getGroupId()); Match match = matchRepo.findOne(updateBettingMatchInfo.getMatchId()); if (balanceIsValid(updateBettingMatchInfo.getBalance1()) && balanceIsValid(updateBettingMatchInfo.getBalance2())) { if (isExistedInTournament(match, group)) { bettingMatch.setBalance1(updateBettingMatchInfo.getBalance1()); bettingMatch.setBalance2(updateBettingMatchInfo.getBalance2()); bettingMatch.setExpiredTime(updateBettingMatchInfo.getExpiredTime()); bettingMatch.setBetAmount(updateBettingMatchInfo.getBetAmount()); bettingMatch.setMatch(match); bettingMatch.setGroup(group); bettingMatch.setDescription(updateBettingMatchInfo.getDecription()); bettingMatch.setActivated(updateBettingMatchInfo.isActivated()); bettingMatchRepo.save(bettingMatch); } else { throw new DataInvalidException("exception.match.group.invalid"); } } else { throw new DataInvalidException("exception.balance.in.valid"); } } else { throw new DataInvalidException("exception.expiredTime.invalid"); } } else { throw new DataInvalidException("exception.betting.match.is.actived"); } }
public List<BettingMatch> getBettingMatchesByRoundAndGroupId( GetBettingMatchesByRoundAndGroupIdInfo getBettingMatchesByRoundAndGroupIdInfo) { List<BettingMatch> bettingMatches = new ArrayList<>(); Round round = roundRepo.getOne(getBettingMatchesByRoundAndGroupIdInfo.getRoundId()); Group group = groupRepo.getOne(getBettingMatchesByRoundAndGroupIdInfo.getGroupId()); List<Match> matches = matchRepo.findByRound(round); for (Match match : matches) { bettingMatches.add(bettingMatchRepo.findByGroupAndMatch(group, match)); } return bettingMatches; }
public List<BettingMatch> getBettingMatchesByMatch(Long matchId) { Match match = matchRepo.getOne(matchId); return bettingMatchRepo.findByMatch(match); }