Exemplo n.º 1
0
  @RequestMapping(value = "/leavepolicy", method = RequestMethod.GET)
  public String list(Model model) {
    Set<LeavePolicy> holidays = service.findAll();
    String jsonData = "";
    try {
      jsonData = mapper.writeValueAsString(holidays);
    } catch (Exception e) {
      e.printStackTrace();
    }

    model.addAttribute("leavePolicyJsonData", jsonData);
    return "leavepolicy/list";
  }
Exemplo n.º 2
0
 @RequestMapping(value = "/leavepolicy/admin/create", method = RequestMethod.POST)
 public String create(LeavePolicy leavePolicy, BindingResult result) {
   if (result.hasErrors()) {
     return "leavepolicy/create";
   }
   leavePolicy = service.create(leavePolicy);
   Set<User> userList = userService.findAll();
   for (User user : userList) {
     UserLeavePolicy ulp = new UserLeavePolicy();
     ulp.setUser(user);
     ulp.setLeavePolicy(leavePolicy);
     ulpService.create(ulp);
   }
   return "redirect:/leavepolicy";
 }