首页>代码>基于SpringBoot的爱购商城>/day15_eshop/src/main/java/com/eshop/controller/admin/CarouselController.java
package com.eshop.controller.admin; import com.eshop.domain.Carousel; import com.eshop.service.CarouselService; import com.eshop.utils.PageModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @Controller @RequestMapping("/admin/carousel") public class CarouselController { @Autowired private CarouselService service; @RequestMapping("/list") public String list(@RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "5")Integer pageSize, Model model){ try { PageModel<Carousel> CarouselPages = service.queryCarouselPages(pageNo, pageSize); model.addAttribute("CarouselPages", CarouselPages); } catch (Exception e) { e.printStackTrace(); model.addAttribute("errMessage", "查询失败:"+e.getMessage()); return "500"; } return "admin/carousel/list"; } @RequestMapping("addPage") public String addPage(){ return "admin/carousel/add"; } @RequestMapping("/add") public String add(Carousel carousel, Model model){ try { int i = service.addCarousel(carousel); if (i==0){ model.addAttribute("errMessage","服务器繁忙操作失败"); return "500"; } }catch (Exception e){ model.addAttribute("errMessage",e.getMessage()); return "500"; } model.addAttribute("url", "admin/carousel/list"); return "success"; } @RequestMapping("updatePage") public String updatePage(String id,Model model){ Carousel carousel=service.queryCarouselById(id); model.addAttribute("carousel",carousel); return "admin/carousel/update"; } @RequestMapping("/update") public String update(Carousel carousel, Model model){ try { int i = service.updateCarousel(carousel); if (i==0){ model.addAttribute("errMessage","服务器繁忙操作失败"); return "500"; } }catch (Exception e){ model.addAttribute("errMessage",e.getMessage()); return "500"; } model.addAttribute("url", "admin/carousel/list"); return "success"; } @RequestMapping("deletePage") public String deletePage(String id,Model model){ model.addAttribute("id",id); return "admin/carousel/delete"; } @RequestMapping("/delete") public String delete(String id, Model model){ try { int i = service.delete(id); if (i==0){ model.addAttribute("errMessage","服务器繁忙操作失败"); return "500"; } }catch (Exception e){ model.addAttribute("errMessage",e.getMessage()); return "500"; } model.addAttribute("url", "admin/carousel/list"); return "success"; } }
最近下载更多
yvimib LV2
10月26日
微信网友_6786215447367680 LV5
10月8日
TY0165 LV20
6月22日
A1314521anna LV1
5月18日
qtingchh LV3
5月3日
微信网友_6971776760270848 LV2
4月29日
zolscy LV12
3月24日
chenglei1314 LV6
3月12日
刘自盛 LV2
3月1日
xshxxm1 LV21
1月11日