From ff4e6308bf86c2606e3843ef4485b03ba2dc6e14 Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期三, 13 三月 2019 12:04:02 +0800
Subject: [PATCH] 提交
---
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java | 190 +++++++++++++++++++++++++++++++++--------------
1 files changed, 133 insertions(+), 57 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 05f5af6..eb1093e 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
@@ -1,6 +1,8 @@
package com.yeshi.fanli.controller.admin;
import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.List;
import javax.annotation.Resource;
@@ -8,9 +10,12 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import com.yeshi.fanli.entity.bus.msg.UserSystemMsg;
+import com.yeshi.fanli.entity.bus.msg.UserSystemMsgTypeEnum;
import com.yeshi.fanli.exception.PushException;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.config.SystemService;
+import com.yeshi.fanli.service.inter.msg.UserSystemMsgService;
import com.yeshi.fanli.service.inter.push.PushRecordService;
import com.yeshi.fanli.service.inter.push.PushService;
import com.yeshi.fanli.service.inter.user.AccountMessageService;
@@ -33,6 +38,7 @@
public final static int ZNX = 4; // 绔欏唴鎺ㄩ��
public final static int WEEX = 5; // 绔欏唴鎺ㄩ��
public final static int BAICHUAN = 6; // 绔欏唴鎺ㄩ��
+ public final static int WELFARE_CENTER = 7; // 绂忓埄涓績
@Resource
private PushRecordService pushRecordService;
@@ -52,6 +58,9 @@
@Resource
private PushService pushService;
+ @Resource
+ private UserSystemMsgService userSystemMsgService;
+
/**
* 鍟嗗搧鎺ㄩ��
*
@@ -67,29 +76,41 @@
* @throws Exception
*/
@RequestMapping(value = "pushGoodsAll_f", method = RequestMethod.POST)
- public void pushGoods(Long uId, String url, String title, String content, PrintWriter out) throws Exception {
- String auctionId = null;
- if (!StringUtil.isNullOrEmpty(url) && url.contains("id=")) {
- String[] sts = url.split("\\?")[1].split("&");
- for (String st : sts)
- if (st.contains("id=")) {
- auctionId = st.replace("id=", "");
- }
- }
+ public void pushGoods(Long uId, String url, String title, String content, String versions, PrintWriter out) throws Exception {
+ try {
+ String auctionId = null;
+ if (!StringUtil.isNullOrEmpty(url) && url.contains("id=")) {
+ String[] sts = url.split("\\?")[1].split("&");
+ for (String st : sts)
+ if (st.contains("id=")) {
+ auctionId = st.replace("id=", "");
+ }
+ }
- if (StringUtil.isNullOrEmpty(auctionId)) {
- out.print(JsonUtil.loadFalseResult("鎻愬彇鍟嗗搧ID澶辫触"));
- return;
- }
+ if (StringUtil.isNullOrEmpty(auctionId)) {
+ out.print(JsonUtil.loadFalseResult("鎻愬彇鍟嗗搧ID澶辫触"));
+ return;
+ }
- JSONObject json = IOSPushFactory.createGoodsPush(Long.parseLong(auctionId), title, content);
- if (json.toString().getBytes().length > 256) {
- out.print(JsonUtil.loadFalseResult("鏍囬鎴栧唴瀹硅繃闀匡紝璇峰垹鍑忓悗鍐嶈瘯"));
- return;
- }
+ JSONObject json = IOSPushFactory.createGoodsPush(Long.parseLong(auctionId), title, content);
+ if (json.toString().getBytes().length > 256) {
+ out.print(JsonUtil.loadFalseResult("鏍囬鎴栧唴瀹硅繃闀匡紝璇峰垹鍑忓悗鍐嶈瘯"));
+ return;
+ }
- pushService.pushGoods(uId, url, title, content);
- out.print(JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�"));
+ List<String> listVersion = null;
+ if (versions != null && versions.trim().length() > 0) {
+ listVersion = Arrays.asList(versions.split(","));
+ }
+
+ pushService.pushGoods(uId, url, title, content, listVersion);
+ out.print(JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�"));
+ } catch (PushException e) {
+ out.print(JsonUtil.loadFalseResult(e.getMsg()));
+ } catch (Exception e) {
+ out.print(JsonUtil.loadFalseResult("鎺ㄩ�佸け璐�"));
+ e.printStackTrace();
+ }
}
/**
@@ -102,7 +123,7 @@
* @throws Exception
*/
@RequestMapping(value = "pushUrlAll_f", method = RequestMethod.POST)
- public void pushUrl(String url, String title, String content, PrintWriter out) throws Exception {
+ public void pushUrl(String url, String title, String content, String versions, PrintWriter out) throws Exception {
if (StringUtil.isNullOrEmpty(url) || StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) {
out.print(JsonUtil.loadFalseResult("璇峰~鍐欓摼鎺ワ紝鏍囬涓庡唴瀹�"));
return;
@@ -113,8 +134,22 @@
out.print(JsonUtil.loadFalseResult("鏍囬鎴栧唴瀹硅繃闀匡紝璇峰垹鍑忓悗鍐嶈瘯"));
return;
}
- pushService.pushUrl(null, url, title, content);
- out.print(JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�"));
+
+ try {
+ List<String> listVersion = null;
+ if (versions != null && versions.trim().length() > 0) {
+ listVersion = Arrays.asList(versions.split(","));
+ }
+
+ pushService.pushUrl(null, url, title, content, listVersion);
+ out.print(JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�"));
+ } catch (PushException e) {
+ out.print(JsonUtil.loadFalseResult(e.getMsg()));
+ } catch (Exception e) {
+ out.print(JsonUtil.loadFalseResult("鎺ㄩ�佸け璐�"));
+ e.printStackTrace();
+ }
+
}
/**
@@ -128,9 +163,23 @@
* @throws Exception
*/
@RequestMapping(value = "pushFanZNX_f", method = RequestMethod.POST)
- public void pushSystemZnx(Long uId, String title, String content, PrintWriter out) throws Exception {
- pushService.pushZNX(uId, title, content);
- out.print(JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�"));
+ public void pushSystemZnx(Long uId, String title, String content, String versions, PrintWriter out) throws Exception {
+ try {
+ List<String> listVersion = null;
+ if (versions != null && versions.trim().length() > 0) {
+ listVersion = Arrays.asList(versions.split(","));
+ }
+
+ pushService.pushZNX(uId, title, content, listVersion);
+
+ out.print(JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�"));
+ } catch (PushException e) {
+ out.print(JsonUtil.loadFalseResult(e.getMsg()));
+ } catch (Exception e) {
+ out.print(JsonUtil.loadFalseResult("鎺ㄩ�佸け璐�"));
+ e.printStackTrace();
+ }
+
}
/**
@@ -147,7 +196,7 @@
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("杞摼鏁版嵁涓嶈兘涓虹┖"));
return;
}
-
+
try {
String shortLink = org.yeshi.utils.HttpUtil.getShortLink(url);
@@ -155,17 +204,15 @@
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();
}
}
-
-
/**
- * 鍟嗗搧鎺ㄩ�� -(鏂板悗鍙�)
+ * 鍟嗗搧鎺ㄩ�� -(鏂板悗鍙�)
*
* @param uId
* -鐢ㄦ埛ID 鍙负绌�
@@ -179,8 +226,9 @@
* @throws Exception
*/
@RequestMapping(value = "newPushGoodsAll")
- public void newPushGoodsAll(String callback, Long uid, String url, String title, String content, PrintWriter out) throws Exception {
-
+ public void newPushGoodsAll(String callback, Long uid, String url, String title, String content, String versions, PrintWriter out)
+ throws Exception {
+
String auctionId = null;
if (!StringUtil.isNullOrEmpty(url) && url.contains("id=")) {
String[] sts = url.split("\\?")[1].split("&");
@@ -202,14 +250,21 @@
}
try {
- pushService.pushGoods(uid, url, title, content);
+ List<String> listVersion = null;
+ if (versions != null && versions.trim().length() > 0) {
+ listVersion = Arrays.asList(versions.split(","));
+ }
+
+ pushService.pushGoods(uid, url, title, content, listVersion);
JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�"));
+ } catch (PushException e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
} catch (Exception e) {
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎺ㄩ�佸け璐�"));
e.printStackTrace();
}
}
-
+
/**
* 缃戦〉鎺ㄩ�� -(鏂板悗鍙�)
*
@@ -220,8 +275,8 @@
* @throws Exception
*/
@RequestMapping(value = "newPushUrlAll")
- public void newPushUrlAll(String callback, String url, String title, String content, PrintWriter out) {
-
+ public void newPushUrlAll(String callback, String url, String title, String content, String versions, PrintWriter out) {
+
if (StringUtil.isNullOrEmpty(url) || StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) {
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇峰~鍐欓摼鎺ワ紝鏍囬涓庡唴瀹�"));
return;
@@ -232,16 +287,23 @@
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏍囬鎴栧唴瀹硅繃闀匡紝璇峰垹鍑忓悗鍐嶈瘯"));
return;
}
-
+
try {
- pushService.pushUrl(null, url, title, content);
+ List<String> listVersion = null;
+ if (versions != null && versions.trim().length() > 0) {
+ listVersion = Arrays.asList(versions.split(","));
+ }
+
+ pushService.pushUrl(null, url, title, content, listVersion);
JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�"));
} catch (PushException e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+ } catch (Exception e) {
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎺ㄩ�佸け璐�"));
e.printStackTrace();
}
}
-
+
/**
*
* 鏂规硶璇存槑: 绔欏唴淇℃帹閫� -(鏂板悗鍙�)
@@ -252,39 +314,47 @@
* @throws Exception
*/
@RequestMapping(value = "newPushFanZNX")
- public void newPushFanZNX(String callback, String uids, String title, String content, PrintWriter out) {
-
+ public void newPushFanZNX(String callback, String uids, String title, String content, String versions, 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(",");
}
+ List<String> listVersion = null;
+ if (versions != null && versions.trim().length() > 0) {
+ listVersion = Arrays.asList(versions.split(","));
+ }
+
if (uidArray == null) {
- pushService.pushZNX(null, title, content);
+ pushService.pushZNX(null, title, content, listVersion);
} 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);
+ pushService.pushZNX(Long.parseLong(str_uid), title, content, listVersion);
+
+ userSystemMsgService.addUserSystemMsg(Long.parseLong(str_uid), UserSystemMsgTypeEnum.question,
+ title, content, UserSystemMsg.TIME_TAG_EMERGENT, null);
}
}
}
-
JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�"));
} catch (PushException e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+ } catch (Exception e) {
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎺ㄩ�佸け璐�"));
e.printStackTrace();
}
}
-
/**
*
* 鏂规硶璇存槑: 鐧惧窛鎺ㄩ�� -(鏂板悗鍙�)
@@ -295,37 +365,43 @@
* @throws Exception
*/
@RequestMapping(value = "pushBaiChuan")
- public void pushBaiChuan(String callback, String uids, String title, String content, String url,
- PrintWriter out) {
-
+ public void pushBaiChuan(String callback, String uids, String title, String content, String url, String versions, 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(",");
}
+
+ List<String> listVersion = null;
+ if (versions != null && versions.trim().length() > 0) {
+ listVersion = Arrays.asList(versions.split(","));
+ }
if (uidArray == null) {
- pushService.pushBaiChuanUrl(null, title, content, url);
+ pushService.pushBaiChuanUrl(null, title, content, url, listVersion);
} 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);
+ pushService.pushBaiChuanUrl(Long.parseLong(str_uid), title, content, url, listVersion);
}
}
}
JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�"));
-
+
} catch (PushException e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
+ } catch (Exception e) {
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎺ㄩ�佸け璐�"));
e.printStackTrace();
}
}
-
+
}
--
Gitblit v1.8.0