예제 #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";
    }
  }
예제 #2
0
 // edit team worker
 @RequestMapping(
     value = "/editTeam",
     method = RequestMethod.POST,
     headers = {"content-type=application/json"})
 public @ResponseBody int editTeam(@RequestBody Map<String, Object> formMap) {
   String username = userService.getCurrentUserName();
   Leader leader = leaderService.getLeaderByUserName(username);
   Team team = teamService.getTeamByLeader(leader);
   team.setName(formMap.get("team_name").toString());
   team.setAddress(formMap.get("address").toString());
   team.setLicense(formMap.get("license").toString());
   teamService.updateTeam(team);
   return team.getId();
 }
예제 #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/";
   }
 }
예제 #4
0
 @RequestMapping(
     value = "/isSetTeam",
     method = RequestMethod.POST,
     headers = {"content-type=application/json"})
 public @ResponseBody boolean isSetTeam(@RequestBody Map<String, Object> map) {
   String team_name = map.get("team_name").toString();
   return teamService.isSetTeam(team_name);
 }
예제 #5
0
  // add team page
  @RequestMapping(value = "/add", method = RequestMethod.GET)
  public String addTeamPage(Map<String, Object> map) {

    Leader leader = leaderService.getLeaderByUserName(userService.getCurrentUserName());
    if (teamService.isTeamByLeaderId(leader.getId()) == false) {
      map.put("username", userService.getCurrentUserName());
      map.put("authority", userService.getCurrentAuthority());
      return "team_add";
    }
    return "index";
  }
예제 #6
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";
  }
예제 #7
0
 @RequestMapping(value = "/list", method = RequestMethod.GET)
 public String teamsListPage(Map<String, Object> map) {
   map.put("teamList", teamService.getAllTeams());
   return "teams";
 }