mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-27 20:14:52 +08:00
🎨 升级部分依赖版本,优化代码,部分代码增加泛型参数
This commit is contained in:
@ -2,7 +2,6 @@ package me.chanjar.weixin.open.api;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.open.bean.ma.WxFastMaCategory;
|
||||
import me.chanjar.weixin.open.bean.ma.WxOpenMaApplyOrderPathInfo;
|
||||
import me.chanjar.weixin.open.bean.result.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package me.chanjar.weixin.open.api;
|
||||
|
||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
||||
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
|
||||
@ -150,7 +150,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
return SHA1.gen(getWxOpenConfigStorage().getComponentToken(), timestamp, nonce)
|
||||
.equals(signature);
|
||||
} catch (Exception e) {
|
||||
log.error("Checking signature failed, and the reason is :" + e.getMessage());
|
||||
log.error("Checking signature failed, and the reason is :{}", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -705,7 +705,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
jsonObject.addProperty("wx_name", wxName);
|
||||
String url = CHECK_SHOP_AUDITSTATUS_URL + "?access_token=" + getComponentAccessToken(false);
|
||||
String response = post(url, jsonObject.toString());
|
||||
log.info("CHECK_SHOP_AUDITSTATUS_URL: " + response);
|
||||
log.info("CHECK_SHOP_AUDITSTATUS_URL: {}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -715,7 +715,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
jsonObject.addProperty("wx_name", wxName);
|
||||
String url = CHECK_SHOP_AUDITSTATUS_URL + "?access_token=" + getAuthorizerAccessToken(appId, false);
|
||||
String response = post(url, jsonObject.toString());
|
||||
log.info("CHECK_SHOP_AUDITSTATUS_URL: " + response);
|
||||
log.info("CHECK_SHOP_AUDITSTATUS_URL: {}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -757,7 +757,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
@Override
|
||||
public WxMinishopImageUploadResult uploadMinishopImagePicFile(String appId, Integer height, Integer width, File file) throws WxErrorException {
|
||||
String url = WxOpenMinishopService.UPLOAD_IMG_MINISHOP_FILE_URL + "?access_token=" + getAuthorizerAccessToken(appId, false) + "&height=" + height + "&width=" + width;
|
||||
log.info("upload url: " + url);
|
||||
log.info("upload url: {}", url);
|
||||
// String response = (url, file);
|
||||
WxMinishopImageUploadResult result = getWxOpenService().uploadMinishopMediaFile(url, file);
|
||||
|
||||
@ -770,13 +770,13 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
jsonObject.addProperty("f_cat_id", fCatId);
|
||||
String url = MINISHOP_CATEGORY_GET_URL + "?access_token=" + getAuthorizerAccessToken(appId, false);
|
||||
String response = getWxOpenService().post(url, jsonObject.toString());
|
||||
log.info("response: " + response);
|
||||
log.info("response: {}", response);
|
||||
JsonObject respJson = GsonParser.parse(response);
|
||||
MinishopCategories categories = new MinishopCategories();
|
||||
categories.setErrcode(respJson.get(WxConsts.ERR_CODE).getAsInt());
|
||||
if (categories.getErrcode() == 0) {
|
||||
JsonArray catListJson = respJson.getAsJsonArray("cat_list");
|
||||
if (catListJson != null || catListJson.size() > 0) {
|
||||
if (catListJson != null || !catListJson.isEmpty()) {
|
||||
List<MinishopCategory> categoryList = new ArrayList<>();
|
||||
for (int i = 0; i < catListJson.size(); i++) {
|
||||
JsonObject catJson = catListJson.get(i).getAsJsonObject();
|
||||
@ -806,7 +806,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
brandList.setErrcode(respJson.get(WxConsts.ERR_CODE).getAsInt());
|
||||
if (brandList.getErrcode() == 0) {
|
||||
JsonArray brandArrayJson = respJson.get("brands").getAsJsonArray();
|
||||
if (brandArrayJson.size() > 0) {
|
||||
if (!brandArrayJson.isEmpty()) {
|
||||
List<MinishopBrand> brands = new ArrayList<>();
|
||||
for (int i = 0; i < brandArrayJson.size(); i++) {
|
||||
JsonObject brandJson = brandArrayJson.get(i).getAsJsonObject();
|
||||
@ -843,7 +843,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
templateResult.setErrCode(respJson.get(WxConsts.ERR_CODE).getAsInt());
|
||||
if (templateResult.getErrCode() == 0) {
|
||||
JsonArray templateArrayJson = respJson.get("template_list").getAsJsonArray();
|
||||
if (templateArrayJson.size() > 0) {
|
||||
if (!templateArrayJson.isEmpty()) {
|
||||
List<MinishopDeliveryTemplate> templateList = new ArrayList<>();
|
||||
for (int i = 0; i < templateArrayJson.size(); i++) {
|
||||
JsonObject templateJson = templateArrayJson.get(i).getAsJsonObject();
|
||||
@ -876,7 +876,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
shopCatList.setErrcode(respJson.get(WxConsts.ERR_CODE).getAsInt());
|
||||
if (shopCatList.getErrcode() == 0) {
|
||||
JsonArray shopcatArrayJson = respJson.get("shopcat_list").getAsJsonArray();
|
||||
if (shopcatArrayJson.size() > 0) {
|
||||
if (!shopcatArrayJson.isEmpty()) {
|
||||
List<MinishopShopCat> shopCats = new ArrayList<>();
|
||||
for (int i = 0; i < shopcatArrayJson.size(); i++) {
|
||||
JsonObject shopCatJson = shopcatArrayJson.get(i).getAsJsonObject();
|
||||
@ -906,7 +906,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
String response = getWxOpenService().post(url, jsonObject.toString());
|
||||
|
||||
JsonObject respObj = GsonParser.parse(response);
|
||||
WxMinishopAddGoodsSpuResult result = new WxMinishopAddGoodsSpuResult();
|
||||
WxMinishopAddGoodsSpuResult<List<WxMinishopDeliveryCompany>> result = new WxMinishopAddGoodsSpuResult<>();
|
||||
result.setErrcode(respObj.get(WxConsts.ERR_CODE).getAsInt());
|
||||
if (result.getErrcode() == 0) {
|
||||
JsonArray companyArray = respObj.get("company_list").getAsJsonArray();
|
||||
@ -931,7 +931,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
JsonObject jsonObject = couponInfo.toJsonObject();
|
||||
String response = getWxOpenService().post(url, jsonObject.toString());
|
||||
JsonObject respJson = GsonParser.parse(response);
|
||||
Integer couponId = -1;
|
||||
int couponId = -1;
|
||||
if (respJson.get(WxConsts.ERR_CODE).getAsInt() == 0) {
|
||||
JsonObject dataJson = respJson.get("data").getAsJsonObject();
|
||||
couponId = dataJson.get("coupon_id").getAsInt();
|
||||
@ -965,7 +965,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
JsonObject jsonObject = couponInfo.toJsonObject();
|
||||
String response = getWxOpenService().post(url, jsonObject.toString());
|
||||
JsonObject respJson = GsonParser.parse(response);
|
||||
Integer couponId = -1;
|
||||
int couponId = -1;
|
||||
if (respJson.get(WxConsts.ERR_CODE).getAsInt() == 0) {
|
||||
JsonObject dataJson = respJson.get("data").getAsJsonObject();
|
||||
couponId = dataJson.get("coupon_id").getAsInt();
|
||||
@ -994,7 +994,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
String response = getWxOpenService().post(url, jsonObject.toString());
|
||||
|
||||
JsonObject respObj = GsonParser.parse(response);
|
||||
WxMinishopAddGoodsSpuResult result = new WxMinishopAddGoodsSpuResult();
|
||||
WxMinishopAddGoodsSpuResult<WxMinishopAddGoodsSpuData> result = new WxMinishopAddGoodsSpuResult<>();
|
||||
result.setErrcode(respObj.get(WxConsts.ERR_CODE).getAsInt());
|
||||
|
||||
if (result.getErrcode() == 0) {
|
||||
@ -1032,7 +1032,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
String response = getWxOpenService().post(url, jsonObject.toString());
|
||||
|
||||
JsonObject respObj = GsonParser.parse(response);
|
||||
WxMinishopAddGoodsSpuResult result = new WxMinishopAddGoodsSpuResult();
|
||||
WxMinishopAddGoodsSpuResult<WxMinishopAddGoodsSpuData> result = new WxMinishopAddGoodsSpuResult<>();
|
||||
result.setErrcode(respObj.get(WxConsts.ERR_CODE).getAsInt());
|
||||
if (result.getErrcode() == 0) {
|
||||
JsonObject dataObj = respObj.get("data").getAsJsonObject();
|
||||
@ -1082,7 +1082,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
String response = getWxOpenService().post(url, jsonObject.toString());
|
||||
|
||||
JsonObject respObj = GsonParser.parse(response);
|
||||
WxMinishopAddGoodsSpuResult result = new WxMinishopAddGoodsSpuResult();
|
||||
WxMinishopAddGoodsSpuResult<WxMinishopAddGoodsSkuData> result = new WxMinishopAddGoodsSpuResult<>();
|
||||
result.setErrcode(respObj.get(WxConsts.ERR_CODE).getAsInt());
|
||||
if (result.getErrcode() == 0) {
|
||||
JsonObject dataObj = respObj.get("data").getAsJsonObject();
|
||||
@ -1187,7 +1187,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
JsonObject jsonObject = limitDiscountGoods.toJsonObject();
|
||||
String response = getWxOpenService().post(url, jsonObject.toString());
|
||||
JsonObject respObj = GsonParser.parse(response);
|
||||
Integer taskId = 0;
|
||||
int taskId = 0;
|
||||
if (respObj.get(WxConsts.ERR_CODE).getAsInt() == 0) {
|
||||
taskId = respObj.get("task_id").getAsInt();
|
||||
}
|
||||
@ -1208,7 +1208,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
//成功获取到秒杀活动列表
|
||||
|
||||
JsonArray jsonArray = respObj.get("limited_discount_list").getAsJsonArray();
|
||||
if (jsonArray != null && jsonArray.size() > 0) {
|
||||
if (jsonArray != null && !jsonArray.isEmpty()) {
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JsonObject goodsObj = jsonArray.get(i).getAsJsonObject();
|
||||
LimitDiscountGoods discountGoods = new LimitDiscountGoods();
|
||||
@ -1219,12 +1219,12 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
|
||||
List<LimitDiscountSku> skuList = new ArrayList<>();
|
||||
JsonArray skuArray = goodsObj.get("limited_discount_sku_list").getAsJsonArray();
|
||||
if (skuArray != null && skuArray.size() > 0) {
|
||||
if (skuArray != null && !skuArray.isEmpty()) {
|
||||
for (int j = 0; j < skuArray.size(); j++) {
|
||||
JsonObject skuObj = skuArray.get(i).getAsJsonObject();
|
||||
LimitDiscountSku sku = new LimitDiscountSku();
|
||||
sku.setSkuId(skuObj.get("sku_id").getAsLong());
|
||||
sku.setSalePrice(new BigDecimal(skuObj.get("sale_price").getAsDouble() / 100));
|
||||
sku.setSalePrice(BigDecimal.valueOf(skuObj.get("sale_price").getAsDouble() / 100));
|
||||
sku.setSaleStock(skuObj.get("sale_stock").getAsInt());
|
||||
skuList.add(sku);
|
||||
}
|
||||
|
||||
@ -8,7 +8,6 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.open.api.WxOpenComponentService;
|
||||
import me.chanjar.weixin.open.api.WxOpenFastMaService;
|
||||
import me.chanjar.weixin.open.bean.ma.WxFastMaCategory;
|
||||
import me.chanjar.weixin.open.bean.ma.WxOpenMaApplyOrderPathInfo;
|
||||
import me.chanjar.weixin.open.bean.result.*;
|
||||
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
|
||||
|
||||
|
||||
@ -105,17 +105,7 @@ public class WxOpenInMemoryConfigStorage implements WxOpenConfigStorage {
|
||||
|
||||
@Override
|
||||
public Lock getLockByKey(String key) {
|
||||
Lock lock = locks.get(key);
|
||||
if (lock == null) {
|
||||
synchronized (this) {
|
||||
lock = locks.get(key);
|
||||
if (lock == null) {
|
||||
lock = new ReentrantLock();
|
||||
locks.put(key, lock);
|
||||
}
|
||||
}
|
||||
}
|
||||
return lock;
|
||||
return locks.computeIfAbsent(key, e -> new ReentrantLock());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -3,11 +3,9 @@ package me.chanjar.weixin.open.api.impl;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
|
||||
import lombok.NonNull;
|
||||
import me.chanjar.weixin.common.redis.JedisWxRedisOps;
|
||||
import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps;
|
||||
import me.chanjar.weixin.common.redis.WxRedisOps;
|
||||
|
||||
|
||||
@ -6,7 +6,6 @@ import com.google.gson.JsonObject;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.open.api.WxOpenMaBasicService;
|
||||
import me.chanjar.weixin.open.bean.ma.WxFastMaCategory;
|
||||
import me.chanjar.weixin.open.bean.ma.WxOpenMaApplyOrderPathInfo;
|
||||
import me.chanjar.weixin.open.bean.result.*;
|
||||
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
|
||||
|
||||
|
||||
@ -2,13 +2,11 @@ package me.chanjar.weixin.open.api.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||
import cn.binarywang.wx.miniapp.config.WxMaConfig;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.open.api.WxOpenComponentService;
|
||||
import me.chanjar.weixin.open.api.WxOpenMinishopService;
|
||||
import me.chanjar.weixin.open.api.WxOpenService;
|
||||
import me.chanjar.weixin.open.bean.minishop.*;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenResult;
|
||||
|
||||
@ -24,7 +22,7 @@ public class WxOpenMinishopServiceImpl extends WxMaServiceImpl implements WxOpen
|
||||
this.wxOpenComponentService = wxOpenComponentService;
|
||||
this.appId = appId;
|
||||
this.wxMaConfig = wxMaConfig;
|
||||
log.info("appId: " + appId);
|
||||
log.info("appId: {}", appId);
|
||||
if (wxMaConfig == null) {
|
||||
log.error("WxMaConfig is null");
|
||||
}
|
||||
@ -58,7 +56,7 @@ public class WxOpenMinishopServiceImpl extends WxMaServiceImpl implements WxOpen
|
||||
@Override
|
||||
public String uploadImagePicFile(Integer height, Integer width, File file) throws WxErrorException {
|
||||
String url = UPLOAD_IMG_MINISHOP_FILE_URL + "?access_token="+getAccessToken(true)+"&height="+height+"&width="+width;
|
||||
log.info("upload url: " + url);
|
||||
log.info("upload url: {}", url);
|
||||
String response = post(url, file);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -5,9 +5,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.SneakyThrows;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
|
||||
import me.chanjar.weixin.open.api.WxOpenComponentService;
|
||||
import me.chanjar.weixin.open.api.WxOpenMpService;
|
||||
@ -16,9 +14,7 @@ import me.chanjar.weixin.open.bean.result.WxAmpLinkResult;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenResult;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/007gzs">007</a>
|
||||
|
||||
@ -10,8 +10,6 @@ import me.chanjar.weixin.common.util.http.RequestHttp;
|
||||
import me.chanjar.weixin.open.api.WxOpenComponentService;
|
||||
import me.chanjar.weixin.open.api.WxOpenConfigStorage;
|
||||
import me.chanjar.weixin.open.api.WxOpenService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package me.chanjar.weixin.open.api.impl;
|
||||
|
||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
||||
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.http.*;
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package me.chanjar.weixin.open.bean.icp;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package me.chanjar.weixin.open.bean.icp;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenResult;
|
||||
|
||||
/**
|
||||
|
||||
@ -5,9 +5,6 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 小程序版本信息
|
||||
*
|
||||
|
||||
@ -7,7 +7,6 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package me.chanjar.weixin.open.executor;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import jodd.http.HttpConnectionProvider;
|
||||
import jodd.http.HttpRequest;
|
||||
import jodd.http.HttpResponse;
|
||||
@ -24,7 +23,6 @@ import org.apache.http.entity.mime.HttpMultipartMode;
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@ -28,7 +28,7 @@ import java.util.UUID;
|
||||
* created on 2018-09-13
|
||||
*/
|
||||
public class MaQrCodeApacheHttpRequestExecutor extends MaQrCodeRequestExecutor<CloseableHttpClient, HttpHost> {
|
||||
public MaQrCodeApacheHttpRequestExecutor(RequestHttp requestHttp) {
|
||||
public MaQrCodeApacheHttpRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
|
||||
super(requestHttp);
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ import jodd.http.HttpRequest;
|
||||
import jodd.http.HttpResponse;
|
||||
import jodd.http.ProxyInfo;
|
||||
import jodd.net.MimeTypes;
|
||||
import jodd.util.StringPool;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
@ -27,7 +26,7 @@ import java.util.UUID;
|
||||
* created on 2018-09-13
|
||||
*/
|
||||
public class MaQrCodeJoddHttpRequestExecutor extends MaQrCodeRequestExecutor<HttpConnectionProvider, ProxyInfo> {
|
||||
public MaQrCodeJoddHttpRequestExecutor(RequestHttp requestHttp) {
|
||||
public MaQrCodeJoddHttpRequestExecutor(RequestHttp<HttpConnectionProvider, ProxyInfo> requestHttp) {
|
||||
super(requestHttp);
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ import java.util.UUID;
|
||||
* created on 2018-09-13
|
||||
*/
|
||||
public class MaQrCodeOkhttpRequestExecutor extends MaQrCodeRequestExecutor<OkHttpClient, OkHttpProxyInfo> {
|
||||
public MaQrCodeOkhttpRequestExecutor(RequestHttp requestHttp) {
|
||||
public MaQrCodeOkhttpRequestExecutor(RequestHttp<OkHttpClient, OkHttpProxyInfo> requestHttp) {
|
||||
super(requestHttp);
|
||||
}
|
||||
|
||||
|
||||
@ -3,13 +3,18 @@ package me.chanjar.weixin.open.executor;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import jodd.http.HttpConnectionProvider;
|
||||
import jodd.http.ProxyInfo;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.http.RequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.RequestHttp;
|
||||
import me.chanjar.weixin.common.util.http.ResponseHandler;
|
||||
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
|
||||
import me.chanjar.weixin.open.bean.ma.WxMaQrcodeParam;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
||||
/**
|
||||
* 获得小程序体验QrCode图片 请求执行器.
|
||||
@ -20,7 +25,7 @@ import me.chanjar.weixin.open.bean.ma.WxMaQrcodeParam;
|
||||
public abstract class MaQrCodeRequestExecutor<H, P> implements RequestExecutor<File, WxMaQrcodeParam> {
|
||||
protected RequestHttp<H, P> requestHttp;
|
||||
|
||||
public MaQrCodeRequestExecutor(RequestHttp requestHttp) {
|
||||
public MaQrCodeRequestExecutor(RequestHttp<H, P> requestHttp) {
|
||||
this.requestHttp = requestHttp;
|
||||
}
|
||||
|
||||
@ -29,14 +34,15 @@ public abstract class MaQrCodeRequestExecutor<H, P> implements RequestExecutor<F
|
||||
handler.handle(this.execute(uri, data, wxType));
|
||||
}
|
||||
|
||||
public static RequestExecutor<File, WxMaQrcodeParam> create(RequestHttp requestHttp) throws WxErrorException {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static RequestExecutor<File, WxMaQrcodeParam> create(RequestHttp<?, ?> requestHttp) throws WxErrorException {
|
||||
switch (requestHttp.getRequestType()) {
|
||||
case APACHE_HTTP:
|
||||
return new MaQrCodeApacheHttpRequestExecutor(requestHttp);
|
||||
return new MaQrCodeApacheHttpRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp);
|
||||
case JODD_HTTP:
|
||||
return new MaQrCodeJoddHttpRequestExecutor(requestHttp);
|
||||
return new MaQrCodeJoddHttpRequestExecutor((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp);
|
||||
case OK_HTTP:
|
||||
return new MaQrCodeOkhttpRequestExecutor(requestHttp);
|
||||
return new MaQrCodeOkhttpRequestExecutor((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp);
|
||||
default:
|
||||
throw new WxErrorException("不支持的http框架");
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package me.chanjar.weixin.open.util;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
import com.google.common.io.BaseEncoding;
|
||||
import me.chanjar.weixin.open.api.WxOpenConfigStorage;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
||||
@ -24,10 +24,9 @@ public class WxOpenAuthorizerListResultGsonAdapter implements JsonDeserializer<W
|
||||
wxOpenAuthorizerListResult.setTotalCount(GsonHelper.getInteger(jsonObject, "total_count").intValue());
|
||||
|
||||
List<Map<String, String>> list = new ArrayList<>();
|
||||
Iterator<JsonElement> jsonElementIterator = jsonObject.getAsJsonArray("list").iterator();
|
||||
|
||||
while (jsonElementIterator.hasNext()) {
|
||||
JsonObject authorizer = jsonElementIterator.next().getAsJsonObject();
|
||||
for (JsonElement element : jsonObject.getAsJsonArray("list")) {
|
||||
JsonObject authorizer = element.getAsJsonObject();
|
||||
Map<String, String> authorizerMap = new HashMap<>(10);
|
||||
|
||||
authorizerMap.put(AUTHORIZER_APPID, GsonHelper.getString(authorizer, AUTHORIZER_APPID));
|
||||
|
||||
Reference in New Issue
Block a user