From 18738585b455edb5c576ea1b327441122e455055 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 13 十二月 2018 18:09:35 +0800
Subject: [PATCH] 增加首页邀请入口的banner图片
---
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushController.java | 136 ++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 127 insertions(+), 9 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 a6d8f6e..7d3731a 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,6 +8,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+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.push.PushRecordService;
@@ -16,6 +17,7 @@
import com.yeshi.fanli.service.inter.user.SystemZnxService;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.factory.IOSPushFactory;
+
import org.yeshi.utils.HttpUtil;
import org.yeshi.utils.JsonUtil;
@@ -136,17 +138,133 @@
* @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();
+ }
}
+
+
+ /**
+ * 鍟嗗搧鎺ㄩ�� -(鏂板悗鍙�)
+ *
+ * @param uId
+ * -鐢ㄦ埛ID 鍙负绌�
+ * @param url
+ * -鍟嗗搧閾炬帴
+ * @param title
+ * -鎺ㄩ�佹爣棰�
+ * @param content
+ * -鎺ㄩ�佸唴瀹�
+ * @param out
+ * @throws Exception
+ */
+ @RequestMapping(value = "newPushGoodsAll")
+ public void newPushGoodsAll(String callback, 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=", "");
+ }
+ }
+
+ if (StringUtil.isNullOrEmpty(auctionId)) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎻愬彇鍟嗗搧ID澶辫触"));
+ return;
+ }
+
+ JSONObject json = IOSPushFactory.createGoodsPush(Long.parseLong(auctionId), title, content);
+ if (json.toString().getBytes().length > 256) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏍囬鎴栧唴瀹硅繃闀匡紝璇峰垹鍑忓悗鍐嶈瘯"));
+ return;
+ }
+
+ try {
+ pushService.pushGoods(uid, url, title, content);
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�"));
+ } catch (Exception e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎺ㄩ�佸け璐�"));
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 缃戦〉鎺ㄩ�� -(鏂板悗鍙�)
+ *
+ * @param url
+ * @param title
+ * @param content
+ * @param out
+ * @throws Exception
+ */
+ @RequestMapping(value = "newPushUrlAll")
+ public void newPushUrlAll(String callback, String url, String title, String content, PrintWriter out) {
+
+ if (StringUtil.isNullOrEmpty(url) || StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇峰~鍐欓摼鎺ワ紝鏍囬涓庡唴瀹�"));
+ return;
+ }
+
+ JSONObject json = IOSPushFactory.createURLPush(HttpUtil.getShortLink(url), title, content);
+ if (json.toString().getBytes().length > 256) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏍囬鎴栧唴瀹硅繃闀匡紝璇峰垹鍑忓悗鍐嶈瘯"));
+ return;
+ }
+
+ try {
+ pushService.pushUrl(null, url, title, content);
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�"));
+ } catch (PushException e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎺ㄩ�佸け璐�"));
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ *
+ * 鏂规硶璇存槑: 绔欏唴淇℃帹閫� -(鏂板悗鍙�)
+ *
+ * @param uId
+ * @param title
+ * @param content
+ * @throws Exception
+ */
+ @RequestMapping(value = "newPushFanZNX")
+ public void newPushFanZNX(String callback, Long uid, String title, String content, PrintWriter out) {
+
+ if (StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(content)) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇峰~鍐欐爣棰樹笌鍐呭"));
+ return;
+ }
+
+ try {
+ pushService.pushZNX(uid, title, content);
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�"));
+ } catch (PushException e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎺ㄩ�佸け璐�"));
+ e.printStackTrace();
+ }
+ }
+
+
}
--
Gitblit v1.8.0