28 Commits

Author SHA1 Message Date
Binary Wang
62f89987c0 🔖 发布 4.7.7.B 测试版本 2025-07-16 20:05:09 +08:00
痴货
990dbba06b 🎨 【开放平台】重构小程序认证及备案相关接口 2025-07-16 11:47:11 +00:00
痴货
d85e04a72a 🎨 starter模块添加 HttpClient 超时配置 2025-07-16 11:46:38 +00:00
Binary Wang
aacfa947be 🎨 统一优化gson adapter类,抽取常量,优化重复代码
Some checks are pending
Publish to Maven Central / build-and-publish (push) Waiting to run
2025-07-16 13:50:55 +08:00
Ryn
3e4ee57e1c 🎨 #3639 【小程序】修复多账号starter不支持设置数据格式,导致消息解析出错的问题 2025-07-16 13:44:50 +08:00
benben
d4cf48d059 🎨 【公众号】删除已下线的新增删除永久图文素材的接口
Some checks failed
Publish to Maven Central / build-and-publish (push) Has been cancelled
2025-07-12 08:59:11 +00:00
ihao
696ce8621e 🆕 #3636【微信支付】增加微信签约、解约结果通知解析的方法 2025-07-12 16:57:50 +08:00
dependabot[bot]
8c8139533d ⬆️ Bump org.apache.commons:commons-lang3 from 3.10 to 3.18.0 2025-07-12 16:49:40 +08:00
zhfkt
84c69d4900 🎨 Add null check for textJsonElement in WxCpUserGsonAdapter 2025-07-04 15:40:29 +08:00
xuxiancan
d52e225626 🎨 #3633【微信支付】创建支付分订单接口请求参数里增加设备信息字段 2025-07-04 15:39:15 +08:00
ihao
686dff6436 🎨 优化微信h5纯签约接口,增加非必填字段判断 2025-07-03 01:55:33 +00:00
Style-lo
92431aabd9 🎨 getConfigKey方法改成public的 2025-07-03 09:53:30 +08:00
Binary Wang
29bc950f92 🎨 为小程序短剧管理服务接口增加接口 2025-07-02 10:35:54 +08:00
Binary Wang
5c74c1d930 🎨 为微信小程序物流退货组件接口增加注释文档 2025-07-02 10:35:54 +08:00
Binary Wang
52d0b2fc1c 🎨 为小程序虚拟支付接口类增加注释文档 2025-07-02 10:35:54 +08:00
Binary Wang
5b816242a4 🎨 优化小程序数据分析接口类的注释文档 2025-07-02 10:35:54 +08:00
Binary Wang
a45f0ac048 🎨 优化小程序云开发接口类的注释文档 2025-07-02 10:35:54 +08:00
Binary Wang
4731479b93 🎨 优化小程序接口注释文档 2025-07-02 10:35:54 +08:00
benben
cc344f105e 🎨 #3624 【企业微信】企微微盘API相关接口去掉废弃的userId参数 2025-07-02 10:33:56 +08:00
Well
172b96444f 🎨 #3626 【微信支付】创建代金券批次接口新增字段,包括背景色、卡包跳转目标、小程序 appid 与 path等 2025-07-02 10:31:26 +08:00
jinceon
b3b8c273c7 🎨 【企业微信】增加“审批申请状态变化回调通知”事件类型 2025-06-28 23:07:36 +08:00
大粽子
b6d489e9c8 📝 修改赞助商信息 2025-06-28 23:07:36 +08:00
zhoushi1
72266c3aeb 🎨 #3627 【开放平台】小程序三方平台代上传代码提交额外信息对象新增requiredPrivateInfos信息
Co-authored-by: zhoushi1 <qiannanyou9@gmail.com>
2025-06-28 20:57:37 +08:00
altusea
ccbfa98864 🎨 添加 Apache HttpComponents Client 5.x 为可选的 http client
Some checks failed
Publish to Maven Central / build-and-publish (push) Has been cancelled
2025-06-09 14:29:35 +08:00
buaazyl
bf35797b91 :art:【小程序】发订阅消息的“43101用户未订阅消息”异常日志调整为debug 2025-06-09 14:28:56 +08:00
buaazyl
41081561b5 :art:【小程序】不再打印发订阅消息的“43101用户未订阅消息”警告日志 2025-06-09 11:19:37 +08:00
Binary Wang
8878f06c1e 🎨 修复单元测试代码
Some checks failed
Publish to Maven Central / build-and-publish (push) Has been cancelled
2025-06-06 17:07:52 +08:00
Zeyes Lee
22d288f6cd 🎨 #3609 【视频号】微信小店获取售后单接口返回新增换货相关的数据 2025-06-06 16:55:46 +08:00
221 changed files with 5594 additions and 1639 deletions

View File

@@ -53,8 +53,8 @@
</a>
</td>
<td align="center">
<a href="#" target="_blank">
<img height="120" src="images/banners/aliyun.jpg" alt="ad">
<a href="https://www.crmeb.com/xiazai" target="_blank">
<img height="120" src="https://crmebjavamer.oss-cn-beijing.aliyuncs.com/crmebimage/gitee/WechatIMG202.jpg" alt="ad">
</a>
</td>
</tr>

10
pom.xml
View File

