Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0fcd371

Browse filesBrowse files
authored
Merge pull request binarywang#1730 from Wechat-Group/develop
合并develop分支,发布最新正式版
2 parents 89011db + ec7ab21 commit 0fcd371
Copy full SHA for 0fcd371

File tree

Expand file treeCollapse file tree

467 files changed

+12365
-3981
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

467 files changed

+12365
-3981
lines changed

‎pom.xml

Copy file name to clipboardExpand all lines: pom.xml
+10-6Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<modelVersion>4.0.0</modelVersion>
77
<groupId>com.github.binarywang</groupId>
88
<artifactId>wx-java</artifactId>
9-
<version>3.8.0</version>
9+
<version>3.9.0</version>
1010
<packaging>pom</packaging>
1111
<name>WxJava - Weixin/Wechat Java SDK</name>
1212
<description>微信开发Java SDK</description>
@@ -90,6 +90,11 @@
9090
<email>liuxinghao1988@gmail.com</email>
9191
<url>https://github.com/howardliu-cn</url>
9292
</developer>
93+
<developer>
94+
<name>huangxiaoming</name>
95+
<email>huangxm129@163.com</email>
96+
<url>https://github.com/huangxm129</url>
97+
</developer>
9398
</developers>
9499

95100
<scm>
@@ -111,8 +116,8 @@
111116
</modules>
112117

113118
<properties>
114-
<maven.compiler.source>1.7</maven.compiler.source>
115-
<maven.compiler.target>1.7</maven.compiler.target>
119+
<maven.compiler.source>1.8</maven.compiler.source>
120+
<maven.compiler.target>1.8</maven.compiler.target>
116121

117122
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
118123
<httpclient.version>4.5</httpclient.version>
@@ -126,11 +131,10 @@
126131
<artifactId>qrcode-utils</artifactId>
127132
<version>1.1</version>
128133
</dependency>
129-
<!-- 由于jodd-http较新的3.8版本需要jdk8,故而此处采用较低版本 -->
130134
<dependency>
131135
<groupId>org.jodd</groupId>
132136
<artifactId>jodd-http</artifactId>
133-
<version>5.1.4</version>
137+
<version>5.1.6</version>
134138
<scope>provided</scope>
135139
</dependency>
136140
<dependency>
@@ -239,7 +243,7 @@
239243
<dependency>
240244
<groupId>redis.clients</groupId>
241245
<artifactId>jedis</artifactId>
242-
<version>2.9.0</version>
246+
<version>3.3.0</version>
243247
<scope>provided</scope>
244248
</dependency>
245249
<dependency>

‎spring-boot-starters/pom.xml

Copy file name to clipboardExpand all lines: spring-boot-starters/pom.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.github.binarywang</groupId>
88
<artifactId>wx-java</artifactId>
9-
<version>3.8.0</version>
9+
<version>3.9.0</version>
1010
</parent>
1111
<packaging>pom</packaging>
1212
<artifactId>wx-java-spring-boot-starters</artifactId>

‎spring-boot-starters/wx-java-miniapp-spring-boot-starter/README.md

Copy file name to clipboardExpand all lines: spring-boot-starters/wx-java-miniapp-spring-boot-starter/README.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
wx.miniapp.msgDataFormat = @msgDataFormat # 消息格式,XML或者JSON.
1919
# 存储配置redis(可选)
2020
# 注意: 指定redis.host值后不会使用容器注入的redis连接(JedisPool)
21-
wx.miniapp.config-storage.type = jedis # 配置类型: memory(默认), jedis, redistemplate
21+
wx.miniapp.config-storage.type = Jedis # 配置类型: Memory(默认), Jedis, RedisTemplate
2222
wx.miniapp.config-storage.key-prefix = wa # 相关redis前缀配置: wa(默认)
2323
wx.miniapp.config-storage.redis.host = 127.0.0.1
2424
wx.miniapp.config-storage.redis.port = 6379
2525
# http客户端配置
26-
wx.miniapp.config-storage.http-client-type=httpclient # http客户端类型: httpclient(默认)
26+
wx.miniapp.config-storage.http-client-type=HttpClient # http客户端类型: HttpClient(默认), OkHttp, JoddHttp
2727
wx.miniapp.config-storage.http-proxy-host=
2828
wx.miniapp.config-storage.http-proxy-port=
2929
wx.miniapp.config-storage.http-proxy-username=

