@RequestMapping("/ad-editLocation/{id}") public String getEditLocation(Model model, @PathVariable("id") int id) { model.addAttribute("location", locationService.findOne(id)); return "ad-editLocation"; }
@RequestMapping("/ad-searchLocation") public String getSearchLocation( Model model, @RequestParam(value = "pageNumber", defaultValue = "0") int pageNumber) { model.addAttribute("startPage", 1); model.addAttribute( "endPage", locationService .findAll(new PageRequest(pageNumber, 10, Direction.ASC, "name")) .getTotalPages()); model.addAttribute("currentPage", pageNumber); model.addAttribute( "locations", locationService .findAll(new PageRequest(pageNumber, 10, Direction.ASC, "name")) .getContent()); return "ad-searchLocation"; }
@RequestMapping(value = "/ad-editLocation/{id}", method = RequestMethod.POST) public String postEditLocation( @ModelAttribute("location") Location location, @PathVariable("id") int id, @RequestParam(value = "attachFile", required = false) List<CommonsMultipartFile> attachFile) { if (attachFile != null) { if (attachFile.isEmpty()) { } else { location.setGallery(imageCompressor.compress(attachFile, 800, 1000, true)); } } locationService.save(location); return "redirect:/ad-searchLocation?editSuccess=true"; }
@RequestMapping(value = "/ad-addLocation", method = RequestMethod.POST) public String postAddLocation( @ModelAttribute("location") Location location, @RequestParam(value = "attachFile", required = false) List<CommonsMultipartFile> attachFile) { if (attachFile != null) { if (attachFile.isEmpty()) { } else { location.setGallery(imageCompressor.compress(attachFile, 800, 1000, true)); } } System.out.println(location.getAddress()); locationService.save(location); return "redirect:/ad-searchLocation?addSuccess=true"; }
@RequestMapping("/ad-deleteLocation/{id}") public String getDeleteLocation(@PathVariable("id") int id) { locationService.delete(id); return "redirect:/ad-searchLocation?deleteSuccess=true"; }