Skip to content

Commit 476b067

Browse files
authored
Merge pull request #1151 from Wechat-Group/develop
合并 Develop 分支
2 parents 5570cba + 3bf1bb9 commit 476b067

File tree

237 files changed

+6661
-2043
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+6661
-2043
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ language: java
77
# secure: "834110c7191f97ecb226970c46dcaff8e681da5a"
88

99
jdk:
10-
- oraclejdk8
10+
- openjdk8
1111
script: "mvn clean package -DskipTests=true -Dcheckstyle.skip=true"
1212

1313
#script:

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

pom.xml

Lines changed: 6 additions & 4 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.4.0</version>
9+
<version>3.5.0</version>
1010
<packaging>pom</packaging>
1111
<name>WxJava - Weixin/Wechat Java SDK</name>
1212
<description>微信开发Java SDK</description>
@@ -105,8 +105,9 @@
105105
<module>weixin-java-pay</module>
106106
<module>weixin-java-miniapp</module>
107107
<module>weixin-java-open</module>
108-
<module>starters/wx-java-pay-starter</module>
109-
<module>starters/wx-java-mp-starter</module>
108+
<module>spring-boot-starters/wx-java-pay-spring-boot-starter</module>
109+
<module>spring-boot-starters/wx-java-mp-spring-boot-starter</module>
110+
<module>spring-boot-starters/wx-java-miniapp-spring-boot-starter</module>
110111
<!--module>weixin-java-osgi</module-->
111112
</modules>
112113