‎spring-boot-starters/wx-java-miniapp-spring-boot-starter/pom.xml

Copy file name to clipboardExpand all lines: spring-boot-starters/wx-java-miniapp-spring-boot-starter/pom.xml
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>wx-java-spring-boot-starters</artifactId>
77
<groupId>com.github.binarywang</groupId>
8-
<version>3.8.0</version>
8+
<version>3.9.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

@@ -22,13 +22,11 @@
2222
<dependency>
2323
<groupId>redis.clients</groupId>
2424
<artifactId>jedis</artifactId>
25-
<scope>provided</scope>
2625
</dependency>
2726
<dependency>
2827
<groupId>org.springframework.data</groupId>
2928
<artifactId>spring-data-redis</artifactId>
3029
<version>${spring.boot.version}</version>
31-
<scope>provided</scope>
3230
</dependency>
3331
</dependencies>
3432

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package com.binarywang.spring.starter.wxjava.miniapp.config;
22

33
import cn.binarywang.wx.miniapp.api.WxMaService;
4+
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceHttpClientImpl;
45
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
6+
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceJoddHttpImpl;
7+
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceOkHttpImpl;
58
import cn.binarywang.wx.miniapp.config.WxMaConfig;
69
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
710
import cn.binarywang.wx.miniapp.config.impl.WxMaRedisBetterConfigImpl;
11+
import com.binarywang.spring.starter.wxjava.miniapp.enums.HttpClientType;
812
import com.binarywang.spring.starter.wxjava.miniapp.properties.WxMaProperties;
913
import lombok.AllArgsConstructor;
1014
import me.chanjar.weixin.common.redis.JedisWxRedisOps;
@@ -46,22 +50,35 @@ public class WxMaAutoConfiguration {
4650
@Bean
4751
@ConditionalOnMissingBean(WxMaService.class)
4852
public WxMaService service(WxMaConfig wxMaConfig) {
49-
final WxMaServiceImpl service = new WxMaServiceImpl();
50-
service.setWxMaConfig(wxMaConfig);
51-
return service;
53+
HttpClientType httpClientType = wxMaProperties.getConfigStorage().getHttpClientType();
54+
WxMaService wxMaService;
55+
if (httpClientType == HttpClientType.OkHttp) {
56+
wxMaService = new WxMaServiceOkHttpImpl();
57+
} else if (httpClientType == HttpClientType.JoddHttp) {
58+
wxMaService = new WxMaServiceJoddHttpImpl();
59+
} else if (httpClientType == HttpClientType.HttpClient) {
60+
wxMaService = new WxMaServiceHttpClientImpl();
61+
} else {
62+
wxMaService = new WxMaServiceImpl();
63+
}
64+
wxMaService.setWxMaConfig(wxMaConfig);
65+
return wxMaService;
5266
}
5367

5468
@Bean
5569
@ConditionalOnMissingBean(WxMaConfig.class)
5670
public WxMaConfig wxMaConfig() {
57-
WxMaProperties.StorageType type = wxMaProperties.getConfigStorage().getType();
5871
WxMaDefaultConfigImpl config;
59-
if (type == WxMaProperties.StorageType.jedis) {
60-
config = wxMaInJedisConfigStorage();
61-
} else if (type == WxMaProperties.StorageType.redistemplate) {
62-
config = wxMaInRedisTemplateConfigStorage();
63-
} else {
64-
config = wxMaInMemoryConfigStorage();
72+
switch (wxMaProperties.getConfigStorage().getType()) {
73+
case Jedis:
74+
config = wxMaJedisConfigStorage();
75+
break;
76+
case RedisTemplate:
77+
config = wxMaRedisTemplateConfigStorage();
78+
break;
79+
default:
80+
config = wxMaDefaultConfigStorage();
81+
break;
6582
}
6683

6784
config.setAppid(StringUtils.trimToNull(this.wxMaProperties.getAppid()));
@@ -80,52 +97,42 @@ public WxMaConfig wxMaConfig() {
8097
return config;
8198
}
8299

83-
private WxMaDefaultConfigImpl wxMaInMemoryConfigStorage() {
84-
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
85-
return config;
100+
private WxMaDefaultConfigImpl wxMaDefaultConfigStorage() {
101+
return new WxMaDefaultConfigImpl();
86102
}
87103

88-
private WxMaDefaultConfigImpl wxMaInJedisConfigStorage() {
104+
private WxMaDefaultConfigImpl wxMaJedisConfigStorage() {
89105
WxMaProperties.RedisProperties redisProperties = wxMaProperties.getConfigStorage().getRedis();
90106
JedisPool jedisPool;
91-
if (redisProperties != null && StringUtils.isNotEmpty(redisProperties.getHost())) {
92-
jedisPool = getJedisPool();
107+
if (StringUtils.isNotEmpty(redisProperties.getHost())) {
108+
JedisPoolConfig config = new JedisPoolConfig();
109+
if (redisProperties.getMaxActive() != null) {
110+
config.setMaxTotal(redisProperties.getMaxActive());
111+
}
112+
if (redisProperties.getMaxIdle() != null) {
113+
config.setMaxIdle(redisProperties.getMaxIdle());
114+
}
115+
if (redisProperties.getMaxWaitMillis() != null) {
116+
config.setMaxWaitMillis(redisProperties.getMaxWaitMillis());
117+
}
118+
if (redisProperties.getMinIdle() != null) {
119+
config.setMinIdle(redisProperties.getMinIdle());
120+
}
121+
config.setTestOnBorrow(true);
122+
config.setTestWhileIdle(true);
123+
124+
jedisPool = new JedisPool(config, redisProperties.getHost(), redisProperties.getPort(),
125+
redisProperties.getTimeout(), redisProperties.getPassword(), redisProperties.getDatabase());
93126
} else {
94127
jedisPool = applicationContext.getBean(JedisPool.class);
95128
}
96129
WxRedisOps redisOps = new JedisWxRedisOps(jedisPool);
97-
WxMaRedisBetterConfigImpl wxMaRedisConfig = new WxMaRedisBetterConfigImpl(redisOps, wxMaProperties.getConfigStorage().getKeyPrefix());
98-
return wxMaRedisConfig;
130+
return new WxMaRedisBetterConfigImpl(redisOps, wxMaProperties.getConfigStorage().getKeyPrefix());
99131
}
100132

101-
private WxMaDefaultConfigImpl wxMaInRedisTemplateConfigStorage() {
133+
private WxMaDefaultConfigImpl wxMaRedisTemplateConfigStorage() {
102134
StringRedisTemplate redisTemplate = applicationContext.getBean(StringRedisTemplate.class);
103135
WxRedisOps redisOps = new RedisTemplateWxRedisOps(redisTemplate);
104-
WxMaRedisBetterConfigImpl wxMaRedisConfig = new WxMaRedisBetterConfigImpl(redisOps, wxMaProperties.getConfigStorage().getKeyPrefix());
105-
return wxMaRedisConfig;
106-
}
107-
108-
private JedisPool getJedisPool() {
109-
WxMaProperties.ConfigStorage storage = wxMaProperties.getConfigStorage();
110-
WxMaProperties.RedisProperties redis = storage.getRedis();
111-
112-
JedisPoolConfig config = new JedisPoolConfig();
113-
if (redis.getMaxActive() != null) {
114-
config.setMaxTotal(redis.getMaxActive());
115-
}
116-
if (redis.getMaxIdle() != null) {
117-
config.setMaxIdle(redis.getMaxIdle());
118-
}
119-
if (redis.getMaxWaitMillis() != null) {
120-
config.setMaxWaitMillis(redis.getMaxWaitMillis());
121-
}
122-
if (redis.getMinIdle() != null) {
123-
config.setMinIdle(redis.getMinIdle());
124-
}
125-
config.setTestOnBorrow(true);
126-
config.setTestWhileIdle(true);
127-
128-
return new JedisPool(config, redis.getHost(), redis.getPort(), redis.getTimeout(), redis.getPassword(),
129-
redis.getDatabase());
136+
return new WxMaRedisBetterConfigImpl(redisOps, wxMaProperties.getConfigStorage().getKeyPrefix());
130137
}
131138
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.binarywang.spring.starter.wxjava.miniapp.enums;
2+
3+
/**
4+
* httpclient类型.
5+
*
6+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
7+
* @date 2020-05-25
8+
*/
9+
public enum HttpClientType {
10+
/**
11+
* HttpClient.
12+
*/
13+
HttpClient,
14+
/**
15+
* OkHttp.
16+
*/
17+
OkHttp,
18+
/**
19+
* JoddHttp.
20+
*/
21+
JoddHttp,
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.binarywang.spring.starter.wxjava.miniapp.enums;
2+
3+
/**
4+
* storage类型.
5+
*
6+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
7+
* @date 2020-05-25
8+
*/
9+
public enum StorageType {
10+
/**
11+
* 内存.
12+
*/
13+
Memory,
14+
/**
15+
* redis(JedisClient).
16+
*/
17+
Jedis,
18+
/**
19+
* redis(RedisTemplate).
20+
*/
21+
RedisTemplate
22+
}

‎spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/properties/WxMaProperties.java

Copy file name to clipboardExpand all lines: spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/miniapp/properties/WxMaProperties.java
+9-34Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.binarywang.spring.starter.wxjava.miniapp.properties;
22

3+
import com.binarywang.spring.starter.wxjava.miniapp.enums.HttpClientType;
4+
import com.binarywang.spring.starter.wxjava.miniapp.enums.StorageType;
35
import lombok.Data;
46
import org.springframework.boot.context.properties.ConfigurationProperties;
57

6-
import java.io.Serializable;
7-
88
/**
99
* 属性配置类.
1010
*
@@ -42,16 +42,15 @@ public class WxMaProperties {
4242
/**
4343
* 存储策略
4444
*/
45-
private ConfigStorage configStorage = new ConfigStorage();
45+
private final ConfigStorage configStorage = new ConfigStorage();
4646

4747
@Data
48-
public static class ConfigStorage implements Serializable {
49-
private static final long serialVersionUID = 4815731027000065434L;
48+
public static class ConfigStorage {
5049

5150
/**
5251
* 存储类型.
5352
*/
54-
private StorageType type = StorageType.memory;
53+
private StorageType type = StorageType.Memory;
5554

5655
/**
5756
* 指定key前缀.
@@ -61,12 +60,12 @@ public static class ConfigStorage implements Serializable {
6160
/**
6261
* redis连接配置.
6362
*/
64-
private RedisProperties redis;
63+
private final RedisProperties redis = new RedisProperties();
6564

6665
/**
6766
* http客户端类型.
6867
*/
69-
private HttpClientType httpClientType = HttpClientType.httpclient;
68+
private HttpClientType httpClientType = HttpClientType.HttpClient;
7069

7170
/**
7271
* http代理主机.
@@ -87,37 +86,13 @@ public static class ConfigStorage implements Serializable {
8786
* http代理密码.
8887
*/
8988
private String httpProxyPassword;
90-
91-
}
92-
93-
public enum StorageType {
94-
/**
95-
* 内存.
96-
*/
97-
memory,
98-
/**
99-
* redis(JedisClient).
100-
*/
101-
jedis,
102-
/**
103-
* redis(RedisTemplate).
104-
*/
105-
redistemplate
106-
}
107-
108-
public enum HttpClientType {
109-
/**
110-
* HttpClient.
111-
*/
112-
httpclient
11389
}
11490

11591
@Data
116-
public static class RedisProperties implements Serializable {
117-
private static final long serialVersionUID = -5924815351660074401L;
92+
public static class RedisProperties {
11893

11994
/**
120-
* 主机地址.
95+
* 主机地址.不填则从spring容器内获取JedisPool
12196
*/
12297
private String host;
12398

‎spring-boot-starters/wx-java-mp-spring-boot-starter/pom.xml

Copy file name to clipboardExpand all lines: spring-boot-starters/wx-java-mp-spring-boot-starter/pom.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>wx-java-spring-boot-starters</artifactId>
77
<groupId>com.github.binarywang</groupId>
8-
<version>3.8.0</version>
8+
<version>3.9.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.