@RequestMapping( value = {"/updateapplication/{id}"}, method = {RequestMethod.POST}) public ModelAndView updateapplication( @PathVariable Long id, @ModelAttribute("application") Application application, Model model, BindingResult bindingResult, HttpSession session, Authentication auth) { ModelAndView mav = new ModelAndView(); Application application1 = mechanicService.getApplicationById(id); applicationValidator.validate(application, bindingResult); if (bindingResult.hasErrors()) { UserPrincipal user = userService.getUserByName(auth.getName()); Number size1 = directorService.getSizeMechanicOnSto(application1.getSto()); int size = Integer.parseInt(size1.toString()); mav.addObject("application", application1); mav.addObject("statuss", directorService.getStatus()); mav.addObject("mechanics", directorService.getMechanicsOnSto(application1.getSto(), 0, size)); mav.addObject("user", user); mav.setViewName("director.updateapplication"); return mav; } application1.setMechanic(application.getMechanic()); application1.setStatus(application.getStatus()); clientService.addOrUpdateApplication(application1); mav.setViewName("redirect:/home"); return mav; }
@PreAuthorize("isFullyAuthenticated()") @RequestMapping(value = "/mechaniclistbysto/{id}", method = RequestMethod.GET) public ModelAndView getmechaniclistbysto( @RequestParam(value = "page", required = false) Integer page, @PathVariable Long id, HttpSession session, Authentication auth) { ModelAndView mav = new ModelAndView(); UserPrincipal user = userService.getUserByName(auth.getName()); Sto sto = directorService.getStoById(id); Number size1 = directorService.getSizeMechanicOnSto(sto); int size = Integer.parseInt(size1.toString()); System.out.println("Test test test" + sto.getName()); if (page == null) page = 1; Integer pageSize = 3; Integer startPage = page; Integer endPage = page + 5; Integer lastPage = (size + (pageSize - 1)) / pageSize; if (endPage >= lastPage) endPage = lastPage; if (endPage >= 5 && (endPage - startPage) < 5) startPage = endPage - 5; mav.addObject("page", page); mav.addObject("startpage", startPage); mav.addObject("endpage", endPage); mav.addObject("user", user); mav.addObject( "mechanic", directorService.getMechanicsOnSto(sto, (page - 1) * pageSize, pageSize)); mav.setViewName("director.mechaniclistbysto"); return mav; };
@PreAuthorize("isFullyAuthenticated()") @RequestMapping(value = "/updateapplication/{id}", method = RequestMethod.GET) public ModelAndView updateapplication( @PathVariable Long id, HttpSession session, Authentication auth) { ModelAndView mav = new ModelAndView(); UserPrincipal user = userService.getUserByName(auth.getName()); Application application = mechanicService.getApplicationById(id); Number size1 = directorService.getSizeMechanicOnSto(application.getSto()); int size = Integer.parseInt(size1.toString()); mav.addObject("application", application); mav.addObject("statuss", directorService.getStatus()); mav.addObject("mechanics", directorService.getMechanicsOnSto(application.getSto(), 0, size)); mav.addObject("user", user); mav.setViewName("director.updateapplication"); return mav; };