FrontNewsController.java 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. package com.ruoyi.web.controller.front;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.ruoyi.common.annotation.Anonymous;
  4. import com.ruoyi.common.core.content.VistorContextHolder;
  5. import com.ruoyi.common.core.controller.BaseController;
  6. import com.ruoyi.common.core.domain.AjaxResult;
  7. import com.ruoyi.common.core.domain.entity.SysDictData;
  8. import com.ruoyi.common.core.page.TableDataInfo;
  9. import com.ruoyi.common.utils.SecurityUtils;
  10. import com.ruoyi.system.service.ISysConfigService;
  11. import com.ruoyi.system.service.ISysDictDataService;
  12. import com.ruoyi.syzy.domain.BWwwNews;
  13. import com.ruoyi.syzy.domain.BWwwNewsRef;
  14. import com.ruoyi.syzy.service.IBWwwNewsRefService;
  15. import com.ruoyi.syzy.service.IBWwwNewsService;
  16. import com.ruoyi.web.service.CommService;
  17. import io.swagger.annotations.Api;
  18. import io.swagger.annotations.ApiOperation;
  19. import io.swagger.annotations.ApiParam;
  20. import org.apache.commons.lang3.StringUtils;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.web.bind.annotation.GetMapping;
  23. import org.springframework.web.bind.annotation.RequestMapping;
  24. import org.springframework.web.bind.annotation.RequestParam;
  25. import org.springframework.web.bind.annotation.RestController;
  26. import java.util.ArrayList;
  27. import java.util.Collections;
  28. import java.util.List;
  29. @RestController
  30. @Api(tags = "资讯-高考")
  31. @RequestMapping("front/news/")
  32. public class FrontNewsController extends BaseController {
  33. @Autowired
  34. private IBWwwNewsService newsService;
  35. @Autowired
  36. private IBWwwNewsRefService newsRefService;
  37. @Autowired
  38. private ISysDictDataService dictDataService;
  39. @Autowired
  40. private ISysConfigService sysConfigService;
  41. @Autowired
  42. private CommService commService;
  43. @GetMapping("types")
  44. @ApiOperation("00 高考资讯类型")
  45. public TableDataInfo types() {
  46. return getTypes();
  47. }
  48. private TableDataInfo getTypes(){
  49. List<SysDictData> arr = dictDataService.selectDictDataByType("news_type");
  50. List<JSONObject> list = new ArrayList<JSONObject>(arr.size());
  51. arr.forEach(row -> {
  52. JSONObject item = new JSONObject(true);
  53. item.put("value", row.getDictValue());
  54. item.put("label", row.getDictLabel());
  55. list.add(item);
  56. });
  57. return getDataTable(list);
  58. }
  59. @GetMapping("typesNoToken")
  60. @ApiOperation("00-1 高考资讯类型")
  61. public TableDataInfo typesNoToken() {
  62. return getTypes();
  63. }
  64. @GetMapping("getMainList")
  65. @ApiOperation("00 通关指南")
  66. public TableDataInfo getMainList(@ApiParam(value = "省份 ", example = "湖南") @RequestParam(required = false) String location) {
  67. BWwwNewsRef cond = new BWwwNewsRef();
  68. cond.setLocation(commService.getLocation(location));
  69. return getDataTable(newsRefService.selectBWwwNewsRefList(cond));
  70. }
  71. @GetMapping("getMainListNoToken")
  72. @ApiOperation("00 通关指南免登陆")
  73. public TableDataInfo getMainListNoToken(@ApiParam(value = "省份 ", example = "湖南") @RequestParam(required = false) String location) {
  74. BWwwNewsRef cond = new BWwwNewsRef();
  75. cond.setLocation(commService.getLocation(location));
  76. return getDataTable(newsRefService.selectBWwwNewsRefList(cond));
  77. }
  78. @GetMapping("getMainListV2")
  79. @ApiOperation("00 通关指南免登陆")
  80. @Anonymous
  81. public TableDataInfo getMainListV2() {
  82. BWwwNewsRef cond = new BWwwNewsRef();
  83. cond.setLocation(commService.getLocation(null));
  84. cond.setSubType("官方公告");
  85. List<BWwwNewsRef> list = newsRefService.selectBWwwNewsRefList(cond);
  86. return getDataTable(list);
  87. }
  88. @GetMapping("getMainCourseDateNoToken")
  89. @ApiOperation("00 考试日程免登陆")
  90. public TableDataInfo getMainCourseDateNoToken() {
  91. return getMainCourseDate();
  92. }
  93. @GetMapping("getMainCourseDate")
  94. @ApiOperation("00 考试日程")
  95. public TableDataInfo getMainCourseDate() {
  96. String arrString = sysConfigService.selectConfigByKey("main.course.date");
  97. if (StringUtils.isBlank(arrString)){
  98. arrString= "[ { \"title\": \"高考报名\", \"time\": \"2023年10月底\", \"fireTime\": \"2023-10-01\", \"sort\": 1, \"description\": \"\" }, { \"title\": \"院校发布招生简章\", \"time\": \"2024年1月初\", \"fireTime\": \"2024-02-01\", \"sort\": 2, \"description\": \"\" }, { \"title\": \"报考及填报志愿\", \"time\": \"2月27~3月5日\", \"fireTime\": \"2024-02-27\", \"sort\": 3, \"description\": \"登录湖南省普通高校招生考试考生综合信息平台或潇湘高考APP,可填报1-2所院校\" }, { \"title\": \"第一志愿考试\", \"time\": \"3月16~17日\", \"fireTime\": \"2024-03-16\", \"sort\": 4, \"description\": \"\" }, { \"title\": \"第一志愿录取\", \"time\": \"3月中下旬\", \"fireTime\": \"2024-03-16\", \"sort\": 5, \"description\": \"\" }, { \"title\": \"第二志愿考试\", \"time\": \"4月13~14日\", \"fireTime\": \"2024-04-13\", \"sort\": 6, \"description\": \"\" }, { \"title\": \"第二志愿录取\", \"time\": \"4月中下旬\", \"fireTime\": \"2024-04-15\", \"sort\": 7, \"description\": \"\" } ]";
  99. }
  100. return getDataTable(JSONObject.parseArray(arrString));
  101. }
  102. @GetMapping("list")
  103. @ApiOperation("01 资讯列表")
  104. public TableDataInfo list(@ApiParam(value = "分类 ", example = "1") String type,Boolean top,String ids,
  105. @ApiParam(value = "标签", example = "hot") String tag,String title,
  106. @ApiParam(value = "省份 ", example = "湖南") @RequestParam(required = false) String location,
  107. @ApiParam(value = "页数", example = "1") @RequestParam Integer pageNum,
  108. @ApiParam(value = "页大小", example = "15") @RequestParam Integer pageSize) {
  109. return llist(ids,top,type,tag,title,commService.getLocation(location), pageNum,pageSize);
  110. }
  111. private TableDataInfo llist(String ids,Boolean top,String type, String tag,String title,String location, Integer pageNum,Integer pageSize){
  112. BWwwNews exam = new BWwwNews();
  113. exam.setIsTop(null==top?null:(top?1:0));
  114. exam.setType(type);
  115. exam.setTitle(title);
  116. exam.setTag(StringUtils.trimToNull(tag));
  117. exam.setLocation(commService.getLocation(location));
  118. if(StringUtils.isNotBlank(ids)){
  119. String[] strArray = ids.split(",");
  120. List<String> strList = new ArrayList<>(strArray.length);
  121. Collections.addAll(strList, strArray);
  122. exam.setIds(strList);
  123. }
  124. startPage();
  125. List<BWwwNews> arr = newsService.selectBWwwNewsList(exam);
  126. return getDataTable(arr);
  127. }
  128. @GetMapping("listNoToken")
  129. @ApiOperation("01-2 资讯列表")
  130. public TableDataInfo listNoToken(@ApiParam(value = "分类 ", example = "1") String type,Boolean top,String ids,
  131. @ApiParam(value = "标签", example = "hot") String tag,String title,
  132. @ApiParam(value = "省份 ", example = "湖南") @RequestParam(required = false) String location,
  133. @ApiParam(value = "页数", example = "1") Integer pageNum,
  134. @ApiParam(value = "页大小", example = "15") Integer pageSize) {
  135. return llist(ids,top,type,tag,title,commService.getLocation(location), pageNum,pageSize);
  136. }
  137. @GetMapping("info")
  138. @ApiOperation("02 资讯详情")
  139. @Anonymous
  140. public AjaxResult videoInfo(@ApiParam("课程id") Long id) {
  141. saveClicked(id);
  142. BWwwNews info = newsService.selectBWwwNewsById(id);
  143. return AjaxResult.success(info);
  144. }
  145. // @GetMapping("saveClicked")
  146. // @ApiOperation("03 保存点击数")
  147. public AjaxResult saveClicked( Long id) {
  148. BWwwNews info = newsService.selectBWwwNewsById(id);
  149. Long clicked= null==info.getClicked()?1L:(info.getClicked()+1);
  150. info.setClicked(clicked);
  151. newsService.updateBWwwNews(info);
  152. return AjaxResult.success(clicked);
  153. }
  154. }