|
|
@@ -3,6 +3,7 @@ package com.mrxu.framework.common.xcx.base;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.mrxu.framework.common.util.BusinessException;
|
|
|
import com.mrxu.framework.common.util.HttpUtil;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@@ -20,11 +21,11 @@ public class XcxHttp {
|
|
|
public static <T extends XcxResult> T get(Class<T> clazz, String url, Map<String, String> queryParas) {
|
|
|
String rs = HttpUtil.get(GLOBAL_CONNECT_TIMEOUT, GLOBAL_READ_TIMEOUT, url, queryParas, null);
|
|
|
if(rs == null) {
|
|
|
- throw new RuntimeException("与微信服务器网络不通");
|
|
|
+ throw new BusinessException("与微信服务器网络不通");
|
|
|
}
|
|
|
T wxRs = JSON.parseObject(rs, clazz);
|
|
|
if(!wxRs.isSuccess()) {
|
|
|
- throw new RuntimeException("调用微信接口出错:"+wxRs.getErrmsg());
|
|
|
+ throw new BusinessException(wxRs.getErrmsg());
|
|
|
}
|
|
|
return wxRs;
|
|
|
}
|
|
|
@@ -37,12 +38,12 @@ public class XcxHttp {
|
|
|
public static <T extends XcxResult> T post(Class<T> clazz,String url,JSONObject json) {
|
|
|
String rs = HttpUtil.post(GLOBAL_CONNECT_TIMEOUT, GLOBAL_READ_TIMEOUT, url,json.toJSONString());
|
|
|
if(rs == null) {
|
|
|
- throw new RuntimeException("与微信服务器网络不通");
|
|
|
+ throw new BusinessException("与微信服务器网络不通");
|
|
|
}
|
|
|
T wxRs = JSON.parseObject(rs, clazz);
|
|
|
if(!wxRs.isSuccess()) {
|
|
|
logger.error(rs);
|
|
|
- throw new RuntimeException("调用微信接口出错:"+wxRs.getErrmsg());
|
|
|
+ throw new BusinessException(wxRs.getErrmsg());
|
|
|
}
|
|
|
return wxRs;
|
|
|
}
|