@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
<packaging>pom</packaging>
<name>WxJava - Weixin/Wechat Java SDK</name>
<description>微信开发Java SDK</description>
@@ -154,7 +154,7 @@
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.5.0</version>
<version>4.12.0</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -187,7 +187,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.10</version>
<version>3.18.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@@ -212,7 +212,7 @@
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>2.18.1</version>
<version>2.18.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -333,7 +333,7 @@
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk18on</artifactId>
<version>1.78.1</version>
<version>1.80</version>
</dependency>
</dependencies>
</dependencyManagement>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<packaging>pom</packaging>
<artifactId>wx-java-solon-plugins</artifactId>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -8,6 +8,7 @@ import com.binarywang.solon.wxjava.channel.service.WxChannelMultiServicesImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.channel.api.WxChannelService;
import me.chanjar.weixin.channel.api.impl.WxChannelServiceHttpComponentsImpl;
import me.chanjar.weixin.channel.api.impl.WxChannelServiceHttpClientImpl;
import me.chanjar.weixin.channel.api.impl.WxChannelServiceImpl;
import me.chanjar.weixin.channel.config.WxChannelConfig;
@@ -84,6 +85,9 @@ public abstract class AbstractWxChannelConfiguration {
case HTTP_CLIENT:
wxChannelService = new WxChannelServiceHttpClientImpl();
break;
case HTTP_COMPONENTS:
wxChannelService = new WxChannelServiceHttpComponentsImpl();
break;
default:
wxChannelService = new WxChannelServiceImpl();
break;

View File

@@ -11,6 +11,10 @@ public enum HttpClientType {
* HttpClient
*/
HTTP_CLIENT,
/**
* HttpComponents
*/
HTTP_COMPONENTS
// WxChannelServiceOkHttpImpl 实现经测试无法正常完成业务固暂不支持OK_HTTP方式
// /**
// * OkHttp.

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -7,10 +7,7 @@ import com.binarywang.solon.wxjava.cp_multi.service.WxCpMultiServicesImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.api.impl.WxCpServiceApacheHttpClientImpl;
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
import me.chanjar.weixin.cp.api.impl.WxCpServiceJoddHttpImpl;
import me.chanjar.weixin.cp.api.impl.WxCpServiceOkHttpImpl;
import me.chanjar.weixin.cp.api.impl.*;
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
import org.apache.commons.lang3.StringUtils;
@@ -96,6 +93,9 @@ public abstract class AbstractWxCpConfiguration {
case HTTP_CLIENT:
wxCpService = new WxCpServiceApacheHttpClientImpl();
break;
case HTTP_COMPONENTS:
wxCpService = new WxCpServiceHttpComponentsImpl();
break;
default:
wxCpService = new WxCpServiceImpl();
break;

View File

@@ -117,6 +117,10 @@ public class WxCpMultiProperties implements Serializable {
* HttpClient
*/
HTTP_CLIENT,
/**
* HttpComponents
*/
HTTP_COMPONENTS,
/**
* OkHttp
*/

View File

@@ -4,7 +4,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>wx-java-solon-plugins</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<packaging>pom</packaging>
<artifactId>wx-java-spring-boot-starters</artifactId>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -108,12 +108,12 @@ public abstract class AbstractWxMaConfiguration {
return wxMaService;
}
private void configApp(WxMaDefaultConfigImpl config, WxMaSingleProperties corpProperties) {
String appId = corpProperties.getAppId();
String appSecret = corpProperties.getAppSecret();
String token = corpProperties.getToken();
String aesKey = corpProperties.getAesKey();
boolean useStableAccessToken = corpProperties.isUseStableAccessToken();
private void configApp(WxMaDefaultConfigImpl config, WxMaSingleProperties properties) {
String appId = properties.getAppId();
String appSecret = properties.getAppSecret();
String token = properties.getToken();
String aesKey = properties.getAesKey();
boolean useStableAccessToken = properties.isUseStableAccessToken();
config.setAppid(appId);
config.setSecret(appSecret);
@@ -123,6 +123,7 @@ public abstract class AbstractWxMaConfiguration {
if (StringUtils.isNotBlank(aesKey)) {
config.setAesKey(aesKey);
}
config.setMsgDataFormat(properties.getMsgDataFormat());
config.useStableAccessToken(useStableAccessToken);
}

View File

@@ -33,6 +33,11 @@ public class WxMaSingleProperties implements Serializable {
*/
private String aesKey;
/**
* 消息格式XML或者JSON.
*/
private String msgDataFormat;
/**
* 是否使用稳定版 Access Token
*/

View File

@@ -4,7 +4,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -2,6 +2,8 @@ package com.binarywang.spring.starter.wxjava.miniapp.config.storage;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import com.binarywang.spring.starter.wxjava.miniapp.properties.WxMaProperties;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
import org.apache.commons.lang3.StringUtils;
/**
@@ -10,6 +12,7 @@ import org.apache.commons.lang3.StringUtils;
public abstract class AbstractWxMaConfigStorageConfiguration {
protected WxMaDefaultConfigImpl config(WxMaDefaultConfigImpl config, WxMaProperties properties) {
WxMaProperties.ConfigStorage storage = properties.getConfigStorage();
config.setAppid(StringUtils.trimToNull(properties.getAppid()));
config.setSecret(StringUtils.trimToNull(properties.getSecret()));
config.setToken(StringUtils.trimToNull(properties.getToken()));
@@ -25,6 +28,19 @@ public abstract class AbstractWxMaConfigStorageConfiguration {
config.setHttpProxyPort(configStorageProperties.getHttpProxyPort());
}
// 设置自定义的HttpClient超时配置
ApacheHttpClientBuilder clientBuilder = config.getApacheHttpClientBuilder();
if (clientBuilder == null) {
clientBuilder = DefaultApacheHttpClientBuilder.get();
}
if (clientBuilder instanceof DefaultApacheHttpClientBuilder) {
DefaultApacheHttpClientBuilder defaultBuilder = (DefaultApacheHttpClientBuilder) clientBuilder;
defaultBuilder.setConnectionTimeout(storage.getConnectionTimeout());
defaultBuilder.setSoTimeout(storage.getSoTimeout());
defaultBuilder.setConnectionRequestTimeout(storage.getConnectionRequestTimeout());
config.setApacheHttpClientBuilder(defaultBuilder);
}
int maxRetryTimes = configStorageProperties.getMaxRetryTimes();
if (configStorageProperties.getMaxRetryTimes() < 0) {
maxRetryTimes = 0;

View File

@@ -112,6 +112,21 @@ public class WxMaProperties {
* </pre>
*/
private int maxRetryTimes = 5;
/**
* 连接超时时间,单位毫秒
*/
private int connectionTimeout = 5000;
/**
* 读数据超时时间即socketTimeout单位毫秒
*/
private int soTimeout = 5000;
/**
* 从连接池获取链接的超时时间,单位毫秒
*/
private int connectionRequestTimeout = 5000;
}
}

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -7,10 +7,7 @@ import com.binarywang.spring.starter.wxjava.mp.service.WxMpMultiServicesImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceHttpClientImpl;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.api.impl.WxMpServiceJoddHttpImpl;
import me.chanjar.weixin.mp.api.impl.WxMpServiceOkHttpImpl;
import me.chanjar.weixin.mp.api.impl.*;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.WxMpHostConfig;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
@@ -91,6 +88,9 @@ public abstract class AbstractWxMpConfiguration {
case HTTP_CLIENT:
wxMpService = new WxMpServiceHttpClientImpl();
break;
case HTTP_COMPONENTS:
wxMpService = new WxMpServiceHttpComponentsImpl();
break;
default:
wxMpService = new WxMpServiceImpl();
break;

View File

@@ -142,6 +142,10 @@ public class WxMpMultiProperties implements Serializable {
* HttpClient
*/
HTTP_CLIENT,
/**
* HttpComponents
*/
HTTP_COMPONENTS,
/**
* OkHttp
*/

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -9,6 +9,8 @@ import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.redis.JedisWxRedisOps;
import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps;
import me.chanjar.weixin.common.redis.WxRedisOps;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.WxMpHostConfig;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
@@ -122,6 +124,19 @@ public class WxMpStorageAutoConfiguration {
config.setSecret(properties.getSecret());
config.setToken(properties.getToken());
config.setAesKey(properties.getAesKey());
WxMpProperties.ConfigStorage storage = properties.getConfigStorage();
// 设置自定义的HttpClient超时配置
ApacheHttpClientBuilder clientBuilder = config.getApacheHttpClientBuilder();
if (clientBuilder == null) {
clientBuilder = DefaultApacheHttpClientBuilder.get();
}
if (clientBuilder instanceof DefaultApacheHttpClientBuilder) {
DefaultApacheHttpClientBuilder defaultBuilder = (DefaultApacheHttpClientBuilder) clientBuilder;
defaultBuilder.setConnectionTimeout(storage.getConnectionTimeout());
defaultBuilder.setSoTimeout(storage.getSoTimeout());
defaultBuilder.setConnectionRequestTimeout(storage.getConnectionRequestTimeout());
config.setApacheHttpClientBuilder(defaultBuilder);
}
config.setUseStableAccessToken(wxMpProperties.isUseStableAccessToken());
config.setHttpProxyHost(configStorageProperties.getHttpProxyHost());
config.setHttpProxyUsername(configStorageProperties.getHttpProxyUsername());

View File

@@ -102,6 +102,21 @@ public class WxMpProperties {
*/
private String httpProxyPassword;
/**
* 连接超时时间,单位毫秒
*/
private int connectionTimeout = 5000;
/**
* 读数据超时时间即socketTimeout单位毫秒
*/
private int soTimeout = 1;
/**
* 从连接池获取链接的超时时间,单位毫秒
*/
private int connectionRequestTimeout = 5000;
}
}

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -1,6 +1,8 @@
package com.binarywang.spring.starter.wxjava.open.config.storage;
import com.binarywang.spring.starter.wxjava.open.properties.WxOpenProperties;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage;
/**
@@ -28,6 +30,20 @@ public abstract class AbstractWxOpenConfigStorageConfiguration {
}
config.setRetrySleepMillis(retrySleepMillis);
config.setMaxRetryTimes(maxRetryTimes);
// 设置自定义的HttpClient超时配置
ApacheHttpClientBuilder clientBuilder = config.getApacheHttpClientBuilder();
if (clientBuilder == null) {
clientBuilder = DefaultApacheHttpClientBuilder.get();
}
if (clientBuilder instanceof DefaultApacheHttpClientBuilder) {
DefaultApacheHttpClientBuilder defaultBuilder = (DefaultApacheHttpClientBuilder) clientBuilder;
defaultBuilder.setConnectionTimeout(storage.getConnectionTimeout());
defaultBuilder.setSoTimeout(storage.getSoTimeout());
defaultBuilder.setConnectionRequestTimeout(storage.getConnectionRequestTimeout());
config.setApacheHttpClientBuilder(defaultBuilder);
}
return config;
}
}

View File

@@ -108,6 +108,21 @@ public class WxOpenProperties {
*/
private int maxRetryTimes = 5;
/**
* 连接超时时间,单位毫秒
*/
private int connectionTimeout = 5000;
/**
* 读数据超时时间即socketTimeout单位毫秒
*/
private int soTimeout = 1;
/**
* 从连接池获取链接的超时时间,单位毫秒
*/
private int connectionRequestTimeout = 5000;
}
public enum StorageType {

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<artifactId>weixin-graal</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<artifactId>weixin-java-channel</artifactId>
@@ -14,7 +14,7 @@
<description>微信视频号/微信小店 Java SDK</description>
<properties>
<jackson.version>2.18.1</jackson.version>
<jackson.version>2.18.4</jackson.version>
</properties>
<dependencies>
@@ -29,6 +29,11 @@
<artifactId>jodd-http</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>

View File

@@ -56,7 +56,7 @@ public class WxChannelBasicServiceImpl implements WxChannelBasicService {
public ChannelImageInfo uploadImg(int respType, File file, int height, int width) throws WxErrorException {
String url = IMG_UPLOAD_URL + "?upload_type=0&resp_type=" + respType + "&height=" + height + "&width=" + width;
RequestExecutor<String, File> executor = ChannelFileUploadRequestExecutor.create(shopService);
String resJson = (String) shopService.execute(executor, url, file);
String resJson = shopService.execute(executor, url, file);
UploadImageResponse response = ResponseUtils.decode(resJson, UploadImageResponse.class);
return response.getImgInfo();
}
@@ -64,19 +64,19 @@ public class WxChannelBasicServiceImpl implements WxChannelBasicService {
@Override
public QualificationFileResponse uploadQualificationFile(File file) throws WxErrorException {
RequestExecutor<String, File> executor = ChannelFileUploadRequestExecutor.create(shopService);
String resJson = (String) shopService.execute(executor, UPLOAD_QUALIFICATION_FILE, file);
String resJson = shopService.execute(executor, UPLOAD_QUALIFICATION_FILE, file);
return ResponseUtils.decode(resJson, QualificationFileResponse.class);
}
@Override
public ChannelImageResponse getImg(String mediaId) throws WxErrorException {
String appId = shopService.getConfig().getAppid();
ChannelImageResponse rs = null;
ChannelImageResponse rs;
try {
String url = GET_IMG_URL + "?media_id=" + mediaId;
RequestExecutor<ChannelImageResponse, String> executor = ChannelMediaDownloadRequestExecutor.create(shopService,
Files.createTempDirectory("wxjava-channel-" + appId).toFile());
rs = (ChannelImageResponse) shopService.execute(executor, url, null);
rs = shopService.execute(executor, url, null);
} catch (IOException e) {
throw new WxErrorException(WxError.builder().errorMsg(e.getMessage()).build(), e);
}

View File

@@ -0,0 +1,113 @@
package me.chanjar.weixin.channel.api.impl;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.channel.bean.token.StableTokenParam;
import me.chanjar.weixin.channel.config.WxChannelConfig;
import me.chanjar.weixin.channel.util.JsonUtils;
import me.chanjar.weixin.common.util.http.HttpClientType;
import me.chanjar.weixin.common.util.http.apache.ApacheBasicResponseHandler;
import me.chanjar.weixin.common.util.http.hc.BasicResponseHandler;
import me.chanjar.weixin.common.util.http.hc.DefaultHttpComponentsClientBuilder;
import me.chanjar.weixin.common.util.http.hc.HttpComponentsClientBuilder;
import org.apache.commons.lang3.StringUtils;
import org.apache.hc.client5.http.classic.HttpClient;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.io.entity.StringEntity;
import java.io.IOException;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.GET_ACCESS_TOKEN_URL;
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.GET_STABLE_ACCESS_TOKEN_URL;
/**
* @author altusea
*/
@Slf4j
public class WxChannelServiceHttpComponentsImpl extends BaseWxChannelServiceImpl<HttpClient, HttpHost> {
private CloseableHttpClient httpClient;
private HttpHost httpProxy;
@Override
public void initHttp() {
WxChannelConfig config = this.getConfig();
HttpComponentsClientBuilder apacheHttpClientBuilder = DefaultHttpComponentsClientBuilder.get();
apacheHttpClientBuilder.httpProxyHost(config.getHttpProxyHost())
.httpProxyPort(config.getHttpProxyPort())
.httpProxyUsername(config.getHttpProxyUsername())
.httpProxyPassword(config.getHttpProxyPassword().toCharArray());
if (config.getHttpProxyHost() != null && config.getHttpProxyPort() > 0) {
this.httpProxy = new HttpHost(config.getHttpProxyHost(), config.getHttpProxyPort());
}
this.httpClient = apacheHttpClientBuilder.build();
}
@Override
public CloseableHttpClient getRequestHttpClient() {
return httpClient;
}
@Override
public HttpHost getRequestHttpProxy() {
return httpProxy;
}
@Override
public HttpClientType getRequestType() {
return HttpClientType.HTTP_COMPONENTS;
}
@Override
protected String doGetAccessTokenRequest() throws IOException {
WxChannelConfig config = this.getConfig();
String url = StringUtils.isNotEmpty(config.getAccessTokenUrl()) ? config.getAccessTokenUrl() :
StringUtils.isNotEmpty(config.getApiHostUrl()) ?
GET_ACCESS_TOKEN_URL.replace("https://api.weixin.qq.com", config.getApiHostUrl()) : GET_ACCESS_TOKEN_URL;
url = String.format(url, config.getAppid(), config.getSecret());
HttpGet httpGet = new HttpGet(url);
if (this.getRequestHttpProxy() != null) {
RequestConfig requestConfig = RequestConfig.custom().setProxy(this.getRequestHttpProxy()).build();
httpGet.setConfig(requestConfig);
}
return getRequestHttpClient().execute(httpGet, BasicResponseHandler.INSTANCE);
}
/**
* 获取稳定版接口调用凭据
*
* @param forceRefresh false 为普通模式, true为强制刷新模式
* @return 返回json的字符串
* @throws IOException the io exception
*/
@Override
protected String doGetStableAccessTokenRequest(boolean forceRefresh) throws IOException {
WxChannelConfig config = this.getConfig();
String url = GET_STABLE_ACCESS_TOKEN_URL;
HttpPost httpPost = new HttpPost(url);
if (this.getRequestHttpProxy() != null) {
RequestConfig requestConfig = RequestConfig.custom().setProxy(this.getRequestHttpProxy()).build();
httpPost.setConfig(requestConfig);
}
StableTokenParam requestParam = new StableTokenParam();
requestParam.setAppId(config.getAppid());
requestParam.setSecret(config.getSecret());
requestParam.setGrantType("client_credential");
requestParam.setForceRefresh(forceRefresh);
String requestJson = JsonUtils.encode(requestParam);
assert requestJson != null;
httpPost.setEntity(new StringEntity(requestJson, ContentType.APPLICATION_JSON));
return getRequestHttpClient().execute(httpPost, BasicResponseHandler.INSTANCE);
}
}

View File

@@ -0,0 +1,35 @@
package me.chanjar.weixin.channel.bean.after;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import lombok.Data;
import lombok.NoArgsConstructor;
import me.chanjar.weixin.channel.bean.base.AddressInfo;
/**
* 换货类型的发货物流信息
*
* @author <a href="https://github.com/lixize">Zeyes</a>
*/
@Data
@NoArgsConstructor
public class AfterSaleExchangeDeliveryInfo implements Serializable {
private static final long serialVersionUID = 3039216368034112038L;
/** 快递单号 */
@JsonProperty("waybill_id")
private String waybillId;
/** 物流公司id */
@JsonProperty("delivery_id")
private String deliveryId;
/** 物流公司名称 */
@JsonProperty("delivery_name")
private String deliveryName;
/** 地址信息 */
@JsonProperty("address_info")
private AddressInfo addressInfo;
}

View File

@@ -0,0 +1,34 @@
package me.chanjar.weixin.channel.bean.after;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 换货商品信息
*
* @author <a href="https://github.com/lixize">Zeyes</a>
*/
@Data
@NoArgsConstructor
public class AfterSaleExchangeProductInfo implements Serializable {
private static final long serialVersionUID = -1341436607011117854L;
/** 商品spuid */
@JsonProperty("product_id")
private String productId;
/** 旧商品skuid */
@JsonProperty("old_sku_id")
private String oldSkuId;
/** 新商品skuid */
@JsonProperty("new_sku_id")
private String newSkuId;
/** 数量 */
@JsonProperty("product_cnt")
private String productCnt;
}

View File

@@ -86,4 +86,16 @@ public class AfterSaleInfo implements Serializable {
/** 仅在待商家审核退款退货申请或收货期间返回,表示操作剩余时间(秒数)*/
@JsonProperty("deadline")
private Long deadline;
/** 售后换货商品信息 */
@JsonProperty("exchange_product_info")
private AfterSaleExchangeProductInfo exchangeProductInfo;
/** 售后换货物流信息 */
@JsonProperty("exchange_delivery_info")
private AfterSaleExchangeDeliveryInfo exchangeDeliveryInfo;
/** 售后换货虚拟号码信息 */
@JsonProperty("virtual_tel_num_info")
private AfterSaleVirtualNumberInfo virtualTelNumInfo;
}

View File

@@ -0,0 +1,26 @@
package me.chanjar.weixin.channel.bean.after;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 虚拟号码信息
*
* @author <a href="https://github.com/lixize">Zeyes</a>
*/
@Data
@NoArgsConstructor
public class AfterSaleVirtualNumberInfo implements Serializable {
private static final long serialVersionUID = -5756618937333859985L;
/** 虚拟号码 */
@JsonProperty("virtual_tel_number")
private String virtualTelNumber;
/** 虚拟号码过期时间 */
@JsonProperty("virtual_tel_expire_time")
private Long virtualTelExpireTime;
}

View File

@@ -0,0 +1,47 @@
package me.chanjar.weixin.channel.executor;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.ResponseHandler;
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.File;
import java.io.IOException;
public class ApacheHttpChannelFileUploadRequestExecutor extends ChannelFileUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public ApacheHttpChannelFileUploadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (file != null) {
HttpEntity entity = MultipartEntityBuilder
.create()
.addBinaryBody("media", file)
.setMode(HttpMultipartMode.RFC6532)
.build();
httpPost.setEntity(entity);
}
return requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
}
@Override
public void execute(String uri, File data, ResponseHandler<String> handler, WxType wxType)
throws WxErrorException, IOException {
handler.handle(this.execute(uri, data, wxType));
}
}

View File

@@ -0,0 +1,90 @@
package me.chanjar.weixin.channel.executor;
import me.chanjar.weixin.channel.bean.image.ChannelImageResponse;
import me.chanjar.weixin.channel.util.JsonUtils;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.ResponseHandler;
import me.chanjar.weixin.common.util.http.apache.InputStreamResponseHandler;
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.Header;
import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.entity.ContentType;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
public class ApacheHttpChannelMediaDownloadRequestExecutor extends ChannelMediaDownloadRequestExecutor<CloseableHttpClient, HttpHost> {
public ApacheHttpChannelMediaDownloadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp, File tmpDirFile) {
super(requestHttp, tmpDirFile);
}
@Override
public ChannelImageResponse execute(String uri, String data, WxType wxType) throws WxErrorException, IOException {
if (data != null) {
if (uri.indexOf('?') == -1) {
uri += '?';
}
uri += uri.endsWith("?") ? data : '&' + data;
}
HttpGet httpGet = new HttpGet(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpGet.setConfig(config);
}
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpGet);
InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response)) {
Header[] contentTypeHeader = response.getHeaders("Content-Type");
String contentType = null;
if (contentTypeHeader != null && contentTypeHeader.length > 0) {
contentType = contentTypeHeader[0].getValue();
if (contentType.startsWith(ContentType.APPLICATION_JSON.getMimeType())) {
// application/json; encoding=utf-8 下载媒体文件出错
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
return JsonUtils.decode(responseContent, ChannelImageResponse.class);
}
}
String fileName = this.getFileName(response);
if (StringUtils.isBlank(fileName)) {
fileName = String.valueOf(System.currentTimeMillis());
}
String baseName = FilenameUtils.getBaseName(fileName);
if (StringUtils.isBlank(fileName) || baseName.length() < 3) {
baseName = String.valueOf(System.currentTimeMillis());
}
String extension = FilenameUtils.getExtension(fileName);
if (StringUtils.isBlank(extension)) {
extension = "unknown";
}
File file = createTmpFile(inputStream, baseName, extension, tmpDirFile);
return new ChannelImageResponse(file, contentType);
}
}
private String getFileName(CloseableHttpResponse response) throws WxErrorException {
Header[] contentDispositionHeader = response.getHeaders("Content-disposition");
if (contentDispositionHeader == null || contentDispositionHeader.length == 0) {
return createDefaultFileName();
}
return this.extractFileNameFromContentString(contentDispositionHeader[0].getValue());
}
@Override
public void execute(String uri, String data, ResponseHandler<ChannelImageResponse> handler, WxType wxType)
throws WxErrorException, IOException {
handler.handle(this.execute(uri, data, wxType));
}
}

View File

@@ -1,66 +1,34 @@
package me.chanjar.weixin.channel.executor;
import me.chanjar.weixin.common.enums.WxType;
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.apache.Utf8ResponseHandler;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.File;
import java.io.IOException;
/**
* 视频号小店 图片上传接口 请求的参数是File, 返回的结果是String
*
* @author <a href="https://github.com/lixize">Zeyes</a>
*/
public class ChannelFileUploadRequestExecutor implements RequestExecutor<String, File> {
public abstract class ChannelFileUploadRequestExecutor<H, P> implements RequestExecutor<String, File> {
protected RequestHttp<CloseableHttpClient, HttpHost> requestHttp;
protected RequestHttp<H, P> requestHttp;
public ChannelFileUploadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
public ChannelFileUploadRequestExecutor(RequestHttp<H, P> requestHttp) {
this.requestHttp = requestHttp;
}
@Override
public String execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (file != null) {
HttpEntity entity = MultipartEntityBuilder
.create()
.addBinaryBody("media", file)
.setMode(HttpMultipartMode.RFC6532)
.build();
httpPost.setEntity(entity);
}
return requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
}
@Override
public void execute(String uri, File data, ResponseHandler<String> handler, WxType wxType)
throws WxErrorException, IOException {
handler.handle(this.execute(uri, data, wxType));
}
@SuppressWarnings("unchecked")
public static RequestExecutor<String, File> create(RequestHttp<?, ?> requestHttp) throws WxErrorException {
public static RequestExecutor<String, File> create(RequestHttp<?, ?> requestHttp) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
return new ChannelFileUploadRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp);
return new ApacheHttpChannelFileUploadRequestExecutor(
(RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp);
case HTTP_COMPONENTS:
return new HttpComponentsChannelFileUploadRequestExecutor(
(RequestHttp<org.apache.hc.client5.http.impl.classic.CloseableHttpClient, org.apache.hc.core5.http.HttpHost>) requestHttp);
default:
throw new WxErrorException("不支持的http框架");
throw new IllegalArgumentException("不支持的http执行器类型:" + requestHttp.getRequestType());
}
}

View File

@@ -1,25 +1,9 @@
package me.chanjar.weixin.channel.executor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.channel.bean.image.ChannelImageResponse;
import me.chanjar.weixin.channel.util.JsonUtils;
import me.chanjar.weixin.common.enums.WxType;
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.apache.InputStreamResponseHandler;
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.Header;
import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.entity.ContentType;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.File;
import java.io.IOException;
@@ -36,77 +20,29 @@ import static org.apache.commons.io.FileUtils.openOutputStream;
*
* @author <a href="https://github.com/lixize">Zeyes</a>
*/
@Slf4j
public class ChannelMediaDownloadRequestExecutor implements RequestExecutor<ChannelImageResponse, String> {
public abstract class ChannelMediaDownloadRequestExecutor<H, P> implements RequestExecutor<ChannelImageResponse, String> {
protected RequestHttp<CloseableHttpClient, HttpHost> requestHttp;
protected RequestHttp<H, P> requestHttp;
protected File tmpDirFile;
private static final Pattern PATTERN = Pattern.compile(".*filename=\"(.*)\"");
public ChannelMediaDownloadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp, File tmpDirFile) {
public ChannelMediaDownloadRequestExecutor(RequestHttp<H, P> requestHttp, File tmpDirFile) {
this.requestHttp = requestHttp;
this.tmpDirFile = tmpDirFile;
}
@Override
public ChannelImageResponse execute(String uri, String data, WxType wxType) throws WxErrorException, IOException {
if (data != null) {
if (uri.indexOf('?') == -1) {
uri += '?';
}
uri += uri.endsWith("?") ? data : '&' + data;
}
HttpGet httpGet = new HttpGet(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpGet.setConfig(config);
}
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpGet);
InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response)) {
Header[] contentTypeHeader = response.getHeaders("Content-Type");
String contentType = null;
if (contentTypeHeader != null && contentTypeHeader.length > 0) {
contentType = contentTypeHeader[0].getValue();
if (contentType.startsWith(ContentType.APPLICATION_JSON.getMimeType())) {
// application/json; encoding=utf-8 下载媒体文件出错
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
return JsonUtils.decode(responseContent, ChannelImageResponse.class);
}
}
String fileName = this.getFileName(response);
if (StringUtils.isBlank(fileName)) {
fileName = String.valueOf(System.currentTimeMillis());
}
String baseName = FilenameUtils.getBaseName(fileName);
if (StringUtils.isBlank(fileName) || baseName.length() < 3) {
baseName = String.valueOf(System.currentTimeMillis());
}
String extension = FilenameUtils.getExtension(fileName);
if (StringUtils.isBlank(extension)) {
extension = "unknown";
}
File file = createTmpFile(inputStream, baseName, extension, tmpDirFile);
return new ChannelImageResponse(file, contentType);
}
}
@Override
public void execute(String uri, String data, ResponseHandler<ChannelImageResponse> handler, WxType wxType)
throws WxErrorException, IOException {
handler.handle(this.execute(uri, data, wxType));
}
public static RequestExecutor<ChannelImageResponse, String> create(RequestHttp<?, ?> requestHttp, File tmpDirFile) throws WxErrorException {
@SuppressWarnings("unchecked")
public static RequestExecutor<ChannelImageResponse, String> create(RequestHttp<?, ?> requestHttp, File tmpDirFile) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
return new ChannelMediaDownloadRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp, tmpDirFile);
return new ApacheHttpChannelMediaDownloadRequestExecutor(
(RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp, tmpDirFile);
case HTTP_COMPONENTS:
return new HttpComponentsChannelMediaDownloadRequestExecutor(
(RequestHttp<org.apache.hc.client5.http.impl.classic.CloseableHttpClient, org.apache.hc.core5.http.HttpHost>) requestHttp, tmpDirFile);
default:
throw new WxErrorException("不支持的http框架");
throw new IllegalArgumentException("不支持的http执行器类型:" + requestHttp.getRequestType());
}
}
@@ -128,19 +64,11 @@ public class ChannelMediaDownloadRequestExecutor implements RequestExecutor<Chan
return resultFile;
}
private String getFileName(CloseableHttpResponse response) throws WxErrorException {
Header[] contentDispositionHeader = response.getHeaders("Content-disposition");
if (contentDispositionHeader == null || contentDispositionHeader.length == 0) {
return createDefaultFileName();
}
return this.extractFileNameFromContentString(contentDispositionHeader[0].getValue());
}
private String createDefaultFileName() {
protected String createDefaultFileName() {
return UUID.randomUUID().toString();
}
private String extractFileNameFromContentString(String content) throws WxErrorException {
protected String extractFileNameFromContentString(String content) {
if (content == null || content.isEmpty()) {
return createDefaultFileName();
}

View File

@@ -0,0 +1,47 @@
package me.chanjar.weixin.channel.executor;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.ResponseHandler;
import me.chanjar.weixin.common.util.http.hc.Utf8ResponseHandler;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.entity.mime.HttpMultipartMode;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpHost;
import java.io.File;
import java.io.IOException;
public class HttpComponentsChannelFileUploadRequestExecutor extends ChannelFileUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public HttpComponentsChannelFileUploadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (file != null) {
HttpEntity entity = MultipartEntityBuilder
.create()
.addBinaryBody("media", file)
.setMode(HttpMultipartMode.EXTENDED)
.build();
httpPost.setEntity(entity);
}
return requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
}
@Override
public void execute(String uri, File data, ResponseHandler<String> handler, WxType wxType)
throws WxErrorException, IOException {
handler.handle(this.execute(uri, data, wxType));
}
}

View File

@@ -0,0 +1,94 @@
package me.chanjar.weixin.channel.executor;
import me.chanjar.weixin.channel.bean.image.ChannelImageResponse;
import me.chanjar.weixin.channel.util.JsonUtils;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.ResponseHandler;
import me.chanjar.weixin.common.util.http.hc.InputStreamResponseHandler;
import me.chanjar.weixin.common.util.http.hc.Utf8ResponseHandler;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.hc.client5.http.ClientProtocolException;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
public class HttpComponentsChannelMediaDownloadRequestExecutor extends ChannelMediaDownloadRequestExecutor<CloseableHttpClient, HttpHost> {
public HttpComponentsChannelMediaDownloadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp, File tmpDirFile) {
super(requestHttp, tmpDirFile);
}
@Override
public ChannelImageResponse execute(String uri, String data, WxType wxType) throws WxErrorException, IOException {
if (data != null) {
if (uri.indexOf('?') == -1) {
uri += '?';
}
uri += uri.endsWith("?") ? data : '&' + data;
}
HttpGet httpGet = new HttpGet(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpGet.setConfig(config);
}
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpGet);
InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response)) {
Header[] contentTypeHeader = response.getHeaders("Content-Type");
String contentType = null;
if (contentTypeHeader != null && contentTypeHeader.length > 0) {
contentType = contentTypeHeader[0].getValue();
if (contentType.startsWith(ContentType.APPLICATION_JSON.getMimeType())) {
// application/json; encoding=utf-8 下载媒体文件出错
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
return JsonUtils.decode(responseContent, ChannelImageResponse.class);
}
}
String fileName = this.getFileName(response);
if (StringUtils.isBlank(fileName)) {
fileName = String.valueOf(System.currentTimeMillis());
}
String baseName = FilenameUtils.getBaseName(fileName);
if (StringUtils.isBlank(fileName) || baseName.length() < 3) {
baseName = String.valueOf(System.currentTimeMillis());
}
String extension = FilenameUtils.getExtension(fileName);
if (StringUtils.isBlank(extension)) {
extension = "unknown";
}
File file = createTmpFile(inputStream, baseName, extension, tmpDirFile);
return new ChannelImageResponse(file, contentType);
} catch (HttpException httpException) {
throw new ClientProtocolException(httpException.getMessage(), httpException);
}
}
private String getFileName(CloseableHttpResponse response) throws WxErrorException {
Header[] contentDispositionHeader = response.getHeaders("Content-disposition");
if (contentDispositionHeader == null || contentDispositionHeader.length == 0) {
return createDefaultFileName();
}
return this.extractFileNameFromContentString(contentDispositionHeader[0].getValue());
}
@Override
public void execute(String uri, String data, ResponseHandler<ChannelImageResponse> handler, WxType wxType)
throws WxErrorException, IOException {
handler.handle(this.execute(uri, data, wxType));
}
}

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<artifactId>weixin-java-common</artifactId>

