From 88b54772dbcf5ecab1e2316e4e4626ac901b8908 Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期二, 22 一月 2019 15:58:24 +0800
Subject: [PATCH] 邀请码添加返回状态

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java |   92 ++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 81 insertions(+), 11 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java
index 0c334a4..05f5af6 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java
@@ -31,6 +31,8 @@
 	public final static int URL = 2; // 缃戦〉鎺ㄩ��
 	public final static int DETAIL = 3; // 璇︽儏鎺ㄩ��
 	public final static int ZNX = 4; // 绔欏唴鎺ㄩ��
+	public final static int WEEX = 5; // 绔欏唴鎺ㄩ��
+	public final static int BAICHUAN = 6; // 绔欏唴鎺ㄩ��
 
 	@Resource
 	private PushRecordService pushRecordService;
@@ -138,17 +140,26 @@
 	 * @param out
 	 * @throws Exception
 	 */
-	@RequestMapping(value = "convertLink", method = RequestMethod.POST)
-	public void convertLink(String url, PrintWriter out) throws Exception {
+	@RequestMapping(value = "convertLink")
+	public void convertLink(String callback, String url, PrintWriter out) {
 
-		String shortLink = org.yeshi.utils.HttpUtil.getShortLink(url);
+		if (StringUtil.isNullOrEmpty(url)) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("杞摼鏁版嵁涓嶈兘涓虹┖"));
+			return;
+		}
+		
+		try {
+			String shortLink = org.yeshi.utils.HttpUtil.getShortLink(url);
 
-		JSONObject jsonData = new JSONObject();
-		jsonData.put("url", url);
-		jsonData.put("shortLink", shortLink);
-
-		out.print(JsonUtil.loadTrueResult(jsonData));
-
+			JSONObject jsonData = new JSONObject();
+			jsonData.put("url", url);
+			jsonData.put("shortLink", shortLink);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonData));
+			
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("杞崲澶辫触"));
+			e.printStackTrace();
+		}
 	}
 
 	
@@ -241,7 +252,7 @@
 	 * @throws Exception
 	 */
 	@RequestMapping(value = "newPushFanZNX")
-	public void newPushFanZNX(String callback, Long uid, String title, String content, PrintWriter out) {
+	public void newPushFanZNX(String callback, String uids, String title, String content, PrintWriter out) {
 		
 		if (StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇峰~鍐欐爣棰樹笌鍐呭"));
@@ -249,7 +260,23 @@
 		}
 		
 		try {
-			pushService.pushZNX(uid, title, content);
+			
+			String[] uidArray = null;
+			if (uids != null) {
+				uidArray = uids.split(",");
+			}
+			
+			if (uidArray == null) {
+				pushService.pushZNX(null, title, content);
+			} else {
+				for (int i = 0; i < uidArray.length; i++) {
+					String str_uid = uidArray[i];
+					if (str_uid != null && str_uid.trim().length() > 0) {
+						pushService.pushZNX(Long.parseLong(str_uid), title, content);
+					}
+				}
+			}
+			
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�"));
 		} catch (PushException e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎺ㄩ�佸け璐�"));
@@ -258,4 +285,47 @@
 	}
 
 	
+	/**
+	 * 
+	 * 鏂规硶璇存槑: 鐧惧窛鎺ㄩ�� -(鏂板悗鍙�)
+	 * 
+	 * @param uId
+	 * @param title
+	 * @param content
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "pushBaiChuan")
+	public void pushBaiChuan(String callback, String uids, String title, String content, String url, 
+			PrintWriter out) {
+		
+		if (StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇峰~鍐欐爣棰樹笌鍐呭"));
+			return;
+		}
+		
+		try {
+			
+			String[] uidArray = null;
+			if (uids != null) {
+				uidArray = uids.split(",");
+			}
+			
+			if (uidArray == null) {
+				pushService.pushBaiChuanUrl(null, title, content, url);
+			} else {
+				for (int i = 0; i < uidArray.length; i++) {
+					String str_uid = uidArray[i];
+					if (str_uid != null && str_uid.trim().length() > 0) {
+						pushService.pushBaiChuanUrl(Long.parseLong(str_uid), title, content, url);
+					}
+				}
+			}
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�"));
+			
+		} catch (PushException e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎺ㄩ�佸け璐�"));
+			e.printStackTrace();
+		}
+	}
+	
 }

--
Gitblit v1.8.0