1
0
mirror of synced 2026-02-17 02:37:50 +08:00

🎨 升级部分依赖版本,优化代码,部分代码增加泛型参数

This commit is contained in:
altusea
2025-05-13 15:56:14 +08:00
committed by GitHub
parent a7b007f853
commit 063fbb7f19
263 changed files with 559 additions and 607 deletions

View File

@@ -131,5 +131,5 @@ public interface BaseWxChannelService extends WxService {
*
* @return . request http
*/
RequestHttp getRequestHttp();
RequestHttp<?, ?> getRequestHttp();
}

View File

@@ -66,7 +66,7 @@ public abstract class BaseWxChannelServiceImpl<H, P> implements WxChannelService
private int maxRetryTimes = 5;
@Override
public RequestHttp getRequestHttp() {
public RequestHttp<H, P> getRequestHttp() {
return this;
}
@@ -75,7 +75,7 @@ public abstract class BaseWxChannelServiceImpl<H, P> implements WxChannelService
try {
return SHA1.gen(this.getConfig().getToken(), 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;
}
}
@@ -276,7 +276,7 @@ public abstract class BaseWxChannelServiceImpl<H, P> implements WxChannelService
* @throws WxErrorException 异常
*/
protected String extractAccessToken(String resultContent) throws WxErrorException {
log.debug("access-token response: " + resultContent);
log.debug("access-token response: {}", resultContent);
WxChannelConfig config = this.getConfig();
WxError error = WxError.fromJson(resultContent, WxType.Channel);
if (error.getErrorCode() != 0) {

View File

@@ -28,7 +28,7 @@ import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Assist
public class WxAssistantServiceImpl implements WxAssistantService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
@Override
public WxChannelBaseResponse addWindowProduct(AddWindowProductRequest req) throws WxErrorException {
String resJson = shopService.post(ADD_WINDOW_PRODUCT_URL, "{}");

View File

@@ -29,9 +29,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
public class WxChannelAddressServiceImpl implements WxChannelAddressService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxChannelAddressServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxChannelAddressServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
this.shopService = shopService;
}

View File

@@ -23,9 +23,9 @@ import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Compla
public class WxChannelAfterSaleServiceImpl implements WxChannelAfterSaleService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxChannelAfterSaleServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxChannelAfterSaleServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
this.shopService = shopService;
}

View File

@@ -31,9 +31,9 @@ import me.chanjar.weixin.common.util.http.RequestExecutor;
public class WxChannelBasicServiceImpl implements WxChannelBasicService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxChannelBasicServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxChannelBasicServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
this.shopService = shopService;
}

View File

@@ -33,9 +33,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
public class WxChannelBrandServiceImpl implements WxChannelBrandService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxChannelBrandServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxChannelBrandServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
this.shopService = shopService;
}

View File

