Beispiel #1
0
  // edit team by id
  @RequestMapping(value = "/edit/{id}", method = RequestMethod.GET)
  public String editTeamPageString(Map<String, Object> map, @PathVariable("id") int id) {
    String username = userService.getCurrentUserName();
    Leader leader = leaderService.getLeaderByUserName(username);
    if (teamService.isTeamByLeaderId(leader.getId())) {
      Team teamByLeader = teamService.getTeamByLeader(leader);
      Team team = teamService.getTeamById(id);
      if (teamByLeader.getId() == team.getId()) {

        map.put("team", team);
        String birthDate = team.getLeader().getBirthday().toString();
        if (birthDate.matches(
            "[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])( 00:00:00.0)")) {
          birthDate = birthDate.substring(0, 10);
        }
        map.put("birthDate", birthDate);
        map.put("username", username);
        return "team_edit";
      } else {
        return "redirect:/error403/";
      }
    } else {
      return "redirect:/add";
    }
  }
Beispiel #2
0
  // view team by id
  @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  public String teamPage(Map<String, Object> map, @PathVariable("id") int id) {

    String username = userService.getCurrentUserName();
    Team team = teamService.getTeamById(id);
    map.put("needTeam", team);
    List<TeamInCompetition> teamInCompetitionList =
        teamInCompetitionService.getTeamInCompetitionListByTeamIdForCurrentYear(id);
    Map<TeamInCompetition, Boolean> isValidTeamInCompetitionMap =
        teamInCompetitionService.isValidTeamInCompetitionMap(teamInCompetitionList);
    map.put("isValidTeamInCompetitionMap", isValidTeamInCompetitionMap);
    map.put("username", username);
    map.put("authority", userService.getCurrentAuthority());
    return "team";
  }
Beispiel #3
0
 @RequestMapping(
     value = "/delete",
     method = RequestMethod.POST,
     headers = {"content-type=application/json"})
 public @ResponseBody String deleteTeam(@RequestBody Map<String, Object> map) {
   String username = userService.getCurrentUserName();
   Leader leader = leaderService.getLeaderByUserName(username);
   Team teamByLeader = teamService.getTeamByLeader(leader);
   Team team = teamService.getTeamById(Integer.parseInt(map.get("id").toString()));
   if (teamByLeader.getId() == team.getId()) {
     teamService.deleteTeam(team);
     return "success";
   } else {
     return "redirect:/error403/";
   }
 }