View File

@@ -302,6 +302,7 @@ public class WxConsts {
public static final String VIEW = "VIEW";
public static final String MASS_SEND_JOB_FINISH = "MASSSENDJOBFINISH";
public static final String SYS_APPROVAL_CHANGE = "sys_approval_change";
/**
* 扫码推事件的事件推送
*/

View File

@@ -16,7 +16,7 @@ public class WxMinishopImageUploadCustomizeResult implements Serializable {
private WxMinishopPicFileCustomizeResult imgInfo;
public static WxMinishopImageUploadCustomizeResult fromJson(String json) {
JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject();
JsonObject jsonObject = JsonParser.parseString(json).getAsJsonObject();
WxMinishopImageUploadCustomizeResult result = new WxMinishopImageUploadCustomizeResult();
result.setErrcode(jsonObject.get(WxConsts.ERR_CODE).getAsNumber().toString());
if (result.getErrcode().equals("0")) {

View File

@@ -21,7 +21,7 @@ public class WxMinishopImageUploadResult implements Serializable {
public static WxMinishopImageUploadResult fromJson(String json) {
JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject();
JsonObject jsonObject = JsonParser.parseString(json).getAsJsonObject();
WxMinishopImageUploadResult result = new WxMinishopImageUploadResult();
result.setErrcode(jsonObject.get(WxConsts.ERR_CODE).getAsNumber().toString());
if (result.getErrcode().equals("0")) {

View File

@@ -1,11 +1,15 @@
package me.chanjar.weixin.common.executor;
import jodd.http.HttpConnectionProvider;
import jodd.http.ProxyInfo;
import me.chanjar.weixin.common.bean.CommonUploadParam;
import me.chanjar.weixin.common.enums.WxType;
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 okhttp3.OkHttpClient;
import java.io.IOException;
@@ -34,15 +38,19 @@ public abstract class CommonUploadRequestExecutor<H, P> implements RequestExecut
* @param requestHttp 请求信息
* @return 执行器
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public static RequestExecutor<String, CommonUploadParam> create(RequestHttp requestHttp) {
@SuppressWarnings("unchecked")
public static RequestExecutor<String, CommonUploadParam> create(RequestHttp<?, ?> requestHttp) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
return new CommonUploadRequestExecutorApacheImpl(requestHttp);
return new CommonUploadRequestExecutorApacheImpl(
(RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp);
case JODD_HTTP:
return new CommonUploadRequestExecutorJoddHttpImpl(requestHttp);
return new CommonUploadRequestExecutorJoddHttpImpl((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp);
case OK_HTTP:
return new CommonUploadRequestExecutorOkHttpImpl(requestHttp);
return new CommonUploadRequestExecutorOkHttpImpl((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp);
case HTTP_COMPONENTS:
return new CommonUploadRequestExecutorHttpComponentsImpl(
(RequestHttp<org.apache.hc.client5.http.impl.classic.CloseableHttpClient, org.apache.hc.core5.http.HttpHost>) requestHttp);
default:
throw new IllegalArgumentException("不支持的http执行器类型" + requestHttp.getRequestType());
}

View File

@@ -28,8 +28,7 @@ import java.io.InputStream;
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
public class CommonUploadRequestExecutorApacheImpl
extends CommonUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public class CommonUploadRequestExecutorApacheImpl extends CommonUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public CommonUploadRequestExecutorApacheImpl(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);

View File

@@ -0,0 +1,75 @@
package me.chanjar.weixin.common.executor;
import lombok.Getter;
import me.chanjar.weixin.common.bean.CommonUploadData;
import me.chanjar.weixin.common.bean.CommonUploadParam;
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.RequestHttp;
import me.chanjar.weixin.common.util.http.hc.Utf8ResponseHandler;
import org.apache.commons.lang3.StringUtils;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.entity.mime.HttpMultipartMode;
import org.apache.hc.client5.http.entity.mime.InputStreamBody;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpHost;
import java.io.IOException;
import java.io.InputStream;
/**
* Apache HttpComponents 通用文件上传器
*/
public class CommonUploadRequestExecutorHttpComponentsImpl extends CommonUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public CommonUploadRequestExecutorHttpComponentsImpl(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, CommonUploadParam param, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (param != null) {
CommonUploadData data = param.getData();
InnerStreamBody part = new InnerStreamBody(data.getInputStream(), ContentType.DEFAULT_BINARY, data.getFileName(), data.getLength());
HttpEntity entity = MultipartEntityBuilder
.create()
.addPart(param.getName(), part)
.setMode(HttpMultipartMode.EXTENDED)
.build();
httpPost.setEntity(entity);
}
String responseContent = requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
if (StringUtils.isEmpty(responseContent)) {
throw new WxErrorException(String.format("上传失败,服务器响应空 url:%s param:%s", uri, param));
}
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
return responseContent;
}
/**
* 内部流 请求体
*/
@Getter
public static class InnerStreamBody extends InputStreamBody {
private final long contentLength;
public InnerStreamBody(final InputStream in, final ContentType contentType, final String filename, long contentLength) {
super(in, contentType, filename);
this.contentLength = contentLength;
}
}
}

View File

@@ -0,0 +1,46 @@
package me.chanjar.weixin.common.requestexecuter.ocr;
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.RequestHttp;
import me.chanjar.weixin.common.util.http.hc.Utf8ResponseHandler;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.entity.mime.HttpMultipartMode;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpHost;
import java.io.File;
import java.io.IOException;
public class OcrDiscernHttpComponentsRequestExecutor extends OcrDiscernRequestExecutor<CloseableHttpClient, HttpHost> {
public OcrDiscernHttpComponentsRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}
@Override
public String execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (file != null) {
HttpEntity entity = MultipartEntityBuilder
.create()
.addBinaryBody("file", file)
.setMode(HttpMultipartMode.EXTENDED)
.build();
httpPost.setEntity(entity);
}
String responseContent = requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);
WxError error = WxError.fromJson(responseContent, wxType);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
}
return responseContent;
}
}

View File

@@ -33,9 +33,13 @@ public abstract class OcrDiscernRequestExecutor<H, P> implements RequestExecutor
public static RequestExecutor<String, File> create(RequestHttp<?, ?> requestHttp) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
return new OcrDiscernApacheHttpRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp);
return new OcrDiscernApacheHttpRequestExecutor(
(RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp);
case HTTP_COMPONENTS:
return new OcrDiscernHttpComponentsRequestExecutor(
(RequestHttp<org.apache.hc.client5.http.impl.classic.CloseableHttpClient, org.apache.hc.core5.http.HttpHost>) requestHttp);
default:
return null;
throw new IllegalArgumentException("不支持的http执行器类型" + requestHttp.getRequestType());
}
}
}

View File

@@ -1,5 +1,6 @@
package me.chanjar.weixin.common.util;
import org.apache.commons.lang3.RegExUtils;
import org.apache.commons.lang3.StringUtils;
/**
@@ -17,7 +18,7 @@ public class DataUtils {
public static <E> E handleDataWithSecret(E data) {
E dataForLog = data;
if(data instanceof String && StringUtils.contains((String)data, "&secret=")){
dataForLog = (E) StringUtils.replaceAll((String)data,"&secret=\\w+&","&secret=******&");
dataForLog = (E) RegExUtils.replaceAll((String)data,"&secret=\\w+&","&secret=******&");
}
return dataForLog;
}

View File

@@ -1,19 +1,18 @@
package me.chanjar.weixin.common.util.http;
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.WxErrorException;
import me.chanjar.weixin.common.util.http.apache.ApacheMediaDownloadRequestExecutor;
import me.chanjar.weixin.common.util.http.hc.HttpComponentsMediaDownloadRequestExecutor;
import me.chanjar.weixin.common.util.http.jodd.JoddHttpMediaDownloadRequestExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpMediaDownloadRequestExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
import okhttp3.OkHttpClient;
import org.apache.http.HttpHost;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.File;
import java.io.IOException;
/**
* 下载媒体文件请求执行器.
@@ -40,13 +39,17 @@ public abstract class BaseMediaDownloadRequestExecutor<H, P> implements RequestE
public static RequestExecutor<File, String> create(RequestHttp<?, ?> requestHttp, File tmpDirFile) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
return new ApacheMediaDownloadRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp, tmpDirFile);
return new ApacheMediaDownloadRequestExecutor(
(RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp, tmpDirFile);
case JODD_HTTP:
return new JoddHttpMediaDownloadRequestExecutor((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp, tmpDirFile);
case OK_HTTP:
return new OkHttpMediaDownloadRequestExecutor((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp, tmpDirFile);
case HTTP_COMPONENTS:
return new HttpComponentsMediaDownloadRequestExecutor(
(RequestHttp<org.apache.hc.client5.http.impl.classic.CloseableHttpClient, org.apache.hc.core5.http.HttpHost>) requestHttp, tmpDirFile);
default:
return null;
throw new IllegalArgumentException("不支持的http执行器类型" + requestHttp.getRequestType());
}
}

View File

@@ -9,7 +9,7 @@ public enum HttpClientType {
*/
JODD_HTTP,
/**
* apache httpclient.
* apache httpclient 4.x.
*/
APACHE_HTTP,
/**
@@ -17,7 +17,7 @@ public enum HttpClientType {
*/
OK_HTTP,
/**
* apache httpclient5.
* apache httpclient 5.x.
*/
APACHE_HTTP_5
HTTP_COMPONENTS
}

View File

@@ -2,7 +2,7 @@ package me.chanjar.weixin.common.util.http;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpResponseProxy;
import me.chanjar.weixin.common.util.http.hc5.ApacheHttpClient5ResponseProxy;
import me.chanjar.weixin.common.util.http.hc.HttpComponentsResponseProxy;
import me.chanjar.weixin.common.util.http.jodd.JoddHttpResponseProxy;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpResponseProxy;
@@ -26,8 +26,8 @@ public interface HttpResponseProxy {
return new ApacheHttpResponseProxy(response);
}
static ApacheHttpClient5ResponseProxy from(org.apache.hc.client5.http.impl.classic.CloseableHttpResponse response) {
return new ApacheHttpClient5ResponseProxy(response);
static HttpComponentsResponseProxy from(org.apache.hc.client5.http.impl.classic.CloseableHttpResponse response) {
return new HttpComponentsResponseProxy(response);
}
static JoddHttpResponseProxy from(jodd.http.HttpResponse response) {
@@ -40,7 +40,7 @@ public interface HttpResponseProxy {
String getFileName() throws WxErrorException;
default String extractFileNameFromContentString(String content) throws WxErrorException {
static String extractFileNameFromContentString(String content) throws WxErrorException {
if (content == null || content.isEmpty()) {
throw new WxErrorException("无法获取到文件名content为空");
}

View File

@@ -6,12 +6,11 @@ import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.apache.ApacheMediaInputStreamUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.hc.HttpComponentsMediaInputStreamUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.jodd.JoddHttpMediaInputStreamUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpMediaInputStreamUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
import okhttp3.OkHttpClient;
import org.apache.http.HttpHost;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.IOException;
@@ -33,16 +32,21 @@ public abstract class MediaInputStreamUploadRequestExecutor<H, P> implements Req
handler.handle(this.execute(uri, data, wxType));
}
@SuppressWarnings("unchecked")
public static RequestExecutor<WxMediaUploadResult, InputStreamData> create(RequestHttp<?, ?> requestHttp) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
return new ApacheMediaInputStreamUploadRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp);
return new ApacheMediaInputStreamUploadRequestExecutor(
(RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp);
case JODD_HTTP:
return new JoddHttpMediaInputStreamUploadRequestExecutor((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp);
case OK_HTTP:
return new OkHttpMediaInputStreamUploadRequestExecutor((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp);
case HTTP_COMPONENTS:
return new HttpComponentsMediaInputStreamUploadRequestExecutor(
(RequestHttp<org.apache.hc.client5.http.impl.classic.CloseableHttpClient, org.apache.hc.core5.http.HttpHost>) requestHttp);
default:
return null;
throw new IllegalArgumentException("不支持的http执行器类型" + requestHttp.getRequestType());
}
}

View File

@@ -8,12 +8,11 @@ import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.service.WxService;
import me.chanjar.weixin.common.util.http.apache.ApacheMediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.hc.HttpComponentsMediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.jodd.JoddHttpMediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpMediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
import okhttp3.OkHttpClient;
import org.apache.http.HttpHost;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.File;
import java.io.IOException;
@@ -40,16 +39,21 @@ public abstract class MediaUploadRequestExecutor<H, P> implements RequestExecuto
handler.handle(this.execute(uri, data, wxType));
}
@SuppressWarnings("unchecked")
public static RequestExecutor<WxMediaUploadResult, File> create(RequestHttp<?, ?> requestHttp) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
return new ApacheMediaUploadRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp);
return new ApacheMediaUploadRequestExecutor(
(RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp);
case JODD_HTTP:
return new JoddHttpMediaUploadRequestExecutor((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp);
case OK_HTTP:
return new OkHttpMediaUploadRequestExecutor((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp);
case HTTP_COMPONENTS:
return new HttpComponentsMediaUploadRequestExecutor(
(RequestHttp<org.apache.hc.client5.http.impl.classic.CloseableHttpClient, org.apache.hc.core5.http.HttpHost>) requestHttp);
default:
return null;
throw new IllegalArgumentException("不支持的http执行器类型" + requestHttp.getRequestType());
}
}

View File

@@ -6,12 +6,11 @@ import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadCustomizeResult
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.apache.ApacheMinishopMediaUploadRequestCustomizeExecutor;
import me.chanjar.weixin.common.util.http.hc.HttpComponentsMinishopMediaUploadRequestCustomizeExecutor;
import me.chanjar.weixin.common.util.http.jodd.JoddHttpMinishopMediaUploadRequestCustomizeExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpMinishopMediaUploadRequestCustomizeExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
import okhttp3.OkHttpClient;
import org.apache.http.HttpHost;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.File;
import java.io.IOException;
@@ -27,8 +26,7 @@ public abstract class MinishopUploadRequestCustomizeExecutor<H, P> implements Re
this.respType = respType;
if (imgUrl == null || imgUrl.isEmpty()) {
this.uploadType = "0";
}
else {
} else {
this.uploadType = "1";
this.imgUrl = imgUrl;
}
@@ -43,13 +41,17 @@ public abstract class MinishopUploadRequestCustomizeExecutor<H, P> implements Re
public static RequestExecutor<WxMinishopImageUploadCustomizeResult, File> create(RequestHttp<?, ?> requestHttp, String respType, String imgUrl) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
return new ApacheMinishopMediaUploadRequestCustomizeExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp, respType, imgUrl);
return new ApacheMinishopMediaUploadRequestCustomizeExecutor(
(RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp, respType, imgUrl);
case JODD_HTTP:
return new JoddHttpMinishopMediaUploadRequestCustomizeExecutor((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp, respType, imgUrl);
case OK_HTTP:
return new OkHttpMinishopMediaUploadRequestCustomizeExecutor((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp, respType, imgUrl);
case HTTP_COMPONENTS:
return new HttpComponentsMinishopMediaUploadRequestCustomizeExecutor(
(RequestHttp<org.apache.hc.client5.http.impl.classic.CloseableHttpClient, org.apache.hc.core5.http.HttpHost>) requestHttp, respType, imgUrl);
default:
return null;
throw new IllegalArgumentException("不支持的http执行器类型" + requestHttp.getRequestType());
}
}
}

View File

@@ -6,12 +6,11 @@ import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.apache.ApacheMinishopMediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.hc.HttpComponentsMinishopMediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.jodd.JoddHttpMinishopMediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpMinishopMediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
import okhttp3.OkHttpClient;
import org.apache.http.HttpHost;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.File;
import java.io.IOException;
@@ -32,13 +31,17 @@ public abstract class MinishopUploadRequestExecutor<H, P> implements RequestExec
public static RequestExecutor<WxMinishopImageUploadResult, File> create(RequestHttp<?, ?> requestHttp) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
return new ApacheMinishopMediaUploadRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp);
return new ApacheMinishopMediaUploadRequestExecutor(
(RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp);
case JODD_HTTP:
return new JoddHttpMinishopMediaUploadRequestExecutor((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp);
case OK_HTTP:
return new OkHttpMinishopMediaUploadRequestExecutor((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp);
case HTTP_COMPONENTS:
return new HttpComponentsMinishopMediaUploadRequestExecutor(
(RequestHttp<org.apache.hc.client5.http.impl.classic.CloseableHttpClient, org.apache.hc.core5.http.HttpHost>) requestHttp);
default:
return null;
throw new IllegalArgumentException("不支持的http执行器类型" + requestHttp.getRequestType());
}
}
}

View File

@@ -6,12 +6,11 @@ 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.apache.ApacheSimpleGetRequestExecutor;
import me.chanjar.weixin.common.util.http.hc.HttpComponentsSimpleGetRequestExecutor;
import me.chanjar.weixin.common.util.http.jodd.JoddHttpSimpleGetRequestExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpSimpleGetRequestExecutor;
import okhttp3.OkHttpClient;
import org.apache.http.HttpHost;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.IOException;
@@ -37,13 +36,17 @@ public abstract class SimpleGetRequestExecutor<H, P> implements RequestExecutor<
public static RequestExecutor<String, String> create(RequestHttp<?, ?> requestHttp) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
return new ApacheSimpleGetRequestExecutor((RequestHttp< CloseableHttpClient, HttpHost>) requestHttp);
return new ApacheSimpleGetRequestExecutor(
(RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp);
case JODD_HTTP:
return new JoddHttpSimpleGetRequestExecutor((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp);
case OK_HTTP:
return new OkHttpSimpleGetRequestExecutor((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp);
case HTTP_COMPONENTS:
return new HttpComponentsSimpleGetRequestExecutor(
(RequestHttp<org.apache.hc.client5.http.impl.classic.CloseableHttpClient, org.apache.hc.core5.http.HttpHost>) requestHttp);
default:
throw new IllegalArgumentException("非法请求参数");
throw new IllegalArgumentException("不支持的http执行器类型" + requestHttp.getRequestType());
}
}

View File

@@ -6,12 +6,11 @@ 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.apache.ApacheSimplePostRequestExecutor;
import me.chanjar.weixin.common.util.http.hc.HttpComponentsSimplePostRequestExecutor;
import me.chanjar.weixin.common.util.http.jodd.JoddHttpSimplePostRequestExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpSimplePostRequestExecutor;
import okhttp3.OkHttpClient;
import org.apache.http.HttpHost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
@@ -34,16 +33,21 @@ public abstract class SimplePostRequestExecutor<H, P> implements RequestExecutor
handler.handle(this.execute(uri, data, wxType));
}
@SuppressWarnings("unchecked")
public static RequestExecutor<String, String> create(RequestHttp<?, ?> requestHttp) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
return new ApacheSimplePostRequestExecutor((RequestHttp<CloseableHttpClient, HttpHost>) requestHttp);
return new ApacheSimplePostRequestExecutor(
(RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp);
case JODD_HTTP:
return new JoddHttpSimplePostRequestExecutor((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp);
case OK_HTTP:
return new OkHttpSimplePostRequestExecutor((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp);
case HTTP_COMPONENTS:
return new HttpComponentsSimplePostRequestExecutor(
(RequestHttp<org.apache.hc.client5.http.impl.classic.CloseableHttpClient, org.apache.hc.core5.http.HttpHost>) requestHttp);
default:
throw new IllegalArgumentException("非法请求参数");
throw new IllegalArgumentException("不支持的http执行器类型" + requestHttp.getRequestType());
}
}

View File

@@ -20,6 +20,6 @@ public class ApacheHttpResponseProxy implements HttpResponseProxy {
throw new WxErrorException("无法获取到文件名Content-disposition为空");
}
return extractFileNameFromContentString(contentDispositionHeader[0].getValue());
return HttpResponseProxy.extractFileNameFromContentString(contentDispositionHeader[0].getValue());
}
}

View File

@@ -4,14 +4,15 @@ import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor;
import org.apache.http.Consts;
import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* .
@@ -33,8 +34,7 @@ public class ApacheSimplePostRequestExecutor extends SimplePostRequestExecutor<C
}
if (postEntity != null) {
StringEntity entity = new StringEntity(postEntity, Consts.UTF_8);
entity.setContentType("application/json; charset=utf-8");
StringEntity entity = new StringEntity(postEntity, ContentType.APPLICATION_JSON.withCharset(StandardCharsets.UTF_8));
httpPost.setEntity(entity);
}

