HomeController.java 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package com.caimei.www.controller;
  2. import com.caimei.module.base.entity.bo.JsonModel;
  3. import com.caimei.www.pojo.HomeFloor;
  4. import com.caimei.www.service.HomeService;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.stereotype.Controller;
  7. import org.springframework.ui.Model;
  8. import org.springframework.web.bind.annotation.GetMapping;
  9. import org.springframework.web.bind.annotation.ResponseBody;
  10. import java.util.List;
  11. /**
  12. * Description
  13. *
  14. * @author : Charles
  15. * @date : 2020/6/15
  16. */
  17. @Controller
  18. public class HomeController extends BaseController {
  19. private static final String HOME_PATH = "index";
  20. private HomeService homeService;
  21. @Autowired
  22. public void setHomeService(HomeService homeService) {
  23. this.homeService = homeService;
  24. }
  25. /**
  26. * 首页页面路径
  27. * @param model
  28. * @return
  29. */
  30. @GetMapping("/index.html")
  31. public String home(final Model model) {
  32. model.addAttribute("msg", "首页");
  33. List<HomeFloor> pageFloors = homeService.getHomePageFloor();
  34. model.addAttribute("pageFloors", pageFloors);
  35. return HOME_PATH;
  36. }
  37. /**
  38. * 首页轮播图列表
  39. * @return
  40. */
  41. @GetMapping("/home/banner")
  42. @ResponseBody
  43. public JsonModel getHomeBanners() {
  44. return homeService.getHomeBanners();
  45. }
  46. /**
  47. * 首页左侧广告图
  48. * @return
  49. */
  50. @GetMapping("/home/advertising")
  51. @ResponseBody
  52. public JsonModel getAdvertising() {
  53. return homeService.getAdvertising();
  54. }
  55. /**
  56. * 首页推荐专区
  57. * @return
  58. */
  59. @GetMapping("/home/recommend")
  60. @ResponseBody
  61. public JsonModel getRecommendProducts() {
  62. return homeService.getRecommendProducts();
  63. }
  64. /**
  65. * 首页专题数据
  66. * @return
  67. */
  68. @GetMapping("/home/topic")
  69. @ResponseBody
  70. public JsonModel getHomeTopicData() {
  71. return homeService.getHomeTopicData();
  72. }
  73. /**
  74. * 顶部购物车数据
  75. * @return
  76. */
  77. @GetMapping("/header/cart")
  78. @ResponseBody
  79. public JsonModel getHeadCarts(Integer userId) {
  80. return homeService.getHeaderCart(userId);
  81. }
  82. }