@@ -246,7 +247,7 @@
246247
<dependency>
247248
<groupId>org.projectlombok</groupId>
248249
<artifactId>lombok</artifactId>
249-
<version>1.16.18</version>
250+
<version>1.18.8</version>
250251
<scope>provided</scope>
251252
</dependency>
252253
</dependencies>
@@ -370,6 +371,7 @@
370371
<artifactId>maven-checkstyle-plugin</artifactId>
371372
<version>2.17</version>
372373
<configuration>
374+
<skip>true</skip>
373375
<configLocation>quality-checks/google_checks.xml</configLocation>
374376
<includeTestSourceDirectory>true</includeTestSourceDirectory>
375377
<consoleOutput>true</consoleOutput>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# 使用说明
2+
1. 在自己的Spring Boot项目里,引入maven依赖
3+
```xml
4+
<dependency>
5+
<groupId>com.github.binarywang</groupId>
6+
<artifactId>wx-java-miniapp-spring-boot-starter</artifactId>
7+
<version>${version}</version>
8+
</dependency>
9+
```
10+
2. 添加配置(application.yml)
11+
```yml
12+
wx:
13+
miniapp:
14+
appid: 111
15+
secret: 111
16+
token: 111
17+
aesKey: 111
18+
msgDataFormat: JSON
19+
```
20+
21+
22+
23+
24+
25+
26+
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>wx-java</artifactId>
7+
<groupId>com.github.binarywang</groupId>
8+
<version>3.5.0</version>
9+
<relativePath>../../</relativePath>
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>wx-java-miniapp-spring-boot-starter</artifactId>
14+
<name>WxJava - Spring Boot Starter for MiniApp</name>
15+
<description>微信小程序开发的 Spring Boot Starter</description>
16+
17+
<properties>
18+
<spring.boot.version>2.1.4.RELEASE</spring.boot.version>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.springframework.boot</groupId>
24+
<artifactId>spring-boot-autoconfigure</artifactId>
25+
<version>${spring.boot.version}</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-configuration-processor</artifactId>
30+
<version>${spring.boot.version}</version>
31+
<optional>true</optional>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.projectlombok</groupId>
35+
<artifactId>lombok</artifactId>
36+
<scope>provided</scope>
37+
</dependency>
38+
<dependency>
39+
<groupId>com.github.binarywang</groupId>
40+
<artifactId>weixin-java-miniapp</artifactId>
41+
<version>${project.version}</version>
42+
</dependency>
43+
</dependencies>
44+
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.springframework.boot</groupId>
49+
<artifactId>spring-boot-maven-plugin</artifactId>
50+
<version>${spring.boot.version}</version>
51+
</plugin>
52+
<plugin>
53+
<groupId>org.apache.maven.plugins</groupId>
54+
<artifactId>maven-source-plugin</artifactId>
55+
<version>2.2.1</version>
56+
<executions>
57+
<execution>
58+
<id>attach-sources</id>
59+
<goals>
60+
<goal>jar-no-fork</goal>
61+
</goals>
62+
</execution>
63+
</executions>
64+
</plugin>
65+
</plugins>
66+
</build>
67+
68+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.binarywang.spring.starter.wxjava.miniapp.config;
2+
3+
import cn.binarywang.wx.miniapp.api.WxMaService;
4+
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
5+
import cn.binarywang.wx.miniapp.config.WxMaConfig;
6+
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
7+
import com.binarywang.spring.starter.wxjava.miniapp.properties.WxMaProperties;
8+
import lombok.AllArgsConstructor;
9+
import org.apache.commons.lang3.StringUtils;
10+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
11+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
12+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
13+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
14+
import org.springframework.context.annotation.Bean;
15+
import org.springframework.context.annotation.Configuration;
16+
17+
/**
18+
* 自动配置.
19+
*
20+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
21+
* @date 2019-08-10
22+
*/
23+
@AllArgsConstructor
24+
@Configuration
25+
@ConditionalOnClass(WxMaService.class)
26+
@EnableConfigurationProperties(WxMaProperties.class)
27+
@ConditionalOnProperty(prefix = "wx.miniapp", value = "enabled", matchIfMissing = true)
28+
public class WxMaAutoConfiguration {
29+
private WxMaProperties properties;
30+
31+
/**
32+
* 小程序service.
33+
*
34+
* @return 小程序service
35+
*/
36+
@Bean
37+
@ConditionalOnMissingBean(WxMaService.class)
38+
public WxMaService service() {
39+
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
40+
config.setAppid(StringUtils.trimToNull(this.properties.getAppid()));
41+
config.setSecret(StringUtils.trimToNull(this.properties.getSecret()));
42+
config.setToken(StringUtils.trimToNull(this.properties.getToken()));
43+
config.setAesKey(StringUtils.trimToNull(this.properties.getAesKey()));
44+
config.setMsgDataFormat(StringUtils.trimToNull(this.properties.getMsgDataFormat()));
45+
46+
final WxMaServiceImpl service = new WxMaServiceImpl();
47+
service.setWxMaConfig(config);
48+
return service;
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.binarywang.spring.starter.wxjava.miniapp.properties;
2+
3+
import lombok.Data;
4+
import org.springframework.boot.context.properties.ConfigurationProperties;
5+
6+
/**
7+
* 属性配置类.
8+
*
9+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
10+
* @date 2019-08-10
11+
*/
12+
@Data
13+
@ConfigurationProperties(prefix = "wx.miniapp")
14+
public class WxMaProperties {
15+
/**
16+
* 设置微信小程序的appid.
17+
*/
18+
private String appid;
19+
20+
/**
21+
* 设置微信小程序的Secret.
22+
*/
23+
private String secret;
24+
25+
/**
26+
* 设置微信小程序消息服务器配置的token.
27+
*/
28+
private String token;
29+
30+
/**
31+
* 设置微信小程序消息服务器配置的EncodingAESKey.
32+
*/
33+
private String aesKey;
34+
35+
/**
36+
* 消息格式,XML或者JSON.
37+
*/
38+
private String msgDataFormat;
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.binarywang.spring.starter.wxjava.miniapp.config.WxMaAutoConfiguration

starters/wx-java-mp-starter/README.md renamed to spring-boot-starters/wx-java-mp-spring-boot-starter/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
```xml
55
<dependency>
66
<groupId>com.github.binarywang</groupId>
7-
<artifactId>wx-java-mp-starter</artifactId>
7+
<artifactId>wx-java-mp-spring-boot-starter</artifactId>
88
<version>${version}</version>
99
</dependency>
1010
```

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<parent>
77
<groupId>com.github.binarywang</groupId>
88
<artifactId>wx-java</artifactId>
9-
<version>3.4.0</version>
9+
<version>3.5.0</version>
1010
<relativePath>../../</relativePath>
1111
</parent>
1212

13-
<artifactId>wx-java-mp-starter</artifactId>
13+
<artifactId>wx-java-mp-spring-boot-starter</artifactId>
1414
<name>WxJava - Spring Boot Starter for MP</name>
15-
<description>微信公众号开发的Spring Boot Starter</description>
15+
<description>微信公众号开发的 Spring Boot Starter</description>
1616

1717
<properties>
1818
<spring.boot.version>2.1.4.RELEASE</spring.boot.version>

starters/wx-java-mp-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/WxMpAutoConfiguration.java renamed to spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/config/WxMpAutoConfiguration.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
package com.binarywang.spring.starter.wxjava.mp;
1+
package com.binarywang.spring.starter.wxjava.mp.config;
22

3+
import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties;
34
import org.springframework.boot.context.properties.EnableConfigurationProperties;
45
import org.springframework.context.annotation.Configuration;
56
import org.springframework.context.annotation.Import;
67

8+
/**
9+
* .
10+
*
11+
* @author someone
12+
*/
713
@Configuration
814
@EnableConfigurationProperties(WxMpProperties.class)
915
@Import({WxMpStorageAutoConfiguration.class, WxMpServiceAutoConfiguration.class})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.binarywang.spring.starter.wxjava.mp.config;
2+
3+
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
4+
import me.chanjar.weixin.mp.api.WxMpService;
5+
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
8+
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
9+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
10+
import org.springframework.context.ApplicationContext;
11+
import org.springframework.context.annotation.Bean;
12+
import org.springframework.context.annotation.Configuration;
13+
14+
/**
15+
* 微信公众号相关服务自动注册.
16+
*
17+
* @author someone
18+
*/
19+
@Configuration
20+
public class WxMpServiceAutoConfiguration {
21+
@Autowired
22+
private ApplicationContext ctx;
23+
24+
@Bean
25+
@ConditionalOnMissingBean
26+
public WxMpService wxMpService(WxMpConfigStorage configStorage) {
27+
WxMpService wxMpService = new WxMpServiceImpl();
28+
wxMpService.setWxMpConfigStorage(configStorage);
29+
registerWxMpSubService(wxMpService);
30+
return wxMpService;
31+
}
32+
33+
@ConditionalOnBean(WxMpService.class)
34+
public Object registerWxMpSubService(WxMpService wxMpService) {
35+
ConfigurableListableBeanFactory factory = (ConfigurableListableBeanFactory) ctx.getAutowireCapableBeanFactory();
36+
factory.registerSingleton("wxMpKefuService", wxMpService.getKefuService());
37+
factory.registerSingleton("wxMpMaterialService", wxMpService.getMaterialService());
38+
factory.registerSingleton("wxMpMenuService", wxMpService.getMenuService());
39+
factory.registerSingleton("wxMpUserService", wxMpService.getUserService());
40+
factory.registerSingleton("wxMpUserTagService", wxMpService.getUserTagService());
41+
factory.registerSingleton("wxMpQrcodeService", wxMpService.getQrcodeService());
42+
factory.registerSingleton("wxMpCardService", wxMpService.getCardService());
43+
factory.registerSingleton("wxMpDataCubeService", wxMpService.getDataCubeService());
44+
factory.registerSingleton("wxMpUserBlacklistService", wxMpService.getBlackListService());
45+
factory.registerSingleton("wxMpStoreService", wxMpService.getStoreService());
46+
factory.registerSingleton("wxMpTemplateMsgService", wxMpService.getTemplateMsgService());
47+
factory.registerSingleton("wxMpSubscribeMsgService", wxMpService.getSubscribeMsgService());
48+
factory.registerSingleton("wxMpDeviceService", wxMpService.getDeviceService());
49+
factory.registerSingleton("wxMpShakeService", wxMpService.getShakeService());
50+
factory.registerSingleton("wxMpMemberCardService", wxMpService.getMemberCardService());
51+
factory.registerSingleton("wxMpMassMessageService", wxMpService.getMassMessageService());
52+
return Boolean.TRUE;
53+
}
54+
55+
}

0 commit comments

Comments
 (0)