예제 #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
 @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/";
   }
 }
예제 #3
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();
 }