ws 3 年 前
コミット
27faee1828

+ 23 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/controller/ArticleController.java

@@ -10,6 +10,8 @@ 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;
 
 /**
@@ -52,5 +54,26 @@ public class ArticleController {
         }
         return articleService.getStreetInfoAll(limit, page, type);
     }
+    
+    /**
+     * 获取公众号信息
+     * @return
+     */
+    @GetMapping("getAllOfficialAccount")
+    public Map<String, Object> getAllOfficialAccount() {
+    	return SendUtil.send(true, null, articleService.getAllOfficialAccount());
+    }
+    
+    @GetMapping("getOffocoalAccountByPaging")
+    public Map<String, Object> getOffocoalAccountByPaging(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.getOffocoalAccountByPaging(map);
+    }
 
 }

+ 6 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/dao/SmsMessageDao.java

@@ -39,4 +39,10 @@ public interface SmsMessageDao {
 	Integer getCountWechatSmsDetail(@Param("id") Integer id);
 	
 	List<Map<String, Object>> getWechatSmsDetail(@Param("page") Integer page, @Param("limit") Integer limit, @Param("id") Integer id);
+	
+	List<Map<String, Object>> getAllOfaList(@Param("num") Integer num);
+	
+	Integer getCountOffocoalAccount(Map<String, Object> map);
+	
+	List<Map<String, Object>> getOffocoalAccountByPaging(Map<String, Object> map);
 }

+ 8 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/service/ArticleService.java

@@ -133,4 +133,12 @@ public interface ArticleService {
 	 * @return
 	 */
     Map<String, Object> getNewestOrHotArticle(Integer articleType);
+    
+    /**
+     * 获取公众号信息
+     * @return
+     */
+    Map<String, Object> getAllOfficialAccount();
+    
+    Map<String, Object> getOffocoalAccountByPaging(Map<String, Object> map);
 }

+ 49 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/service/impl/ArticleServiceImpl.java

@@ -1,5 +1,6 @@
 package com.example.nngkxxdp.service.impl;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -10,6 +11,7 @@ import org.springframework.stereotype.Service;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.example.nngkxxdp.dao.ArticleDao;
+import com.example.nngkxxdp.dao.SmsMessageDao;
 import com.example.nngkxxdp.entity.Article;
 import com.example.nngkxxdp.service.ArticleService;
 import com.example.nngkxxdp.util.Blank;
@@ -25,6 +27,9 @@ import com.example.nngkxxdp.util.SendUtil;
 public class ArticleServiceImpl implements ArticleService {
 	@Resource
 	private ArticleDao articleDao;
+	
+	@Resource
+	private SmsMessageDao smsMessageDao;
 
 	/**
 	 * 通过ID查询单条数据
@@ -280,4 +285,48 @@ public class ArticleServiceImpl implements ArticleService {
 
 		return SendUtil.send(true, "", articleDao.getNewestOrHotArticle(articleType));
 	}
+
+	@Override
+	public Map<String, Object> getAllOfficialAccount() {
+		Integer num = 8;
+		List<Map<String, Object>> ofaList = smsMessageDao.getAllOfa();
+		List<Map<String, Object>> list = smsMessageDao.getAllOfaList(num);
+		JSONObject obj = new JSONObject();
+		JSONArray array;
+		if (Blank.notBlank(list)) {
+			for (Map<String, Object> map : list) {
+				String name = String.valueOf(map.get("officialAccount"));
+				if (Blank.isEmpty(obj.get(name))) {
+					array = new JSONArray();
+				} else {
+					array = obj.getJSONArray(name);
+				}
+				if (array.size() < num) {
+					array.add(map);
+					obj.put(name, array);
+				}
+			}
+		}
+		if (Blank.notBlank(ofaList)) {
+			for (Map<String, Object> map : ofaList) {
+				map.remove("leadName");
+				map.remove("staffName");
+				map.remove("staffPhone");
+				map.remove("leadPhone");
+			}
+		}
+		Map<String, Object> map = new HashMap<>();
+		map.put("ofa", ofaList);
+		map.put("array", obj);
+		return map;
+	}
+
+	@Override
+	public Map<String, Object> getOffocoalAccountByPaging(Map<String, Object> map) {
+		Integer count = smsMessageDao.getCountOffocoalAccount(map);
+		if (!Blank.notBlank(count) || count == 0) {
+			return SendUtil.layuiTable(0, null);
+		}
+		return SendUtil.layuiTable(count, smsMessageDao.getOffocoalAccountByPaging(map));
+	}
 }

+ 20 - 0
nngkxxdp/src/main/resources/mapper/SmsMessageDao.xml

@@ -80,4 +80,24 @@
 		ORDER BY send_time DESC
 		LIMIT #{page}, #{limit}
     </select>
+    
+    <select id="getAllOfaList" resultType="java.util.Map">
+    	SELECT * FROM sort_article AS a
+		WHERE (
+		    SELECT count(*) FROM sort_article AS b WHERE a.official_account=b.official_account AND a.create_time &lt; b.create_time
+		) &lt; #{num}
+		ORDER BY a.official_account, a.create_time DESC
+    </select>
+    
+    <select id="getCountOffocoalAccount" resultType="java.lang.Integer" parameterType="java.util.Map">
+    	SELECT COUNT(*) FROM sort_article
+		WHERE official_account = #{name}
+    </select>
+    
+    <select id="getOffocoalAccountByPaging" resultType="java.util.Map" parameterType="java.util.Map">
+    	SELECT * FROM sort_article
+		WHERE official_account = #{name}
+		ORDER BY create_time DESC
+		LIMIT #{page}, #{limit}
+    </select>
 </mapper>