-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1151 from Wechat-Group/develop
合并 Develop 分支
- Loading branch information
Showing
237 changed files
with
6,661 additions
and
2,043 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
spring-boot-starters/wx-java-miniapp-spring-boot-starter/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# 使用说明 | ||
1. 在自己的Spring Boot项目里,引入maven依赖 | ||
```xml | ||
<dependency> | ||
<groupId>com.github.binarywang</groupId> | ||
<artifactId>wx-java-miniapp-spring-boot-starter</artifactId> | ||
<version>${version}</version> | ||
</dependency> | ||
``` | ||
2. 添加配置(application.yml) | ||
```yml | ||
wx: | ||
miniapp: | ||
appid: 111 | ||
secret: 111 | ||
token: 111 | ||
aesKey: 111 | ||
msgDataFormat: JSON | ||
``` | ||
68 changes: 68 additions & 0 deletions
68
spring-boot-starters/wx-java-miniapp-spring-boot-starter/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>wx-java</artifactId> | ||
<groupId>com.github.binarywang</groupId> | ||
<version>3.5.0</version> | ||
<relativePath>../../</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>wx-java-miniapp-spring-boot-starter</artifactId> | ||
<name>WxJava - Spring Boot Starter for MiniApp</name> | ||
<description>微信小程序开发的 Spring Boot Starter</description> | ||
|
||
<properties> | ||
<spring.boot.version>2.1.4.RELEASE</spring.boot.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-autoconfigure</artifactId> | ||
<version>${spring.boot.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-configuration-processor</artifactId> | ||
<version>${spring.boot.version}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.binarywang</groupId> | ||
<artifactId>weixin-java-miniapp</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<version>${spring.boot.version}</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>2.2.1</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar-no-fork</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
50 changes: 50 additions & 0 deletions
50
.../main/java/com/binarywang/spring/starter/wxjava/miniapp/config/WxMaAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.binarywang.spring.starter.wxjava.miniapp.config; | ||
|
||
import cn.binarywang.wx.miniapp.api.WxMaService; | ||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; | ||
import cn.binarywang.wx.miniapp.config.WxMaConfig; | ||
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; | ||
import com.binarywang.spring.starter.wxjava.miniapp.properties.WxMaProperties; | ||
import lombok.AllArgsConstructor; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* 自动配置. | ||
* | ||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | ||
* @date 2019-08-10 | ||
*/ | ||
@AllArgsConstructor | ||
@Configuration | ||
@ConditionalOnClass(WxMaService.class) | ||
@EnableConfigurationProperties(WxMaProperties.class) | ||
@ConditionalOnProperty(prefix = "wx.miniapp", value = "enabled", matchIfMissing = true) | ||
public class WxMaAutoConfiguration { | ||
private WxMaProperties properties; | ||
|
||
/** | ||
* 小程序service. | ||
* | ||
* @return 小程序service | ||
*/ | ||
@Bean | ||
@ConditionalOnMissingBean(WxMaService.class) | ||
public WxMaService service() { | ||
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); | ||
config.setAppid(StringUtils.trimToNull(this.properties.getAppid())); | ||
config.setSecret(StringUtils.trimToNull(this.properties.getSecret())); | ||
config.setToken(StringUtils.trimToNull(this.properties.getToken())); | ||
config.setAesKey(StringUtils.trimToNull(this.properties.getAesKey())); | ||
config.setMsgDataFormat(StringUtils.trimToNull(this.properties.getMsgDataFormat())); | ||
|
||
final WxMaServiceImpl service = new WxMaServiceImpl(); | ||
service.setWxMaConfig(config); | ||
return service; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...src/main/java/com/binarywang/spring/starter/wxjava/miniapp/properties/WxMaProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.binarywang.spring.starter.wxjava.miniapp.properties; | ||
|
||
import lombok.Data; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
/** | ||
* 属性配置类. | ||
* | ||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | ||
* @date 2019-08-10 | ||
*/ | ||
@Data | ||
@ConfigurationProperties(prefix = "wx.miniapp") | ||
public class WxMaProperties { | ||
/** | ||
* 设置微信小程序的appid. | ||
*/ | ||
private String appid; | ||
|
||
/** | ||
* 设置微信小程序的Secret. | ||
*/ | ||
private String secret; | ||
|
||
/** | ||
* 设置微信小程序消息服务器配置的token. | ||
*/ | ||
private String token; | ||
|
||
/** | ||
* 设置微信小程序消息服务器配置的EncodingAESKey. | ||
*/ | ||
private String aesKey; | ||
|
||
/** | ||
* 消息格式,XML或者JSON. | ||
*/ | ||
private String msgDataFormat; | ||
} |
1 change: 1 addition & 0 deletions
1
...starters/wx-java-miniapp-spring-boot-starter/src/main/resources/META-INF/spring.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.binarywang.spring.starter.wxjava.miniapp.config.WxMaAutoConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
...rter/wxjava/mp/WxMpAutoConfiguration.java → ...java/mp/config/WxMpAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...ain/java/com/binarywang/spring/starter/wxjava/mp/config/WxMpServiceAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.binarywang.spring.starter.wxjava.mp.config; | ||
|
||
import me.chanjar.weixin.mp.config.WxMpConfigStorage; | ||
import me.chanjar.weixin.mp.api.WxMpService; | ||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* 微信公众号相关服务自动注册. | ||
* | ||
* @author someone | ||
*/ | ||
@Configuration | ||
public class WxMpServiceAutoConfiguration { | ||
@Autowired | ||
private ApplicationContext ctx; | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public WxMpService wxMpService(WxMpConfigStorage configStorage) { | ||
WxMpService wxMpService = new WxMpServiceImpl(); | ||
wxMpService.setWxMpConfigStorage(configStorage); | ||
registerWxMpSubService(wxMpService); | ||
return wxMpService; | ||
} | ||
|
||
@ConditionalOnBean(WxMpService.class) | ||
public Object registerWxMpSubService(WxMpService wxMpService) { | ||
ConfigurableListableBeanFactory factory = (ConfigurableListableBeanFactory) ctx.getAutowireCapableBeanFactory(); | ||
factory.registerSingleton("wxMpKefuService", wxMpService.getKefuService()); | ||
factory.registerSingleton("wxMpMaterialService", wxMpService.getMaterialService()); | ||
factory.registerSingleton("wxMpMenuService", wxMpService.getMenuService()); | ||
factory.registerSingleton("wxMpUserService", wxMpService.getUserService()); | ||
factory.registerSingleton("wxMpUserTagService", wxMpService.getUserTagService()); | ||
factory.registerSingleton("wxMpQrcodeService", wxMpService.getQrcodeService()); | ||
factory.registerSingleton("wxMpCardService", wxMpService.getCardService()); | ||
factory.registerSingleton("wxMpDataCubeService", wxMpService.getDataCubeService()); | ||
factory.registerSingleton("wxMpUserBlacklistService", wxMpService.getBlackListService()); | ||
factory.registerSingleton("wxMpStoreService", wxMpService.getStoreService()); | ||
factory.registerSingleton("wxMpTemplateMsgService", wxMpService.getTemplateMsgService()); | ||
factory.registerSingleton("wxMpSubscribeMsgService", wxMpService.getSubscribeMsgService()); | ||
factory.registerSingleton("wxMpDeviceService", wxMpService.getDeviceService()); | ||
factory.registerSingleton("wxMpShakeService", wxMpService.getShakeService()); | ||
factory.registerSingleton("wxMpMemberCardService", wxMpService.getMemberCardService()); | ||
factory.registerSingleton("wxMpMassMessageService", wxMpService.getMassMessageService()); | ||
return Boolean.TRUE; | ||
} | ||
|
||
} |
Oops, something went wrong.