Ejemplo n.º 1
0
  @RequestMapping("/ad-editLocation/{id}")
  public String getEditLocation(Model model, @PathVariable("id") int id) {

    model.addAttribute("location", locationService.findOne(id));

    return "ad-editLocation";
  }
Ejemplo n.º 2
0
  @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";
  }
Ejemplo n.º 3
0
  @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";
  }
Ejemplo n.º 4
0
  @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";
  }
Ejemplo n.º 5
0
 @RequestMapping("/ad-deleteLocation/{id}")
 public String getDeleteLocation(@PathVariable("id") int id) {
   locationService.delete(id);
   return "redirect:/ad-searchLocation?deleteSuccess=true";
 }