@RequestMapping(value = "delete", method = RequestMethod.GET) public String delete( @ModelAttribute(value = "Schedule") Schedule schedule, @Context HttpServletRequest request) { int scheduleId = Integer.parseInt(request.getParameter("id")); scheduleService.delete(scheduleId); return "redirect:/admin/schedule"; }
@RequestMapping(method = RequestMethod.GET) public String index(ModelMap map, HttpServletRequest request) { String interviewer = null; if (request.getParameter("interviewer") != null && !request.getParameter("interviewer").equals("")) { interviewer = request.getParameter("interviewer"); } map.addAttribute("schedule", scheduleService.getScheduleWithApplicantAndRole(interviewer)); map.addAttribute("roles", roleService.getAll()); return "adminSchedule/index"; }
@RequestMapping(value = "edit", method = RequestMethod.GET) public ModelAndView edit( @ModelAttribute(value = "Schedule") Schedule schedule, @Context HttpServletRequest request) { ModelAndView mv = null; int id = Integer.parseInt(request.getParameter("id")); Schedule sch = scheduleService.getByScheduleId(id); if (sch != null) { mv = new ModelAndView("adminSchedule/edit"); mv.addObject("schedule", sch); mv.addObject("applicant", applicantService.getByApplicantId(sch.getApplicantId())); mv.addObject("applicants", applicantService.getAll()); mv.addObject("role", roleService.getByRoleId(sch.getInterviewer())); mv.addObject("roles", roleService.getAll()); } return mv; }
@RequestMapping(value = "save", method = RequestMethod.POST) public String save( @ModelAttribute(value = "Schedule") Schedule schedule, @Context HttpServletRequest request) throws ParseException { Calendar calendar = Calendar.getInstance(); schedule.setScheduleDate(calendar.getTime()); DateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd"); Date formatedDate = formatDate.parse(request.getParameter("schedule_date")); schedule.setScheduleDate(formatedDate); schedule.setScheduleTime(calendar.getTime()); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); Date SimpleDateFormat = sdf.parse(request.getParameter("schedule_time")); schedule.setScheduleTime(SimpleDateFormat); scheduleService.insert(schedule); return "redirect:/admin/schedule"; }
@RequestMapping(value = "detail/{id}", method = RequestMethod.GET) public ModelAndView detail(@PathVariable(value = "id") int id) { ModelAndView mv = new ModelAndView("adminSchedule/detail"); mv.addObject("sch", scheduleService.getByScheduleId(id)); return mv; }