Pārlūkot izejas kodu

#260 修复小程序发送模版消息接口的问题,并重新整理javadoc

master
Binary Wang pirms 7 gadiem
committed by Binary Wang
vecāks
revīzija
cc7a83e350
3 mainītis faili ar 10 papildinājumiem un 13 dzēšanām
  1. +4
    -5
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaMsgService.java
  2. +3
    -5
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImpl.java
  3. +3
    -3
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java

+ 4
- 5
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaMsgService.java Parādīt failu

@@ -18,7 +18,7 @@ public interface WxMaMsgService {
/**
* <pre>
* 发送客服消息
* 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140547&token=&lang=zh_CN">发送客服消息</a>
* 详情请见: <a href="https://mp.weixin.qq.com/debug/wxadoc/dev/api/custommsg/conversation.html">发送客服消息</a>
* 接口url格式:https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
* </pre>
*/
@@ -27,10 +27,9 @@ public interface WxMaMsgService {
/**
* <pre>
* 发送模板消息
* 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN
* 详情请见: <a href="https://mp.weixin.qq.com/debug/wxadoc/dev/api/notice.html#接口说明">发送模板消息</a>
* 接口url格式:https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN
* </pre>
*
* @return 消息Id
*/
String sendTemplateMsg(WxMaTemplateMessage templateMessage) throws WxErrorException;
void sendTemplateMsg(WxMaTemplateMessage templateMessage) throws WxErrorException;
}

+ 3
- 5
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImpl.java Parādīt failu

@@ -27,14 +27,12 @@ public class WxMaMsgServiceImpl implements WxMaMsgService {
}

@Override
public String sendTemplateMsg(WxMaTemplateMessage templateMessage) throws WxErrorException {
public void sendTemplateMsg(WxMaTemplateMessage templateMessage) throws WxErrorException {
String responseContent = this.wxMaService.post(TEMPLATE_MSG_SEND_URL, templateMessage.toJson());
JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject();
if (jsonObject.get("errcode").getAsInt() == 0) {
return jsonObject.get("msgid").getAsString();
if (jsonObject.get("errcode").getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent));
}

throw new WxErrorException(WxError.fromJson(responseContent));
}

}

+ 3
- 3
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java Parādīt failu

@@ -193,7 +193,7 @@ public class WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpCl

try {
T result = executor.execute(uriWithAccessToken, data);
this.log.debug("\n[URL]: {}\n[PARAMS]: {}\n[RESPONSE]: {}", uriWithAccessToken, data, result);
this.log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, data, result);
return result;
} catch (WxErrorException e) {
WxError error = e.getError();
@@ -212,12 +212,12 @@ public class WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpCl
}

if (error.getErrorCode() != 0) {
this.log.error("\n[URL]: {}\n[PARAMS]: {}\n[RESPONSE]: {}", uriWithAccessToken, data, error);
this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, data, error);
throw new WxErrorException(error);
}
return null;
} catch (IOException e) {
this.log.error("\n[URL]: {}\n[PARAMS]: {}\n[EXCEPTION]: {}", uriWithAccessToken, data, e.getMessage());
this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, data, e.getMessage());
throw new RuntimeException(e);
}
}


Notiek ielāde…
Atcelt
Saglabāt