Esempio n. 1
0
  @RequestMapping("/edit")
  public String edit(
      @RequestParam(required = false) Long id,
      @ModelAttribute Ad ad,
      HttpServletRequest request,
      HttpServletResponse response,
      Model model) {
    if (id == null) {
      Object obj = getSessionAttribute(request, "AdWidget_edit_id");
      if (obj != null) {
        id = (Long) obj;
      }
    }
    if (id == null) {
      return prompt(model, "请先选择要修改的广告");
    }

    ad = adService.getAdById(id);
    if (ad == null) {
      return prompt(model, "请先选择要修改的广告");
    }
    model.addAttribute("ad", ad);
    setSessionAttribute(request, "AdWidget_edit_id", id);
    return "/admin/ad/editAd";
  }
Esempio n. 2
0
 @RequestMapping("/edit/save")
 @Log
 public String edit_save(
     @ModelAttribute Ad ad,
     HttpServletRequest request,
     HttpServletResponse response,
     Model model) {
   adService.updateAd(ad);
   return "redirect:/admin/ad/list";
 }
Esempio n. 3
0
 @RequestMapping("/delete")
 @Log
 public String delete(
     @RequestParam(required = false) Long[] id,
     @ModelAttribute Page<Ad> adPage,
     @ModelAttribute Ad ad,
     @QueryParam Map queryParams,
     HttpServletRequest request,
     HttpServletResponse response,
     Model model) {
   adService.deleteAd(id);
   return list(adPage, ad, queryParams, request, response, model);
 }
Esempio n. 4
0
 @SuppressWarnings("rawtypes")
 @RequestMapping("/list")
 @Log
 public String list(
     @ModelAttribute Page<Ad> adPage,
     @ModelAttribute Ad ad,
     @QueryParam Map queryParams,
     HttpServletRequest request,
     HttpServletResponse response,
     Model model) {
   if (adPage == null) {
     adPage = new Page<Ad>();
   }
   adPage.setSort(new Sort("id", Sort.DESC));
   adPage = adService.findAdPage(new AdQueryCriterion(queryParams), adPage);
   model.addAttribute("adPage", adPage);
   return "/admin/ad/listAd";
 }