SinglePageController.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package com.caimei.www.controller.unlimited;
  2. import com.caimei.www.controller.BaseController;
  3. import com.caimei.www.pojo.JsonModel;
  4. import com.caimei.www.pojo.page.ImageLink;
  5. import com.caimei.www.pojo.page.PageContent;
  6. import com.caimei.www.pojo.page.PageFloor;
  7. import com.caimei.www.service.SinglePageService;
  8. import com.github.pagehelper.PageInfo;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.http.server.reactive.ServerHttpResponse;
  11. import org.springframework.stereotype.Controller;
  12. import org.springframework.ui.Model;
  13. import org.springframework.web.bind.annotation.GetMapping;
  14. import org.springframework.web.bind.annotation.RequestParam;
  15. import org.springframework.web.bind.annotation.ResponseBody;
  16. import reactor.core.publisher.Mono;
  17. import java.io.FileNotFoundException;
  18. import java.io.UnsupportedEncodingException;
  19. import java.util.List;
  20. /**
  21. * 二级页面
  22. *
  23. * @author : Charles
  24. * @date : 2020/7/20
  25. */
  26. @Controller
  27. public class SinglePageController extends BaseController {
  28. /** 找产品/找仪器/找项目 */
  29. private static final String TOPIC_PATH = "single-page/topic";
  30. /** 专题活动列表页 */
  31. private static final String PROMOTIONS_PATH = "single-page/promotions";
  32. /** 自由页面 */
  33. private static final String FREE_PAGE_PATH = "single-page/page";
  34. /** 采美直播页面 */
  35. private static final String LIVE_PATH = "single-page/live";
  36. /** 品牌招商介绍页 */
  37. private static final String INVESTMENT_PATH = "single-page/investment";
  38. private SinglePageService singlePageService;
  39. @Autowired
  40. public void setSinglePageService(SinglePageService singlePageService) {
  41. this.singlePageService = singlePageService;
  42. }
  43. /**
  44. * 二级页面(找产品/找仪器/找项目/正品联盟)
  45. */
  46. @GetMapping("/topic.html")
  47. public String topic(final Model model, @RequestParam("type") Integer id) {
  48. PageContent topicPage = singlePageService.getTopicPageById(id);
  49. if (topicPage == null){
  50. return super.getErrorPath();
  51. }
  52. model.addAttribute("pageData", topicPage);
  53. return TOPIC_PATH;
  54. }
  55. /**
  56. * 专题活动列表页
  57. */
  58. @GetMapping("/promotions.html")
  59. public String promotions() {
  60. return PROMOTIONS_PATH;
  61. }
  62. /**
  63. * 自由页面
  64. */
  65. @GetMapping("/page.html")
  66. public String freePage(final Model model, Integer id) {
  67. PageContent freePage = singlePageService.getFreePageById(id);
  68. if (freePage == null){
  69. return super.getErrorPath();
  70. }
  71. model.addAttribute("pageData", freePage);
  72. return FREE_PAGE_PATH;
  73. }
  74. /**
  75. * 采美直播页面
  76. */
  77. @GetMapping("/live.html")
  78. public String livePage(final Model model) {
  79. PageContent livePage = singlePageService.getLivePageData();
  80. if (livePage == null){
  81. return super.getErrorPath();
  82. }
  83. model.addAttribute("pageData", livePage);
  84. return LIVE_PATH;
  85. }
  86. /**
  87. * 品牌招商介绍页
  88. */
  89. @GetMapping("/investment.html")
  90. public String investment(final Model model) {
  91. return INVESTMENT_PATH;
  92. }
  93. /**
  94. * 二级专题数据
  95. * @return
  96. */
  97. @GetMapping("/page/topic")
  98. @ResponseBody
  99. public JsonModel<List<PageFloor>> getTopicDataById(@RequestParam("type") Integer id) {
  100. return singlePageService.getTopicDataById(id);
  101. }
  102. /**
  103. * 专题活动列表数据
  104. * @return
  105. */
  106. @GetMapping("/promotions/list")
  107. @ResponseBody
  108. public JsonModel<PageInfo<ImageLink>> gePromotionsList(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
  109. return singlePageService.gePromotionsList(pageNum, pageSize);
  110. }
  111. /**
  112. * 品牌招商表格下载
  113. */
  114. @GetMapping("/investment/export")
  115. @ResponseBody
  116. public Mono<Void> downloadByWriteWith(ServerHttpResponse response) throws UnsupportedEncodingException, FileNotFoundException {
  117. return singlePageService.downloadByWriteWith(response);
  118. }
  119. /**
  120. * 获取讲师列表
  121. */
  122. @GetMapping("/live/teacher")
  123. @ResponseBody
  124. public JsonModel<List<ImageLink>> getLiveTeachers() {
  125. return singlePageService.getLiveTeachers();
  126. }
  127. }