From ed035efe19e7f247717afa8448998fd2c8a9eefa Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期五, 15 三月 2019 09:45:05 +0800 Subject: [PATCH] 后台推送版本控制优化 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java | 189 ++++++++++++----------------------------------- 1 files changed, 48 insertions(+), 141 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 88e0240..4d914e2 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 @@ -8,19 +8,14 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.yeshi.utils.HttpUtil; import org.yeshi.utils.JsonUtil; 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.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; -import com.yeshi.fanli.service.inter.user.SystemZnxService; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.factory.IOSPushFactory; @@ -38,144 +33,13 @@ public final static int BAICHUAN = 6; // 绔欏唴鎺ㄩ�� public final static int WELFARE_CENTER = 7; // 绂忓埄涓績 - @Resource - private PushRecordService pushRecordService; - - @Resource - private ConfigService configService; - - @Resource - private SystemZnxService systemZnxService; - - @Resource - private AccountMessageService accountMessageService; @Resource private PushService pushService; @Resource private UserSystemMsgService userSystemMsgService; - - /** - * 鍟嗗搧鎺ㄩ�� - * - * @param uId - * -鐢ㄦ埛ID 鍙负绌� - * @param url - * -鍟嗗搧閾炬帴 - * @param title - * -鎺ㄩ�佹爣棰� - * @param content - * -鎺ㄩ�佸唴瀹� - * @param out - * @throws Exception - */ - @RequestMapping(value = "pushGoodsAll_f", method = RequestMethod.POST) - 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; - } - - JSONObject json = IOSPushFactory.createGoodsPush(Long.parseLong(auctionId), title, content); - if (json.toString().getBytes().length > 256) { - out.print(JsonUtil.loadFalseResult("鏍囬鎴栧唴瀹硅繃闀匡紝璇峰垹鍑忓悗鍐嶈瘯")); - return; - } - - 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(); - } - } - - /** - * 缃戦〉鎺ㄩ�� - * - * @param url - * @param title - * @param content - * @param out - * @throws Exception - */ - @RequestMapping(value = "pushUrlAll_f", method = RequestMethod.POST) - 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; - } - - JSONObject json = IOSPushFactory.createURLPush(HttpUtil.getShortLink(url), title, content); - if (json.toString().getBytes().length > 256) { - out.print(JsonUtil.loadFalseResult("鏍囬鎴栧唴瀹硅繃闀匡紝璇峰垹鍑忓悗鍐嶈瘯")); - return; - } - - 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(); - } - - } - - /** - * - * 鏂规硶璇存槑: 绔欏唴淇℃帹閫� - * - * @author mawurui createTime 2018骞�3鏈�12鏃� 涓嬪崍5:45:00 - * @param uId - * @param title - * @param content - * @throws Exception - */ - @RequestMapping(value = "pushFanZNX_f", method = RequestMethod.POST) - 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(); - } - - } + /** * 鐭摼鎺ヨ浆鎹� @@ -221,7 +85,7 @@ * @throws Exception */ @RequestMapping(value = "newPushGoodsAll") - public void newPushGoodsAll(String callback, Long uid, String url, String title, String content, String versions, PrintWriter out) + public void newPushGoodsAll(String callback, String url, String title, String content, String uids, String versions, PrintWriter out) throws Exception { String auctionId = null; @@ -245,12 +109,31 @@ } 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(",")); } - pushService.pushGoods(uid, url, title, content, listVersion); + if (uidArray == null) { + // 鍏ㄦ帹 + pushService.pushGoods(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.pushGoods(Long.parseLong(str_uid), url, title, content, listVersion); + } + } + } + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�")); } catch (PushException e) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); @@ -270,7 +153,8 @@ * @throws Exception */ @RequestMapping(value = "newPushUrlAll") - public void newPushUrlAll(String callback, String url, String title, String content, String versions, PrintWriter out) { + public void newPushUrlAll(String callback, String url, String title, String content, String uids, + String versions, PrintWriter out) { if (StringUtil.isNullOrEmpty(url) || StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇峰~鍐欓摼鎺ワ紝鏍囬涓庡唴瀹�")); @@ -284,12 +168,31 @@ } 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(",")); } - pushService.pushUrl(null, url, title, content, listVersion); + if (uidArray == null) { + // 鍏ㄦ帹 + pushService.pushUrl(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.pushUrl(Long.parseLong(str_uid), url, title, content, listVersion); + } + } + } + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�")); } catch (PushException e) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); @@ -329,8 +232,10 @@ } if (uidArray == null) { + // 鍏ㄦ帹 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) { @@ -380,8 +285,10 @@ } if (uidArray == null) { + // 鍏ㄦ帹 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) { -- Gitblit v1.8.0