From ec2e599aeeef5da20eeedf7b77acd321a1821d03 Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Thu, 22 Sep 2016 20:08:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=A4=E4=B8=AA=E5=AE=A2?= =?UTF-8?q?=E6=9C=8D=E6=8E=A5=E5=8F=A3=E5=9C=B0=E5=9D=80=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=88=E6=80=80=E7=96=91=E6=98=AF=E5=BE=AE=E4=BF=A1=E5=AE=98?= =?UTF-8?q?=E6=96=B9=E5=81=B7=E5=81=B7=E6=94=B9=E4=BA=86=E7=9A=84=EF=BC=9F?= =?UTF-8?q?=EF=BC=9F=EF=BC=81=EF=BC=81=EF=BC=81=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mp/api/impl/WxMpKefuServiceImpl.java | 56 ++++--------------- 1 file changed, 11 insertions(+), 45 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImpl.java index b65fdeaa..99428348 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImpl.java @@ -1,13 +1,6 @@ package me.chanjar.weixin.mp.api.impl; -import java.io.File; -import java.util.Date; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.google.gson.JsonObject; - import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.exception.WxErrorException; @@ -17,15 +10,15 @@ import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.WxMpCustomMessage; import me.chanjar.weixin.mp.bean.kefu.request.WxMpKfAccountRequest; import me.chanjar.weixin.mp.bean.kefu.request.WxMpKfSessionRequest; -import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfList; -import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfMsgList; -import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfOnlineList; -import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfSessionGetResult; -import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfSessionList; -import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfSessionWaitCaseList; +import me.chanjar.weixin.mp.bean.kefu.result.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.util.Date; /** - * + * * @author Binary Wang * */ @@ -33,6 +26,7 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { protected final Logger log = LoggerFactory .getLogger(WxMpKefuServiceImpl.class); private static final String API_URL_PREFIX = "https://api.weixin.qq.com/customservice"; + private static final String API_URL_PREFIX_WITH_CGI_BIN = "https://api.weixin.qq.com/cgi-bin/customservice"; private WxMpService wxMpService; public WxMpKefuServiceImpl(WxMpService wxMpService) { @@ -44,26 +38,20 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { throws WxErrorException { String url = "https://api.weixin.qq.com/cgi-bin/message/custom/send"; String responseContent = this.wxMpService.post(url, message.toJson()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, message.toJson(), - responseContent); return true; } @Override public WxMpKfList kfList() throws WxErrorException { - String url = API_URL_PREFIX + "/getkflist"; + String url = API_URL_PREFIX_WITH_CGI_BIN + "/getkflist"; String responseContent = this.wxMpService.get(url, null); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, null, - responseContent); return WxMpKfList.fromJson(responseContent); } @Override public WxMpKfOnlineList kfOnlineList() throws WxErrorException { - String url = API_URL_PREFIX + "/getonlinekflist"; + String url = API_URL_PREFIX_WITH_CGI_BIN + "/getonlinekflist"; String responseContent = this.wxMpService.get(url, null); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, null, - responseContent); return WxMpKfOnlineList.fromJson(responseContent); } @@ -72,8 +60,6 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { throws WxErrorException { String url = API_URL_PREFIX + "/kfaccount/add"; String responseContent = this.wxMpService.post(url, request.toJson()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, request.toJson(), - responseContent); return true; } @@ -82,8 +68,6 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { throws WxErrorException { String url = API_URL_PREFIX + "/kfaccount/update"; String responseContent = this.wxMpService.post(url, request.toJson()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, request.toJson(), - responseContent); return true; } @@ -91,8 +75,6 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { public boolean kfAccountInviteWorker(WxMpKfAccountRequest request) throws WxErrorException { String url = API_URL_PREFIX + "/kfaccount/inviteworker"; String responseContent = this.wxMpService.post(url, request.toJson()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, request.toJson(), - responseContent); return true; } @@ -102,9 +84,6 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { String url = API_URL_PREFIX + "/kfaccount/uploadheadimg?kf_account=" + kfAccount; WxMediaUploadResult responseContent = this.wxMpService .execute(new MediaUploadRequestExecutor(), url, imgFile); - this.log.debug("\nurl:{}\nparams:{}&file:{}\nresponse:{}", url, kfAccount, - imgFile.getAbsolutePath(), - responseContent); return true; } @@ -112,8 +91,6 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { public boolean kfAccountDel(String kfAccount) throws WxErrorException { String url = API_URL_PREFIX + "/kfaccount/del?kf_account=" + kfAccount; String responseContent = this.wxMpService.get(url, null); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, null, - responseContent); return true; } @@ -123,8 +100,6 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { WxMpKfSessionRequest request = new WxMpKfSessionRequest(kfAccount, openid); String url = API_URL_PREFIX + "/kfsession/create"; String responseContent = this.wxMpService.post(url, request.toJson()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, request.toJson(), - responseContent); return true; } @@ -134,8 +109,6 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { WxMpKfSessionRequest request = new WxMpKfSessionRequest(kfAccount, openid); String url = API_URL_PREFIX + "/kfsession/close"; String responseContent = this.wxMpService.post(url, request.toJson()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, request.toJson(), - responseContent); return true; } @@ -144,8 +117,6 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { throws WxErrorException { String url = API_URL_PREFIX + "/kfsession/getsession?openid=" + openid; String responseContent = this.wxMpService.get(url, null); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, null, - responseContent); return WxMpKfSessionGetResult.fromJson(responseContent); } @@ -154,8 +125,6 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { throws WxErrorException { String url = API_URL_PREFIX + "/kfsession/getsessionlist?kf_account=" + kfAccount; String responseContent = this.wxMpService.get(url, null); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, null, - responseContent); return WxMpKfSessionList.fromJson(responseContent); } @@ -164,8 +133,6 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { throws WxErrorException { String url = API_URL_PREFIX + "/kfsession/getwaitcase"; String responseContent = this.wxMpService.get(url, null); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, null, - responseContent); return WxMpKfSessionWaitCaseList.fromJson(responseContent); } @@ -188,8 +155,7 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { param.addProperty("number", number); //number 每次获取条数,最多10000条 String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, param.toString(), - responseContent); + return WxMpKfMsgList.fromJson(responseContent); }