ArticleController.java 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. package com.example.nngkxxdp.controller;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.example.nngkxxdp.entity.Article;
  5. import com.example.nngkxxdp.service.ArticleService;
  6. import com.example.nngkxxdp.util.Blank;
  7. import com.example.nngkxxdp.util.ConstStr;
  8. import com.example.nngkxxdp.util.SendUtil;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.RestController;
  12. import javax.annotation.Resource;
  13. import java.util.HashMap;
  14. import java.util.Map;
  15. /**
  16. * (Article)表控制层
  17. *
  18. * @author makejava
  19. * @since 2021-09-22 19:59:52
  20. */
  21. @RestController
  22. @RequestMapping("article")
  23. public class ArticleController {
  24. /**
  25. * 服务对象
  26. */
  27. @Resource
  28. private ArticleService articleService;
  29. /**
  30. * 通过主键查询单条数据
  31. *
  32. * @param id 主键
  33. * @return 单条数据
  34. */
  35. @GetMapping("selectOne")
  36. public Article selectOne(Integer id) {
  37. return this.articleService.queryById(id);
  38. }
  39. /**
  40. * 获取街道信息
  41. *
  42. * @param limit 页面大小
  43. * @param page 页数
  44. * @return
  45. */
  46. @GetMapping("getStreetDeptInfoAll")
  47. public Map<String, Object> getStreetDeptInfoAll(Integer limit, Integer page, Integer type) {
  48. if (Blank.isEmpty(limit, page, type)) {
  49. return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
  50. }
  51. // return articleService.getStreetInfoAll(limit, page, type);
  52. return articleService.getStreetInfoAllNew(limit, page, type);
  53. }
  54. /**
  55. * 获取新街道信息
  56. *
  57. * @param limit 页面大小
  58. * @param page 页数
  59. * @return
  60. */
  61. @GetMapping("getStreetInformation")
  62. public Map<String, Object> getStreetInformation(int limit, Integer page) {
  63. if (Blank.isEmpty(limit, page)) {
  64. return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
  65. }
  66. return articleService.getStreetInformation(limit, page);
  67. }
  68. /**
  69. * 获取公众号信息
  70. *
  71. * @return
  72. */
  73. @GetMapping("getAllOfficialAccount")
  74. public Map<String, Object> getAllOfficialAccount(String official) {
  75. return SendUtil.send(true, null, articleService.getAllOfficialAccount(official));
  76. }
  77. /**
  78. * 获取区县公众号信息
  79. *
  80. * @return
  81. */
  82. @GetMapping("getRegionAllOfficialAccount")
  83. public Map<String, Object> getRegionAllOfficialAccount(String official, Integer type) {
  84. return SendUtil.send(true, null, articleService.getRegionAllOfficialAccount(official, type));
  85. }
  86. @GetMapping("getOfficialAccountByPaging")
  87. public Map<String, Object> getOfficialAccountByPaging(String name, Integer page, Integer limit, String title) {
  88. if (Blank.isEmpty(limit, page) || page < 1 || limit < 1) {
  89. return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
  90. }
  91. Map<String, Object> map = new HashMap<>();
  92. map.put("name", name);
  93. map.put("title", title);
  94. map.put("page", (page - 1) * limit);
  95. map.put("limit", limit);
  96. // Map<String, Object> picture = articleService.getOfficialAccountByPaging(map);
  97. // for (int i=0;i<picture.size();i++){
  98. // System.out.println(i);
  99. // }
  100. // System.out.println();
  101. // JSONObject jsonObject=JSONObject.parseObject(picture.toString());
  102. return articleService.getOfficialAccountByPaging(map);
  103. }
  104. @GetMapping("getSortAticleByTitlePage")
  105. public Map<String, Object> getSortAticleByTitlePage(Integer page, Integer limit, String title) {
  106. if (Blank.isEmpty(limit, page) || page < 1 || limit < 1) {
  107. return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
  108. }
  109. Map<String, Object> map = new HashMap<>();
  110. map.put("title", title);
  111. map.put("page", (page - 1) * limit);
  112. map.put("limit", limit);
  113. return articleService.getSortAticleByTitlePage(map);
  114. }
  115. @GetMapping("getRegionOfficialAccountByPaging")
  116. public Map<String, Object> getRegionOfficialAccountByPaging(String name, Integer page, Integer limit) {
  117. if (Blank.isEmpty(limit, page)) {
  118. return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
  119. }
  120. Map<String, Object> map = new HashMap<>();
  121. map.put("name", name);
  122. map.put("page", (page - 1) * limit);
  123. map.put("limit", limit);
  124. return articleService.getRegionOfficialAccountByPaging(map);
  125. }
  126. /**
  127. * 获取小于当前日期南岸发布的wx文章
  128. *
  129. * @param date
  130. * @return
  131. */
  132. @GetMapping("getNAFBArticleByDate")
  133. public Map<String, Object> getNAFBArticleByDate(String date) {
  134. if (Blank.isEmpty(date)) {
  135. return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS, null);
  136. }
  137. return articleService.getNAFBArticleByDate(date);
  138. }
  139. @GetMapping("/publicRemind")
  140. public Map<String, Object> publicRemind() {
  141. return articleService.publicRemind();
  142. }
  143. @GetMapping("/getNewHlw")
  144. public Map<String, Object> getNewHlw() {
  145. try {
  146. return articleService.getNewHlw();
  147. } catch (Exception e) {
  148. e.printStackTrace();
  149. }
  150. return null;
  151. }
  152. /**
  153. * 分页查询华龙网接口数据
  154. *
  155. * @param page 当前页码
  156. * @param limit 每页展示条数
  157. * @param chnlid 栏目id
  158. * @param docTitle 栏目标题
  159. * @param docrelTime 发布时间
  160. * @param channelName 栏目名称
  161. * @param docpubUrl 文章链接
  162. * @param deptid 部门id
  163. * @return
  164. */
  165. @GetMapping("/getHlwAllDataPage")
  166. public Map<String, Object> getHlwAllData(int page, int limit, String chnlid, String docTitle, String docrelTime, String channelName, String docpubUrl, Integer deptid) {
  167. try {
  168. if (Blank.isNotEmpty(page) && Blank.isNotEmpty(limit) && page > 0 && limit > 0) {
  169. return articleService.getHlwAllDataPage(page, limit, chnlid, docTitle, docrelTime, channelName, docpubUrl, deptid);
  170. }
  171. return SendUtil.send(true, null, "page和limit不能为空,且要大于0");
  172. } catch (Exception e) {
  173. e.printStackTrace();
  174. }
  175. return SendUtil.send(false, ConstStr.DATA_NOT_FOUND);
  176. }
  177. }