123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- package com.example.nngkxxdp.controller;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.example.nngkxxdp.entity.Article;
- import com.example.nngkxxdp.service.ArticleService;
- import com.example.nngkxxdp.util.Blank;
- import com.example.nngkxxdp.util.ConstStr;
- import com.example.nngkxxdp.util.SendUtil;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import javax.annotation.Resource;
- import java.util.HashMap;
- import java.util.Map;
- /**
- * (Article)表控制层
- *
- * @author makejava
- * @since 2021-09-22 19:59:52
- */
- @RestController
- @RequestMapping("article")
- public class ArticleController {
- /**
- * 服务对象
- */
- @Resource
- private ArticleService articleService;
- /**
- * 通过主键查询单条数据
- *
- * @param id 主键
- * @return 单条数据
- */
- @GetMapping("selectOne")
- public Article selectOne(Integer id) {
- return this.articleService.queryById(id);
- }
- /**
- * 获取街道信息
- *
- * @param limit 页面大小
- * @param page 页数
- * @return
- */
- @GetMapping("getStreetDeptInfoAll")
- public Map<String, Object> getStreetDeptInfoAll(Integer limit, Integer page, Integer type) {
- if (Blank.isEmpty(limit, page, type)) {
- return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
- }
- // return articleService.getStreetInfoAll(limit, page, type);
- return articleService.getStreetInfoAllNew(limit, page, type);
- }
- /**
- * 获取新街道信息
- *
- * @param limit 页面大小
- * @param page 页数
- * @return
- */
- @GetMapping("getStreetInformation")
- public Map<String, Object> getStreetInformation(int limit, Integer page) {
- if (Blank.isEmpty(limit, page)) {
- return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
- }
- return articleService.getStreetInformation(limit, page);
- }
- /**
- * 获取公众号信息
- *
- * @return
- */
- @GetMapping("getAllOfficialAccount")
- public Map<String, Object> getAllOfficialAccount(String official) {
- return SendUtil.send(true, null, articleService.getAllOfficialAccount(official));
- }
- /**
- * 获取区县公众号信息
- *
- * @return
- */
- @GetMapping("getRegionAllOfficialAccount")
- public Map<String, Object> getRegionAllOfficialAccount(String official, Integer type) {
- return SendUtil.send(true, null, articleService.getRegionAllOfficialAccount(official, type));
- }
- @GetMapping("getOfficialAccountByPaging")
- public Map<String, Object> getOfficialAccountByPaging(String name, Integer page, Integer limit, String title) {
- if (Blank.isEmpty(limit, page) || page < 1 || limit < 1) {
- return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
- }
- Map<String, Object> map = new HashMap<>();
- map.put("name", name);
- map.put("title", title);
- map.put("page", (page - 1) * limit);
- map.put("limit", limit);
- // Map<String, Object> picture = articleService.getOfficialAccountByPaging(map);
- // for (int i=0;i<picture.size();i++){
- // System.out.println(i);
- // }
- // System.out.println();
- // JSONObject jsonObject=JSONObject.parseObject(picture.toString());
- return articleService.getOfficialAccountByPaging(map);
- }
- @GetMapping("getSortAticleByTitlePage")
- public Map<String, Object> getSortAticleByTitlePage(Integer page, Integer limit, String title) {
- if (Blank.isEmpty(limit, page) || page < 1 || limit < 1) {
- return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
- }
- Map<String, Object> map = new HashMap<>();
- map.put("title", title);
- map.put("page", (page - 1) * limit);
- map.put("limit", limit);
- return articleService.getSortAticleByTitlePage(map);
- }
- @GetMapping("getRegionOfficialAccountByPaging")
- public Map<String, Object> getRegionOfficialAccountByPaging(String name, Integer page, Integer limit) {
- if (Blank.isEmpty(limit, page)) {
- return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
- }
- Map<String, Object> map = new HashMap<>();
- map.put("name", name);
- map.put("page", (page - 1) * limit);
- map.put("limit", limit);
- return articleService.getRegionOfficialAccountByPaging(map);
- }
- /**
- * 获取小于当前日期南岸发布的wx文章
- *
- * @param date
- * @return
- */
- @GetMapping("getNAFBArticleByDate")
- public Map<String, Object> getNAFBArticleByDate(String date) {
- if (Blank.isEmpty(date)) {
- return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS, null);
- }
- return articleService.getNAFBArticleByDate(date);
- }
- @GetMapping("/publicRemind")
- public Map<String, Object> publicRemind() {
- return articleService.publicRemind();
- }
- @GetMapping("/getNewHlw")
- public Map<String, Object> getNewHlw() {
- try {
- return articleService.getNewHlw();
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
- /**
- * 分页查询华龙网接口数据
- *
- * @param page 当前页码
- * @param limit 每页展示条数
- * @param chnlid 栏目id
- * @param docTitle 栏目标题
- * @param docrelTime 发布时间
- * @param channelName 栏目名称
- * @param docpubUrl 文章链接
- * @param deptid 部门id
- * @return
- */
- @GetMapping("/getHlwAllDataPage")
- public Map<String, Object> getHlwAllData(int page, int limit, String chnlid, String docTitle, String docrelTime, String channelName, String docpubUrl, Integer deptid) {
- try {
- if (Blank.isNotEmpty(page) && Blank.isNotEmpty(limit) && page > 0 && limit > 0) {
- return articleService.getHlwAllDataPage(page, limit, chnlid, docTitle, docrelTime, channelName, docpubUrl, deptid);
- }
- return SendUtil.send(true, null, "page和limit不能为空,且要大于0");
- } catch (Exception e) {
- e.printStackTrace();
- }
- return SendUtil.send(false, ConstStr.DATA_NOT_FOUND);
- }
- }
|