FrontNewsController.java 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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("getMainCourseDateNoToken")
  79. @ApiOperation("00 考试日程免登陆")
  80. public TableDataInfo getMainCourseDateNoToken() {
  81. return getMainCourseDate();
  82. }
  83. @GetMapping("getMainCourseDate")
  84. @ApiOperation("00 考试日程")
  85. public TableDataInfo getMainCourseDate() {
  86. String arrString = sysConfigService.selectConfigByKey("main.course.date");
  87. if (StringUtils.isBlank(arrString)){
  88. 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\": \"\" } ]";
  89. }
  90. return getDataTable(JSONObject.parseArray(arrString));
  91. }
  92. @GetMapping("list")
  93. @ApiOperation("01 资讯列表")
  94. public TableDataInfo list(@ApiParam(value = "分类 ", example = "1") String type,Boolean top,String ids,
  95. @ApiParam(value = "标签", example = "hot") String tag,String title,
  96. @ApiParam(value = "省份 ", example = "湖南") @RequestParam(required = false) String location,
  97. @ApiParam(value = "页数", example = "1") @RequestParam Integer pageNum,
  98. @ApiParam(value = "页大小", example = "15") @RequestParam Integer pageSize) {
  99. return llist(ids,top,type,tag,title,commService.getLocation(location), pageNum,pageSize);
  100. }
  101. private TableDataInfo llist(String ids,Boolean top,String type, String tag,String title,String location, Integer pageNum,Integer pageSize){
  102. BWwwNews exam = new BWwwNews();
  103. exam.setIsTop(null==top?null:(top?1:0));
  104. exam.setType(type);
  105. exam.setTitle(title);
  106. exam.setTag(StringUtils.trimToNull(tag));
  107. exam.setLocation(commService.getLocation(location));
  108. if(StringUtils.isNotBlank(ids)){
  109. String[] strArray = ids.split(",");
  110. List<String> strList = new ArrayList<>(strArray.length);
  111. Collections.addAll(strList, strArray);
  112. exam.setIds(strList);
  113. }
  114. startPage();
  115. List<BWwwNews> arr = newsService.selectBWwwNewsList(exam);
  116. return getDataTable(arr);
  117. }
  118. @GetMapping("listNoToken")
  119. @ApiOperation("01-2 资讯列表")
  120. public TableDataInfo listNoToken(@ApiParam(value = "分类 ", example = "1") String type,Boolean top,String ids,
  121. @ApiParam(value = "标签", example = "hot") String tag,String title,
  122. @ApiParam(value = "省份 ", example = "湖南") @RequestParam(required = false) String location,
  123. @ApiParam(value = "页数", example = "1") Integer pageNum,
  124. @ApiParam(value = "页大小", example = "15") Integer pageSize) {
  125. return llist(ids,top,type,tag,title,commService.getLocation(location), pageNum,pageSize);
  126. }
  127. @GetMapping("info")
  128. @ApiOperation("02 资讯详情")
  129. @Anonymous
  130. public AjaxResult videoInfo(@ApiParam("课程id") Long id) {
  131. saveClicked(id);
  132. BWwwNews info = newsService.selectBWwwNewsById(id);
  133. return AjaxResult.success(info);
  134. }
  135. // @GetMapping("saveClicked")
  136. // @ApiOperation("03 保存点击数")
  137. public AjaxResult saveClicked( Long id) {
  138. BWwwNews info = newsService.selectBWwwNewsById(id);
  139. Long clicked= null==info.getClicked()?1L:(info.getClicked()+1);
  140. info.setClicked(clicked);
  141. newsService.updateBWwwNews(info);
  142. return AjaxResult.success(clicked);
  143. }
  144. }