SinglePageController.java 4.5 KB

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