-
-
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.
- Loading branch information
1 parent
a8232f6
commit e7f2bd6
Showing
54 changed files
with
3,928 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
.bash | ||
.history | ||
|
||
*.class | ||
test-output | ||
|
||
|
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
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
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
45 changes: 45 additions & 0 deletions
45
spring-boot-starters/wx-java-qidian-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,45 @@ | ||
# wx-java-qidian-spring-boot-starter | ||
|
||
## 快速开始 | ||
|
||
1. 引入依赖 | ||
```xml | ||
<dependency> | ||
<groupId>com.github.binarywang</groupId> | ||
<artifactId>wx-java-qidian-spring-boot-starter</artifactId> | ||
<version>${version}</version> | ||
</dependency> | ||
``` | ||
2. 添加配置(application.properties) | ||
```properties | ||
# 公众号配置(必填) | ||
wx.mp.appId = appId | ||
wx.mp.secret = @secret | ||
wx.mp.token = @token | ||
wx.mp.aesKey = @aesKey | ||
# 存储配置redis(可选) | ||
wx.mp.config-storage.type = Jedis # 配置类型: Memory(默认), Jedis, RedisTemplate | ||
wx.mp.config-storage.key-prefix = wx # 相关redis前缀配置: wx(默认) | ||
wx.mp.config-storage.redis.host = 127.0.0.1 | ||
wx.mp.config-storage.redis.port = 6379 | ||
#单机和sentinel同时存在时,优先使用sentinel配置 | ||
#wx.mp.config-storage.redis.sentinel-ips=127.0.0.1:16379,127.0.0.1:26379 | ||
#wx.mp.config-storage.redis.sentinel-name=mymaster | ||
# http客户端配置 | ||
wx.mp.config-storage.http-client-type=httpclient # http客户端类型: HttpClient(默认), OkHttp, JoddHttp | ||
wx.mp.config-storage.http-proxy-host= | ||
wx.mp.config-storage.http-proxy-port= | ||
wx.mp.config-storage.http-proxy-username= | ||
wx.mp.config-storage.http-proxy-password= | ||
# 公众号地址host配置 | ||
#wx.mp.hosts.api-host=http://proxy.com/ | ||
#wx.mp.hosts.open-host=http://proxy.com/ | ||
#wx.mp.hosts.mp-host=http://proxy.com/ | ||
``` | ||
3. 自动注入的类型 | ||
|
||
- `WxMpService` | ||
- `WxMpConfigStorage` | ||
|
||
4、参考 demo: | ||
https://github.com/binarywang/wx-java-mp-demo |
66 changes: 66 additions & 0 deletions
66
spring-boot-starters/wx-java-qidian-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,66 @@ | ||
<?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-spring-boot-starters</artifactId> | ||
<groupId>com.github.binarywang</groupId> | ||
<version>4.0.1.B</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>wx-java-qidian-spring-boot-starter</artifactId> | ||
<name>WxJava - Spring Boot Starter for QiDian</name> | ||
<description>腾讯企点的 Spring Boot Starter</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.github.binarywang</groupId> | ||
<artifactId>weixin-java-qidian</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>redis.clients</groupId> | ||
<artifactId>jedis</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.data</groupId> | ||
<artifactId>spring-data-redis</artifactId> | ||
<version>${spring.boot.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jodd</groupId> | ||
<artifactId>jodd-http</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.squareup.okhttp3</groupId> | ||
<artifactId>okhttp</artifactId> | ||
<scope>provided</scope> | ||
</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> |
17 changes: 17 additions & 0 deletions
17
...in/java/com/binarywang/spring/starter/wxjava/qidian/config/WxQidianAutoConfiguration.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,17 @@ | ||
package com.binarywang.spring.starter.wxjava.qidian.config; | ||
|
||
import com.binarywang.spring.starter.wxjava.qidian.properties.WxQidianProperties; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
|
||
/** | ||
* . | ||
* | ||
* @author someone | ||
*/ | ||
@Configuration | ||
@EnableConfigurationProperties(WxQidianProperties.class) | ||
@Import({ WxQidianStorageAutoConfiguration.class, WxQidianServiceAutoConfiguration.class }) | ||
public class WxQidianAutoConfiguration { | ||
} |
63 changes: 63 additions & 0 deletions
63
.../com/binarywang/spring/starter/wxjava/qidian/config/WxQidianServiceAutoConfiguration.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,63 @@ | ||
package com.binarywang.spring.starter.wxjava.qidian.config; | ||
|
||
import com.binarywang.spring.starter.wxjava.qidian.enums.HttpClientType; | ||
import com.binarywang.spring.starter.wxjava.qidian.properties.WxQidianProperties; | ||
import me.chanjar.weixin.qidian.api.WxQidianService; | ||
import me.chanjar.weixin.qidian.api.impl.WxQidianServiceHttpClientImpl; | ||
import me.chanjar.weixin.qidian.api.impl.WxQidianServiceImpl; | ||
import me.chanjar.weixin.qidian.api.impl.WxQidianServiceJoddHttpImpl; | ||
import me.chanjar.weixin.qidian.api.impl.WxQidianServiceOkHttpImpl; | ||
import me.chanjar.weixin.qidian.config.WxQidianConfigStorage; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* 腾讯企点相关服务自动注册. | ||
* | ||
* @author alegria | ||
*/ | ||
@Configuration | ||
public class WxQidianServiceAutoConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public WxQidianService wxQidianService(WxQidianConfigStorage configStorage, WxQidianProperties wxQidianProperties) { | ||
HttpClientType httpClientType = wxQidianProperties.getConfigStorage().getHttpClientType(); | ||
WxQidianService wxQidianService; | ||
switch (httpClientType) { | ||
case OkHttp: | ||
wxQidianService = newWxQidianServiceOkHttpImpl(); | ||
break; | ||
case JoddHttp: | ||
wxQidianService = newWxQidianServiceJoddHttpImpl(); | ||
break; | ||
case HttpClient: | ||
wxQidianService = newWxQidianServiceHttpClientImpl(); | ||
break; | ||
default: | ||
wxQidianService = newWxQidianServiceImpl(); | ||
break; | ||
} | ||
|
||
wxQidianService.setWxMpConfigStorage(configStorage); | ||
return wxQidianService; | ||
} | ||
|
||
private WxQidianService newWxQidianServiceImpl() { | ||
return new WxQidianServiceImpl(); | ||
} | ||
|
||
private WxQidianService newWxQidianServiceHttpClientImpl() { | ||
return new WxQidianServiceHttpClientImpl(); | ||
} | ||
|
||
private WxQidianService newWxQidianServiceOkHttpImpl() { | ||
return new WxQidianServiceOkHttpImpl(); | ||
} | ||
|
||
private WxQidianService newWxQidianServiceJoddHttpImpl() { | ||
return new WxQidianServiceJoddHttpImpl(); | ||
} | ||
|
||
} |
Oops, something went wrong.