View File

@@ -0,0 +1,14 @@
package me.chanjar.weixin.common.util.http.hc;
import org.apache.hc.client5.http.impl.classic.BasicHttpClientResponseHandler;
/**
* ApacheBasicResponseHandler
*
* @author altusea
*/
public class BasicResponseHandler extends BasicHttpClientResponseHandler {
public static final BasicHttpClientResponseHandler INSTANCE = new BasicHttpClientResponseHandler();
}

View File

@@ -1,4 +1,4 @@
package me.chanjar.weixin.common.util.http.hc5;
package me.chanjar.weixin.common.util.http.hc;
import org.apache.hc.client5.http.impl.classic.AbstractHttpClientResponseHandler;
import org.apache.hc.core5.http.HttpEntity;

View File

@@ -1,7 +1,9 @@
package me.chanjar.weixin.common.util.http.hc5;
package me.chanjar.weixin.common.util.http.hc;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.hc.client5.http.ConnectionKeepAliveStrategy;
@@ -43,7 +45,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
@Slf4j
@Data
@NotThreadSafe
public class DefaultApacheHttpClientBuilder implements ApacheHttpClientBuilder {
public class DefaultHttpComponentsClientBuilder implements HttpComponentsClientBuilder {
private final AtomicBoolean prepared = new AtomicBoolean(false);
@@ -121,45 +123,45 @@ public class DefaultApacheHttpClientBuilder implements ApacheHttpClientBuilder {
*/
private CloseableHttpClient closeableHttpClient;
private DefaultApacheHttpClientBuilder() {
private DefaultHttpComponentsClientBuilder() {
}
public static DefaultApacheHttpClientBuilder get() {
public static DefaultHttpComponentsClientBuilder get() {
return SingletonHolder.INSTANCE;
}
@Override
public ApacheHttpClientBuilder httpProxyHost(String httpProxyHost) {
public HttpComponentsClientBuilder httpProxyHost(String httpProxyHost) {
this.httpProxyHost = httpProxyHost;
return this;
}
@Override
public ApacheHttpClientBuilder httpProxyPort(int httpProxyPort) {
public HttpComponentsClientBuilder httpProxyPort(int httpProxyPort) {
this.httpProxyPort = httpProxyPort;
return this;
}
@Override
public ApacheHttpClientBuilder httpProxyUsername(String httpProxyUsername) {
public HttpComponentsClientBuilder httpProxyUsername(String httpProxyUsername) {
this.httpProxyUsername = httpProxyUsername;
return this;
}
@Override
public ApacheHttpClientBuilder httpProxyPassword(char[] httpProxyPassword) {
public HttpComponentsClientBuilder httpProxyPassword(char[] httpProxyPassword) {
this.httpProxyPassword = httpProxyPassword;
return this;
}
@Override
public ApacheHttpClientBuilder httpRequestRetryStrategy(HttpRequestRetryStrategy httpRequestRetryStrategy) {
public HttpComponentsClientBuilder httpRequestRetryStrategy(HttpRequestRetryStrategy httpRequestRetryStrategy) {
this.httpRequestRetryStrategy = httpRequestRetryStrategy;
return this;
}
@Override
public ApacheHttpClientBuilder keepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy) {
public HttpComponentsClientBuilder keepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy) {
this.connectionKeepAliveStrategy = keepAliveStrategy;
return this;
}
@@ -242,6 +244,6 @@ public class DefaultApacheHttpClientBuilder implements ApacheHttpClientBuilder {
* DefaultApacheHttpClientBuilder 改为单例模式,并持有唯一的CloseableHttpClient(仅首次调用创建)
*/
private static class SingletonHolder {
private static final DefaultApacheHttpClientBuilder INSTANCE = new DefaultApacheHttpClientBuilder();
private static final DefaultHttpComponentsClientBuilder INSTANCE = new DefaultHttpComponentsClientBuilder();
}
}

View File

@@ -0,0 +1,51 @@
package me.chanjar.weixin.common.util.http.hc;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import org.apache.hc.client5.http.ConnectionKeepAliveStrategy;
import org.apache.hc.client5.http.HttpRequestRetryStrategy;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
/**
* httpclient build interface.
*
* @author altusea
*/
public interface HttpComponentsClientBuilder {
/**
* 构建httpclient实例.
*
* @return new instance of CloseableHttpClient
*/
CloseableHttpClient build();
/**
* 代理服务器地址.
*/
HttpComponentsClientBuilder httpProxyHost(String httpProxyHost);
/**
* 代理服务器端口.
*/
HttpComponentsClientBuilder httpProxyPort(int httpProxyPort);
/**
* 代理服务器用户名.
*/
HttpComponentsClientBuilder httpProxyUsername(String httpProxyUsername);
/**
* 代理服务器密码.
*/
HttpComponentsClientBuilder httpProxyPassword(char[] httpProxyPassword);
/**
* 重试策略.
*/
HttpComponentsClientBuilder httpRequestRetryStrategy(HttpRequestRetryStrategy httpRequestRetryStrategy);
/**
* 超时时间.
*/
HttpComponentsClientBuilder keepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy);
}

View File

@@ -1,4 +1,4 @@
package me.chanjar.weixin.common.util.http.hc5;
package me.chanjar.weixin.common.util.http.hc;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
@@ -28,9 +28,9 @@ import java.io.InputStream;
*
* @author altusea
*/
public class ApacheMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor<CloseableHttpClient, HttpHost> {
public class HttpComponentsMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor<CloseableHttpClient, HttpHost> {
public ApacheMediaDownloadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp, File tmpDirFile) {
public HttpComponentsMediaDownloadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp, File tmpDirFile) {
super(requestHttp, tmpDirFile);
}
@@ -71,7 +71,7 @@ public class ApacheMediaDownloadRequestExecutor extends BaseMediaDownloadRequest
}
return FileUtils.createTmpFile(inputStream, baseName, FilenameUtils.getExtension(fileName), super.tmpDirFile);
} catch (final HttpException httpException) {
} catch (HttpException httpException) {
throw new ClientProtocolException(httpException.getMessage(), httpException);
}
}

View File

@@ -1,4 +1,4 @@
package me.chanjar.weixin.common.util.http.hc5;
package me.chanjar.weixin.common.util.http.hc;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.enums.WxType;
@@ -23,9 +23,9 @@ import java.io.IOException;
*
* @author altusea
*/
public class ApacheMediaInputStreamUploadRequestExecutor extends MediaInputStreamUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public class HttpComponentsMediaInputStreamUploadRequestExecutor extends MediaInputStreamUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public ApacheMediaInputStreamUploadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
public HttpComponentsMediaInputStreamUploadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}

View File

@@ -1,4 +1,4 @@
package me.chanjar.weixin.common.util.http.hc5;
package me.chanjar.weixin.common.util.http.hc;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.enums.WxType;
@@ -22,9 +22,9 @@ import java.io.IOException;
*
* @author altusea
*/
public class ApacheMediaUploadRequestExecutor extends MediaUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public class HttpComponentsMediaUploadRequestExecutor extends MediaUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public ApacheMediaUploadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
public HttpComponentsMediaUploadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}

View File

@@ -1,4 +1,4 @@
package me.chanjar.weixin.common.util.http.hc5;
package me.chanjar.weixin.common.util.http.hc;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadCustomizeResult;
@@ -24,9 +24,9 @@ import java.io.IOException;
* @author altusea
*/
@Slf4j
public class ApacheMinishopMediaUploadRequestCustomizeExecutor extends MinishopUploadRequestCustomizeExecutor<CloseableHttpClient, HttpHost> {
public class HttpComponentsMinishopMediaUploadRequestCustomizeExecutor extends MinishopUploadRequestCustomizeExecutor<CloseableHttpClient, HttpHost> {
public ApacheMinishopMediaUploadRequestCustomizeExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp, String respType, String imgUrl) {
public HttpComponentsMinishopMediaUploadRequestCustomizeExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp, String respType, String imgUrl) {
super(requestHttp, respType, imgUrl);
}

View File

@@ -1,4 +1,4 @@
package me.chanjar.weixin.common.util.http.hc5;
package me.chanjar.weixin.common.util.http.hc;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
@@ -24,9 +24,9 @@ import java.io.IOException;
* @author altusea
*/
@Slf4j
public class ApacheMinishopMediaUploadRequestExecutor extends MinishopUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public class HttpComponentsMinishopMediaUploadRequestExecutor extends MinishopUploadRequestExecutor<CloseableHttpClient, HttpHost> {
public ApacheMinishopMediaUploadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
public HttpComponentsMinishopMediaUploadRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}

View File

@@ -1,15 +1,15 @@
package me.chanjar.weixin.common.util.http.hc5;
package me.chanjar.weixin.common.util.http.hc;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.HttpResponseProxy;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.core5.http.Header;
public class ApacheHttpClient5ResponseProxy implements HttpResponseProxy {
public class HttpComponentsResponseProxy implements HttpResponseProxy {
private final CloseableHttpResponse response;
public ApacheHttpClient5ResponseProxy(CloseableHttpResponse closeableHttpResponse) {
public HttpComponentsResponseProxy(CloseableHttpResponse closeableHttpResponse) {
this.response = closeableHttpResponse;
}
@@ -20,6 +20,6 @@ public class ApacheHttpClient5ResponseProxy implements HttpResponseProxy {
throw new WxErrorException("无法获取到文件名Content-disposition为空");
}
return extractFileNameFromContentString(contentDispositionHeader[0].getValue());
return HttpResponseProxy.extractFileNameFromContentString(contentDispositionHeader[0].getValue());
}
}

View File

@@ -1,4 +1,4 @@
package me.chanjar.weixin.common.util.http.hc5;
package me.chanjar.weixin.common.util.http.hc;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
@@ -16,9 +16,9 @@ import java.io.IOException;
*
* @author altusea
*/
public class ApacheSimpleGetRequestExecutor extends SimpleGetRequestExecutor<CloseableHttpClient, HttpHost> {
public class HttpComponentsSimpleGetRequestExecutor extends SimpleGetRequestExecutor<CloseableHttpClient, HttpHost> {
public ApacheSimpleGetRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
public HttpComponentsSimpleGetRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}

View File

@@ -1,4 +1,4 @@
package me.chanjar.weixin.common.util.http.hc5;
package me.chanjar.weixin.common.util.http.hc;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxErrorException;
@@ -19,9 +19,9 @@ import java.nio.charset.StandardCharsets;
*
* @author altusea
*/
public class ApacheSimplePostRequestExecutor extends SimplePostRequestExecutor<CloseableHttpClient, HttpHost> {
public class HttpComponentsSimplePostRequestExecutor extends SimplePostRequestExecutor<CloseableHttpClient, HttpHost> {
public ApacheSimplePostRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
public HttpComponentsSimplePostRequestExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp) {
super(requestHttp);
}

View File

@@ -1,4 +1,4 @@
package me.chanjar.weixin.common.util.http.hc5;
package me.chanjar.weixin.common.util.http.hc;
import org.apache.hc.client5.http.impl.classic.AbstractHttpClientResponseHandler;
import org.apache.hc.core5.http.HttpEntity;

View File

@@ -1,4 +1,4 @@
package me.chanjar.weixin.common.util.http.hc5;
package me.chanjar.weixin.common.util.http.hc;
import org.apache.hc.client5.http.HttpRequestRetryStrategy;
import org.apache.hc.core5.http.HttpRequest;

View File

@@ -1,4 +1,4 @@
package me.chanjar.weixin.common.util.http.hc5;
package me.chanjar.weixin.common.util.http.hc;
import org.apache.hc.client5.http.ClientProtocolException;
import org.apache.hc.client5.http.impl.classic.AbstractHttpClientResponseHandler;

View File

@@ -1,14 +0,0 @@
package me.chanjar.weixin.common.util.http.hc5;
import org.apache.hc.client5.http.impl.classic.BasicHttpClientResponseHandler;
/**
* ApacheBasicResponseHandler
*
* @author altusea
*/
public class ApacheBasicResponseHandler extends BasicHttpClientResponseHandler {
public static final ApacheBasicResponseHandler INSTANCE = new ApacheBasicResponseHandler();
}

View File

@@ -1,50 +0,0 @@
package me.chanjar.weixin.common.util.http.hc5;
import org.apache.hc.client5.http.ConnectionKeepAliveStrategy;
import org.apache.hc.client5.http.HttpRequestRetryStrategy;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
/**
* httpclient build interface.
*
* @author altusea
*/
public interface ApacheHttpClientBuilder {
/**
* 构建httpclient实例.
*
* @return new instance of CloseableHttpClient
*/
CloseableHttpClient build();
/**
* 代理服务器地址.
*/
ApacheHttpClientBuilder httpProxyHost(String httpProxyHost);
/**
* 代理服务器端口.
*/
ApacheHttpClientBuilder httpProxyPort(int httpProxyPort);
/**
* 代理服务器用户名.
*/
ApacheHttpClientBuilder httpProxyUsername(String httpProxyUsername);
/**
* 代理服务器密码.
*/
ApacheHttpClientBuilder httpProxyPassword(char[] httpProxyPassword);
/**
* 重试策略.
*/
ApacheHttpClientBuilder httpRequestRetryStrategy(HttpRequestRetryStrategy httpRequestRetryStrategy);
/**
* 超时时间.
*/
ApacheHttpClientBuilder keepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy);
}

View File

@@ -15,6 +15,6 @@ public class JoddHttpResponseProxy implements HttpResponseProxy {
@Override
public String getFileName() throws WxErrorException {
String content = response.header("Content-disposition");
return extractFileNameFromContentString(content);
return HttpResponseProxy.extractFileNameFromContentString(content);
}
}

View File

@@ -15,6 +15,6 @@ public class OkHttpResponseProxy implements HttpResponseProxy {
@Override
public String getFileName() throws WxErrorException {
String content = this.response.header("Content-disposition");
return extractFileNameFromContentString(content);
return HttpResponseProxy.extractFileNameFromContentString(content);
}
}

View File

@@ -10,17 +10,16 @@ import java.io.Reader;
* @author niefy
*/
public class GsonParser {
private static final JsonParser JSON_PARSER = new JsonParser();
public static JsonObject parse(String json) {
return JSON_PARSER.parse(json).getAsJsonObject();
return JsonParser.parseString(json).getAsJsonObject();
}
public static JsonObject parse(Reader json) {
return JSON_PARSER.parse(json).getAsJsonObject();
return JsonParser.parseReader(json).getAsJsonObject();
}
public static JsonObject parse(JsonReader json) {
return JSON_PARSER.parse(json).getAsJsonObject();
return JsonParser.parseReader(json).getAsJsonObject();
}
}

View File

@@ -1,11 +1,3 @@
/*
* KINGSTAR MEDIA SOLUTIONS Co.,LTD. Copyright c 2005-2013. All rights reserved.
*
* This source code is the property of KINGSTAR MEDIA SOLUTIONS LTD. It is intended
* only for the use of KINGSTAR MEDIA application development. Reengineering, reproduction
* arose from modification of the original source, or other redistribution of this source
* is not permitted without written permission of the KINGSTAR MEDIA SOLUTIONS LTD.
*/
package me.chanjar.weixin.common.util.json;
import com.google.gson.*;
@@ -14,6 +6,7 @@ import me.chanjar.weixin.common.bean.menu.WxMenuButton;
import me.chanjar.weixin.common.bean.menu.WxMenuRule;
import java.lang.reflect.Type;
import java.util.Optional;
/**
@@ -21,96 +14,111 @@ import java.lang.reflect.Type;
*/
public class WxMenuGsonAdapter implements JsonSerializer<WxMenu>, JsonDeserializer<WxMenu> {
// JSON字段常量定义
private static final String FIELD_BUTTON = "button";
private static final String FIELD_MATCH_RULE = "matchrule";
private static final String FIELD_SUB_BUTTON = "sub_button";
private static final String FIELD_MENU = "menu";
// 菜单按钮字段常量
private static final String FIELD_TYPE = "type";
private static final String FIELD_NAME = "name";
private static final String FIELD_KEY = "key";
private static final String FIELD_URL = "url";
private static final String FIELD_MEDIA_ID = "media_id";
private static final String FIELD_ARTICLE_ID = "article_id";
private static final String FIELD_APP_ID = "appid";
private static final String FIELD_PAGE_PATH = "pagepath";
// 菜单规则字段常量
private static final String FIELD_TAG_ID = "tag_id";
private static final String FIELD_SEX = "sex";
private static final String FIELD_COUNTRY = "country";
private static final String FIELD_PROVINCE = "province";
private static final String FIELD_CITY = "city";
private static final String FIELD_CLIENT_PLATFORM_TYPE = "client_platform_type";
private static final String FIELD_LANGUAGE = "language";
@Override
public JsonElement serialize(WxMenu menu, Type typeOfSrc, JsonSerializationContext context) {
JsonObject json = new JsonObject();
JsonArray buttonArray = new JsonArray();
for (WxMenuButton button : menu.getButtons()) {
JsonObject buttonJson = convertToJson(button);
buttonArray.add(buttonJson);
}
json.add("button", buttonArray);
Optional.ofNullable(menu.getButtons())
.ifPresent(buttons -> buttons.stream()
.map(this::convertToJson)
.forEach(buttonArray::add));
json.add(FIELD_BUTTON, buttonArray);
if (menu.getMatchRule() != null) {
json.add("matchrule", convertToJson(menu.getMatchRule()));
json.add(FIELD_MATCH_RULE, convertToJson(menu.getMatchRule()));
}
return json;
}
protected JsonObject convertToJson(WxMenuButton button) {
JsonObject buttonJson = new JsonObject();
buttonJson.addProperty("type", button.getType());
buttonJson.addProperty("name", button.getName());
buttonJson.addProperty("key", button.getKey());
buttonJson.addProperty("url", button.getUrl());
buttonJson.addProperty("media_id", button.getMediaId());
buttonJson.addProperty("article_id", button.getArticleId());
buttonJson.addProperty("appid", button.getAppId());
buttonJson.addProperty("pagepath", button.getPagePath());
addPropertyIfNotNull(buttonJson, FIELD_TYPE, button.getType());
addPropertyIfNotNull(buttonJson, FIELD_NAME, button.getName());
addPropertyIfNotNull(buttonJson, FIELD_KEY, button.getKey());
addPropertyIfNotNull(buttonJson, FIELD_URL, button.getUrl());
addPropertyIfNotNull(buttonJson, FIELD_MEDIA_ID, button.getMediaId());
addPropertyIfNotNull(buttonJson, FIELD_ARTICLE_ID, button.getArticleId());
addPropertyIfNotNull(buttonJson, FIELD_APP_ID, button.getAppId());
addPropertyIfNotNull(buttonJson, FIELD_PAGE_PATH, button.getPagePath());
if (button.getSubButtons() != null && !button.getSubButtons().isEmpty()) {
JsonArray buttonArray = new JsonArray();
for (WxMenuButton sub_button : button.getSubButtons()) {
buttonArray.add(convertToJson(sub_button));
}
buttonJson.add("sub_button", buttonArray);
button.getSubButtons().stream()
.map(this::convertToJson)
.forEach(buttonArray::add);
buttonJson.add(FIELD_SUB_BUTTON, buttonArray);
}
return buttonJson;
}
protected JsonObject convertToJson(WxMenuRule menuRule) {
JsonObject matchRule = new JsonObject();
matchRule.addProperty("tag_id", menuRule.getTagId());
matchRule.addProperty("sex", menuRule.getSex());
matchRule.addProperty("country", menuRule.getCountry());
matchRule.addProperty("province", menuRule.getProvince());
matchRule.addProperty("city", menuRule.getCity());
matchRule.addProperty("client_platform_type", menuRule.getClientPlatformType());
matchRule.addProperty("language", menuRule.getLanguage());
addPropertyIfNotNull(matchRule, FIELD_TAG_ID, menuRule.getTagId());
addPropertyIfNotNull(matchRule, FIELD_SEX, menuRule.getSex());
addPropertyIfNotNull(matchRule, FIELD_COUNTRY, menuRule.getCountry());
addPropertyIfNotNull(matchRule, FIELD_PROVINCE, menuRule.getProvince());
addPropertyIfNotNull(matchRule, FIELD_CITY, menuRule.getCity());
addPropertyIfNotNull(matchRule, FIELD_CLIENT_PLATFORM_TYPE, menuRule.getClientPlatformType());
addPropertyIfNotNull(matchRule, FIELD_LANGUAGE, menuRule.getLanguage());
return matchRule;
}
@Deprecated
private WxMenuRule convertToRule(JsonObject json) {
WxMenuRule menuRule = new WxMenuRule();
//变态的微信接口,这里居然反人类的使用和序列化时不一样的名字
//menuRule.setTagId(GsonHelper.getString(json,"tag_id"));
menuRule.setTagId(GsonHelper.getString(json, "group_id"));
menuRule.setSex(GsonHelper.getString(json, "sex"));
menuRule.setCountry(GsonHelper.getString(json, "country"));
menuRule.setProvince(GsonHelper.getString(json, "province"));
menuRule.setCity(GsonHelper.getString(json, "city"));
menuRule.setClientPlatformType(GsonHelper.getString(json, "client_platform_type"));
menuRule.setLanguage(GsonHelper.getString(json, "language"));
return menuRule;
private void addPropertyIfNotNull(JsonObject obj, String key, String value) {
if (value != null) {
obj.addProperty(key, value);
}
}
@Override
public WxMenu deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
/*
* 操蛋的微信
* 创建菜单时是 { button : ... }
* 查询菜单时是 { menu : { button : ... } }
* 现在企业号升级为企业微信后,没有此问题,因此需要单独处理
*/
JsonArray buttonsJson = json.getAsJsonObject().get("menu").getAsJsonObject().get("button").getAsJsonArray();
return this.buildMenuFromJson(buttonsJson);
JsonObject root = json.getAsJsonObject();
JsonArray buttonsJson = null;
if (root.has(FIELD_MENU)) {
JsonObject menuObj = root.getAsJsonObject(FIELD_MENU);
buttonsJson = menuObj.getAsJsonArray(FIELD_BUTTON);
} else if (root.has(FIELD_BUTTON)) {
buttonsJson = root.getAsJsonArray(FIELD_BUTTON);
}
if (buttonsJson == null) {
throw new JsonParseException("No button array found in menu JSON");
}
return buildMenuFromJson(buttonsJson);
}
protected WxMenu buildMenuFromJson(JsonArray buttonsJson) {
WxMenu menu = new WxMenu();
for (int i = 0; i < buttonsJson.size(); i++) {
JsonObject buttonJson = buttonsJson.get(i).getAsJsonObject();
for (JsonElement btnElem : buttonsJson) {
JsonObject buttonJson = btnElem.getAsJsonObject();
WxMenuButton button = convertFromJson(buttonJson);
menu.getButtons().add(button);
if (buttonJson.get("sub_button") == null || buttonJson.get("sub_button").isJsonNull()) {
continue;
}
JsonArray sub_buttonsJson = buttonJson.get("sub_button").getAsJsonArray();
for (int j = 0; j < sub_buttonsJson.size(); j++) {
JsonObject sub_buttonJson = sub_buttonsJson.get(j).getAsJsonObject();
button.getSubButtons().add(convertFromJson(sub_buttonJson));
if (buttonJson.has(FIELD_SUB_BUTTON) && buttonJson.get(FIELD_SUB_BUTTON).isJsonArray()) {
JsonArray sub_buttonsJson = buttonJson.getAsJsonArray(FIELD_SUB_BUTTON);
for (JsonElement subBtnElem : sub_buttonsJson) {
button.getSubButtons().add(convertFromJson(subBtnElem.getAsJsonObject()));
}
}
}
return menu;
@@ -118,14 +126,14 @@ public class WxMenuGsonAdapter implements JsonSerializer<WxMenu>, JsonDeserializ
protected WxMenuButton convertFromJson(JsonObject json) {
WxMenuButton button = new WxMenuButton();
button.setName(GsonHelper.getString(json, "name"));
button.setKey(GsonHelper.getString(json, "key"));
button.setUrl(GsonHelper.getString(json, "url"));
button.setType(GsonHelper.getString(json, "type"));
button.setMediaId(GsonHelper.getString(json, "media_id"));
button.setArticleId(GsonHelper.getString(json, "article_id"));
button.setAppId(GsonHelper.getString(json, "appid"));
button.setPagePath(GsonHelper.getString(json, "pagepath"));
button.setName(GsonHelper.getString(json, FIELD_NAME));
button.setKey(GsonHelper.getString(json, FIELD_KEY));
button.setUrl(GsonHelper.getString(json, FIELD_URL));
button.setType(GsonHelper.getString(json, FIELD_TYPE));
button.setMediaId(GsonHelper.getString(json, FIELD_MEDIA_ID));
button.setArticleId(GsonHelper.getString(json, FIELD_ARTICLE_ID));
button.setAppId(GsonHelper.getString(json, FIELD_APP_ID));
button.setPagePath(GsonHelper.getString(json, FIELD_PAGE_PATH));
return button;
}

View File

@@ -102,7 +102,7 @@ public class StringManager {
*
* @param packageName The package name
*/
public static final synchronized StringManager getManager(
public static synchronized StringManager getManager(
String packageName) {
return getManager(packageName, Locale.getDefault());
}
@@ -115,7 +115,7 @@ public class StringManager {
* @param packageName The package name
* @param locale The Locale
*/
public static final synchronized StringManager getManager(
public static synchronized StringManager getManager(
String packageName, Locale locale) {
Map<Locale, StringManager> map = MANAGERS.get(packageName);

View File

@@ -1,6 +1,7 @@
package me.chanjar.weixin.common.util.http;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpResponseProxy;
import org.testng.annotations.Test;
import static org.testng.Assert.*;

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>4.7.6.B</version>
<version>4.7.7.B</version>
</parent>
<artifactId>weixin-java-cp</artifactId>
@@ -89,7 +89,7 @@
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>1.78.1</version>
<version>1.80</version>
</dependency>
<dependency>

View File

@@ -48,12 +48,11 @@ public interface WxCpOaWeDriveService {
* 请求方式POSTHTTPS
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_dismiss?access_token=ACCESS_TOKEN">...</a>
*
* @param userId the user id
* @param spaceId the space id
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
WxCpBaseResp spaceDismiss(@NonNull String userId, @NonNull String spaceId) throws WxErrorException;
WxCpBaseResp spaceDismiss(@NonNull String spaceId) throws WxErrorException;
/**
* 获取空间信息
@@ -62,12 +61,11 @@ public interface WxCpOaWeDriveService {
* 请求方式POSTHTTPS
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_info?access_token=ACCESS_TOKEN">...</a>
*
* @param userId the user id
* @param spaceId the space id
* @return wx cp space info
* @throws WxErrorException the wx error exception
*/
WxCpSpaceInfo spaceInfo(@NonNull String userId, @NonNull String spaceId) throws WxErrorException;
WxCpSpaceInfo spaceInfo(@NonNull String spaceId) throws WxErrorException;
/**
* 添加成员/部门
@@ -115,12 +113,11 @@ public interface WxCpOaWeDriveService {
* 请求方式POSTHTTPS
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_share?access_token=ACCESS_TOKEN">...</a>
*
* @param userId the user id
* @param spaceId the space id
* @return wx cp space share
* @throws WxErrorException the wx error exception
*/
WxCpSpaceShare spaceShare(@NonNull String userId, @NonNull String spaceId) throws WxErrorException;
WxCpSpaceShare spaceShare(@NonNull String spaceId) throws WxErrorException;
/**
* 获取文件列表
@@ -155,18 +152,18 @@ public interface WxCpOaWeDriveService {
* 请求方式POSTHTTPS
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_download?access_token=ACCESS_TOKEN">...</a>
*
* @param fileId 文件fileid只支持下载普通文件不支持下载文件夹或微文档
* @param fileId 文件fileid只支持下载普通文件不支持下载文件夹或微文档
* @param selectedTicket 微盘和文件选择器jsapi返回的selectedTicket。若填此参数则不需要填fileid。
* @return {
* "errcode": 0,
* "errmsg": "ok",
* "download_url": "DOWNLOAD_URL",
* "cookie_name": "COOKIE_NAME",
* "cookie_value": "COOKIE_VALUE"
* "errcode": 0,
* "errmsg": "ok",
* "download_url": "DOWNLOAD_URL",
* "cookie_name": "COOKIE_NAME",
* "cookie_value": "COOKIE_VALUE"
* }
* @throws WxErrorException the wx error exception
*/
WxCpFileDownload fileDownload( String fileId, String selectedTicket) throws WxErrorException;
WxCpFileDownload fileDownload(String fileId, String selectedTicket) throws WxErrorException;
/**
* 重命名文件
@@ -271,14 +268,13 @@ public interface WxCpOaWeDriveService {
* 请求方式POSTHTTPS
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_setting?access_token=ACCESS_TOKEN">...</a>
*
* @param userId the user id
* @param fileId the file id
* @param authScope the auth scope
* @param auth the auth
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
WxCpBaseResp fileSetting(@NonNull String userId, @NonNull String fileId, @NonNull Integer authScope, Integer auth) throws WxErrorException;
WxCpBaseResp fileSetting(@NonNull String fileId, @NonNull Integer authScope, Integer auth) throws WxErrorException;
/**
* 获取分享链接
@@ -287,11 +283,10 @@ public interface WxCpOaWeDriveService {
* 请求方式POSTHTTPS
* 请求地址: <a href="https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_share?access_token=ACCESS_TOKEN">...</a>
*
* @param userId the user id
* @param fileId the file id
* @return wx cp file share
* @throws WxErrorException the wx error exception
*/
WxCpFileShare fileShare(@NonNull String userId, @NonNull String fileId) throws WxErrorException;
WxCpFileShare fileShare(@NonNull String fileId) throws WxErrorException;
}

Some files were not shown because too many files have changed in this diff Show More