@@ -37,9 +37,9 @@ import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor;
public class WxChannelCategoryServiceImpl implements WxChannelCategoryService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxChannelCategoryServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxChannelCategoryServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
this.shopService = shopService;
}
@@ -56,7 +56,7 @@ public class WxChannelCategoryServiceImpl implements WxChannelCategoryService {
try {
pid = Long.parseLong(parentId);
} catch (Throwable e) {
log.error("parentId必须为数字, " + parentId, e);
log.error("parentId必须为数字, {}", parentId, e);
return Collections.emptyList();
}
String reqJson = "{\"f_cat_id\": " + pid + "}";
@@ -80,7 +80,7 @@ public class WxChannelCategoryServiceImpl implements WxChannelCategoryService {
try {
catId = Long.parseLong(id);
} catch (Throwable e) {
log.error("id必须为数字, " + id, e);
log.error("id必须为数字, {}", id, e);
return ResponseUtils.internalError(CategoryDetailResult.class);
}
String reqJson = "{\"cat_id\": " + catId + "}";

View File

@@ -20,9 +20,9 @@ public class WxChannelCompassFinderServiceImpl implements WxChannelCompassFinder
/**
* 微信商店服务
*/
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxChannelCompassFinderServiceImpl(BaseWxChannelServiceImpl shopService) {this.shopService = shopService;}
public WxChannelCompassFinderServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {this.shopService = shopService;}
@Override
public OverallResponse getOverall(String ds) throws WxErrorException {

View File

@@ -41,9 +41,9 @@ public class WxChannelCompassShopServiceImpl implements WxChannelCompassShopServ
/**
* 微信商店服务
*/
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxChannelCompassShopServiceImpl(BaseWxChannelServiceImpl shopService) {this.shopService = shopService;}
public WxChannelCompassShopServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {this.shopService = shopService;}
@Override
public ShopOverallResponse getShopOverall(String ds) throws WxErrorException {

View File

@@ -35,9 +35,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
public class WxChannelCouponServiceImpl implements WxChannelCouponService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxChannelCouponServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxChannelCouponServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
this.shopService = shopService;
}

View File

@@ -24,9 +24,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
@Slf4j
public class WxChannelFreightTemplateServiceImpl implements WxChannelFreightTemplateService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxChannelFreightTemplateServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxChannelFreightTemplateServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
this.shopService = shopService;
}

View File

@@ -54,9 +54,9 @@ public class WxChannelFundServiceImpl implements WxChannelFundService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxChannelFundServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxChannelFundServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
this.shopService = shopService;
}

View File

@@ -27,10 +27,10 @@ public class WxChannelLiveDashboardServiceImpl implements WxChannelLiveDashboard
/**
* 微信商店服务
*/
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
private final ObjectMapper objectMapper = new ObjectMapper();
public WxChannelLiveDashboardServiceImpl(BaseWxChannelServiceImpl shopService) {this.shopService = shopService;}
public WxChannelLiveDashboardServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {this.shopService = shopService;}
@Override
public LiveListResponse getLiveList(Long ds) throws WxErrorException {

View File

@@ -39,9 +39,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
public class WxChannelOrderServiceImpl implements WxChannelOrderService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxChannelOrderServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxChannelOrderServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
this.shopService = shopService;
}

View File

@@ -56,9 +56,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
public class WxChannelProductServiceImpl implements WxChannelProductService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxChannelProductServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxChannelProductServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
this.shopService = shopService;
}

View File

@@ -33,9 +33,9 @@ import me.chanjar.weixin.common.util.json.GsonHelper;
public class WxChannelSharerServiceImpl implements WxChannelSharerService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxChannelSharerServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxChannelSharerServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
this.shopService = shopService;
}

View File

@@ -18,9 +18,9 @@ import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Vip.*;
@Slf4j
public class WxChannelVipServiceImpl implements WxChannelVipService {
private BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxChannelVipServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxChannelVipServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
this.shopService = shopService;
}

View File

@@ -40,9 +40,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
public class WxChannelWarehouseServiceImpl implements WxChannelWarehouseService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxChannelWarehouseServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxChannelWarehouseServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
this.shopService = shopService;
}

View File

@@ -26,7 +26,7 @@ import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Finder
public class WxFinderLiveServiceImpl implements WxFinderLiveService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
@Override
public FinderAttrResponse getFinderAttrByAppid() throws WxErrorException {
String resJson = shopService.post(GET_FINDER_ATTR_BY_APPID, "{}");

View File

@@ -38,7 +38,7 @@ import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.LeadCo
public class WxLeadComponentServiceImpl implements WxLeadComponentService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
private final ObjectMapper objectMapper = new ObjectMapper();
@Override
public LeadInfoResponse getLeadsInfoByComponentId(GetLeadInfoByComponentRequest req) throws WxErrorException {

View File

@@ -32,9 +32,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
public class WxLeagueProductServiceImpl implements WxLeagueProductService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxLeagueProductServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxLeagueProductServiceImpl(BaseWxChannelServiceImpl<?, ?>shopService) {
this.shopService = shopService;
}

View File

@@ -24,9 +24,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
public class WxLeaguePromoterServiceImpl implements WxLeaguePromoterService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxLeaguePromoterServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxLeaguePromoterServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
this.shopService = shopService;
}

View File

@@ -38,9 +38,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
public class WxLeagueSupplierServiceImpl implements WxLeagueSupplierService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxLeagueSupplierServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxLeagueSupplierServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
this.shopService = shopService;
}

