@RequestMapping(method = RequestMethod.GET, value = "/winners/bets/")
  public CupWinnersBetsDTO all(
      @PathVariable("cupId") final int cupId,
      final HttpServletRequest request,
      final Principal principal) {
    final User currentUser = userService.findByLogin(principal.getName());
    final Cup cup = cupService.load(cupId);
    final Language language = AppContext.read(request.getSession()).getLanguage();

    final CupWinnersBetsDTO result = new CupWinnersBetsDTO();
    result.setWinnersCount(cup.getWinnersCount());
    result.setWinners(dtoService.transformTeams(cup.getCategory(), toTeams(cup), currentUser));

    final boolean isCupBetsAreHiddenYet = !cupBetsService.isCupBettingFinished(cup);
    final List<User> users = getUsers(cup);
    final List<UserCupBetsDTO> usersCupBets = newArrayList();
    for (final User user : users) {
      final List<CupTeamBet> cupTeamBets = cupBetsService.load(cup, user);
      final UserCupBetsDTO userCupBetsDTO = new UserCupBetsDTO();
      userCupBetsDTO.setUser(dtoService.transformUser(user));
      final List<CupTeamBetDTO> userCupBets = dtoService.transformCupTeamBets(cupTeamBets, user);
      if (isCupBetsAreHiddenYet) {
        replaceTeamsWithFakeData(cup, userCupBets, language);
      }
      userCupBetsDTO.setUserCupBets(userCupBets);
      usersCupBets.add(userCupBetsDTO);
    }
    result.setUsersCupBets(usersCupBets);
    return result;
  }
Ejemplo n.º 2
0
  @RequestMapping("cups/{cupId}/logo/")
  public void cupLogo(final @PathVariable("cupId") int cupId, final HttpServletResponse response)
      throws IOException {

    final Cup cup = cupService.load(cupId);

    final File cupLogo = logoService.getLogoFile(cup);
    if (isLogo(cupLogo)) {
      downloadFile(cupLogo, response);
      return;
    }

    downloadFile(logoService.getLogoFile(cup.getCategory()), response);
  }
 @RequestMapping(method = RequestMethod.GET, value = "/winners/")
 public List<TeamDTO> winners(@PathVariable("cupId") final int cupId, final Principal principal) {
   final User currentUser = userService.findByLogin(principal.getName());
   final Cup cup = cupService.load(cupId);
   return dtoService.transformTeams(cup.getCategory(), toTeams(cup), currentUser);
 }