View File

@@ -29,9 +29,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
public class WxLeagueWindowServiceImpl implements WxLeagueWindowService {
/** 微信商店服务 */
private final BaseWxChannelServiceImpl shopService;
private final BaseWxChannelServiceImpl<?, ?> shopService;
public WxLeagueWindowServiceImpl(BaseWxChannelServiceImpl shopService) {
public WxLeagueWindowServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
this.shopService = shopService;
}

View File

@@ -25,9 +25,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
public class WxStoreCooperationServiceImpl implements WxStoreCooperationService {
/** 微信小店服务 */
private final BaseWxChannelServiceImpl storeService;
private final BaseWxChannelServiceImpl<?, ?> storeService;
public WxStoreCooperationServiceImpl(BaseWxChannelServiceImpl storeService) {
public WxStoreCooperationServiceImpl(BaseWxChannelServiceImpl<?, ?> storeService) {
this.storeService = storeService;
}

View File

@@ -37,9 +37,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
public class WxStoreHomePageServiceImpl implements WxStoreHomePageService {
/** 微信小店服务 */
private final BaseWxChannelServiceImpl storeService;
private final BaseWxChannelServiceImpl<?, ?> storeService;
public WxStoreHomePageServiceImpl(BaseWxChannelServiceImpl storeService) {
public WxStoreHomePageServiceImpl(BaseWxChannelServiceImpl<?, ?> storeService) {
this.storeService = storeService;
}

View File

@@ -3,6 +3,7 @@ package me.chanjar.weixin.channel.executor;
import java.io.File;
import java.io.IOException;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestExecutor;
@@ -59,8 +60,13 @@ public class ChannelFileUploadRequestExecutor implements RequestExecutor<String,
handler.handle(this.execute(uri, data, wxType));
}
public static RequestExecutor<String, File> create(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
return new ChannelFileUploadRequestExecutor(requestHttp);
public static RequestExecutor<String, File> create(RequestHttp<?, ?> requestHttp) throws WxErrorException {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
return new ChannelFileUploadRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp);
default:
throw new WxErrorException("不支持的http框架");
}
}
}

View File

@@ -103,8 +103,13 @@ public class ChannelMediaDownloadRequestExecutor implements RequestExecutor<Chan
handler.handle(this.execute(uri, data, wxType));
}
public static RequestExecutor<ChannelImageResponse, String> create(RequestHttp requestHttp, File tmpDirFile) {
return new ChannelMediaDownloadRequestExecutor(requestHttp, tmpDirFile);
public static RequestExecutor<ChannelImageResponse, String> create(RequestHttp<?, ?> requestHttp, File tmpDirFile) throws WxErrorException {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
return new ChannelMediaDownloadRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp, tmpDirFile);
default:
throw new WxErrorException("不支持的http框架");
}
}
/**
@@ -138,7 +143,7 @@ public class ChannelMediaDownloadRequestExecutor implements RequestExecutor<Chan
}
private String extractFileNameFromContentString(String content) throws WxErrorException {
if (content == null || content.length() == 0) {
if (content == null || content.isEmpty()) {
return createDefaultFileName();
}
Matcher m = PATTERN.matcher(content);

View File

@@ -137,7 +137,7 @@ public class WxChannelMessageRouter {
}
}
if (matchRules.size() == 0) {
if (matchRules.isEmpty()) {
return null;
}
final List<Future<?>> futures = new ArrayList<>();
@@ -157,7 +157,7 @@ public class WxChannelMessageRouter {
}
}
if (futures.size() > 0) {
if (!futures.isEmpty()) {
this.executorService.submit(() -> {
for (Future<?> future : futures) {
try {