From 75fa6d8be8bd165e8f9762f163c12b0532e1ff99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A6=82=E6=A2=A6=E6=8A=80=E6=9C=AF?= <596392912@qq.com>
Date: Fri, 20 Apr 2018 18:01:34 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20v1.2.0=20=E6=B6=88=E6=81=AF=E6=8E=A7?=
=?UTF-8?q?=E5=88=B6=E5=99=A8=E9=BB=98=E8=AE=A4=E4=B8=BA=E5=A4=9A=E4=BE=8B?=
=?UTF-8?q?=EF=BC=8C=E5=9B=A0=E4=B8=BA=20jfinal-weixin=20=E6=8E=A7?=
=?UTF-8?q?=E5=88=B6=E5=99=A8=E4=B8=8A=20inMsg=20=E4=BD=9C=E4=B8=BA?=
=?UTF-8?q?=E4=BA=86=E5=85=A8=E5=B1=80=E5=8F=98=E9=87=8F=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 28 ++++++++++++++++---
spring-boot-starter-weixin/gradle.properties | 2 +-
.../weixin/annotation/WxMsgController.java | 3 ++
.../weixin/config/WeixinAppConfig.java | 3 ++
.../dreamlu/weixin/config/WxaMsgParser.java | 10 +++++++
.../properties/DreamWeixinProperties.java | 25 ++++++++++++++---
spring-boot-weixin-demo/pom.xml | 4 +--
.../com/example/demo/WeixinController.java | 2 +-
8 files changed, 65 insertions(+), 12 deletions(-)
create mode 100644 spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/config/WxaMsgParser.java
diff --git a/README.md b/README.md
index 6f4d02b..6639aba 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ jfinal weixin 的 spring boot starter,这个starter是为了方便boot用户
net.dreamlu
spring-boot-starter-weixin
- 1.1.0
+ 1.2.0
```
@@ -47,7 +47,22 @@ jfinal weixin 的 spring boot starter,这个starter是为了方便boot用户
| dream.weixin.wxa-config | 小程序配置 | 小程序配置 |
`注意`:
-- 可参考demo中的[application.yml](spring-boot-weixin-demo/src/main/resources/application.yml)
+- demo中的`application.yml`
+```yml
+dream:
+ weixin:
+ dev-mode: true
+ wx-configs:
+ - appId: wx9803d1188fa5fbda
+ appSecret: db859c968763c582794e7c3d003c3d87
+ - appId: wxc03edcd008ad1e70
+ appSecret: 11ed9e2b8e3e3c131e7be320a42b2b5a
+ token: 123456
+ wxa-config:
+ appid: wx4f53594f9a6b3dcb
+ appSecret: eec6482ba3804df05bd10895bace0579
+```
+
- cache使用spring的cache,需要`@EnableCaching`开启。
- `access-token-cache`建议配置有效时间7100秒。
@@ -56,13 +71,18 @@ jfinal weixin 的 spring boot starter,这个starter是为了方便boot用户
## VIP群
-捐助¥199即可加入如梦技术VIP,捐助后联系QQ: 596392912
+捐助~~¥199~~限时¥99,即可加入如梦技术VIP,捐助后联系QQ: 596392912
#### VIP权益
1. spring boot版安全框架(maven + spring boot + spring security + thymeleaf)
-2. 技术资料共享
+2. 技术资料共享,技术指导和技术路线规划。
3. spring cloud脚手架(改造中)
4. 更多私有Git资源,
+
+### spring boot版安全框架 Demo
+地址:http://demo.dreamlu.net
+
+账号vs密码:test、test
diff --git a/spring-boot-starter-weixin/gradle.properties b/spring-boot-starter-weixin/gradle.properties
index fee0146..cf6c862 100644
--- a/spring-boot-starter-weixin/gradle.properties
+++ b/spring-boot-starter-weixin/gradle.properties
@@ -1,4 +1,4 @@
-VERSION=1.1.0
+VERSION=1.2.0
GROUPID=net.dreamlu
userName=chunmeng
diff --git a/spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/annotation/WxMsgController.java b/spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/annotation/WxMsgController.java
index 1806b7e..f127ee8 100644
--- a/spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/annotation/WxMsgController.java
+++ b/spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/annotation/WxMsgController.java
@@ -1,5 +1,7 @@
package net.dreamlu.weixin.annotation;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.lang.annotation.*;
@@ -13,6 +15,7 @@ import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public @interface WxMsgController {
String value() default "/";
diff --git a/spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/config/WeixinAppConfig.java b/spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/config/WeixinAppConfig.java
index 8f9581b..229e51d 100644
--- a/spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/config/WeixinAppConfig.java
+++ b/spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/config/WeixinAppConfig.java
@@ -27,5 +27,8 @@ public class WeixinAppConfig implements InitializingBean {
WxaConfig wxaConfig = weixinProperties.getWxaConfig();
WxaConfigKit.setDevMode(isdev);
WxaConfigKit.setWxaConfig(wxaConfig);
+ if (WxaMsgParser.JSON == weixinProperties.getWxaMsgParser()) {
+ WxaConfigKit.useJsonMsgParser();
+ }
}
}
diff --git a/spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/config/WxaMsgParser.java b/spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/config/WxaMsgParser.java
new file mode 100644
index 0000000..12c75af
--- /dev/null
+++ b/spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/config/WxaMsgParser.java
@@ -0,0 +1,10 @@
+package net.dreamlu.weixin.config;
+
+/**
+ * 小程序消息解析
+ *
+ * @author L.cm
+ */
+public enum WxaMsgParser {
+ JSON, XML
+}
diff --git a/spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/properties/DreamWeixinProperties.java b/spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/properties/DreamWeixinProperties.java
index 5b01432..32aa61c 100644
--- a/spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/properties/DreamWeixinProperties.java
+++ b/spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/properties/DreamWeixinProperties.java
@@ -4,6 +4,7 @@ import com.jfinal.weixin.sdk.api.ApiConfig;
import com.jfinal.wxaapp.WxaConfig;
import lombok.Getter;
import lombok.Setter;
+import net.dreamlu.weixin.config.WxaMsgParser;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.ArrayList;
@@ -13,35 +14,51 @@ import java.util.List;
public class DreamWeixinProperties {
/**
- * JFinal filter拦截的路由
+ * JFinal filter拦截的路由,默认:/weixin/*
*/
@Getter
@Setter
private String urlPatterns = "/weixin/*";
/**
- * 是否开发模式
+ * 是否开发模式,默认:false
*/
@Getter
@Setter
private boolean devMode = false;
/**
- * accessTokenCache
- * Spring cache name
+ * Spring cache name,需要开启spring cache,默认:dreamWeixinCache
*/
@Getter
@Setter
private String accessTokenCache = "dreamWeixinCache";
+ /**
+ * 多公众号url挂参,默认:appId
+ */
@Getter
@Setter
private String appIdKey = "appId";
+ /**
+ * 多公众号配置
+ */
@Getter
private List wxConfigs = new ArrayList();
+ /**
+ * 小程序配置
+ */
@Getter
@Setter
private WxaConfig wxaConfig = new WxaConfig();
+
+ /**
+ * 小程序消息解析,默认xml,支持json和xml
+ */
+ @Getter
+ @Setter
+ private WxaMsgParser wxaMsgParser = WxaMsgParser.XML;
+
}
diff --git a/spring-boot-weixin-demo/pom.xml b/spring-boot-weixin-demo/pom.xml
index 4064671..ecc5a1f 100644
--- a/spring-boot-weixin-demo/pom.xml
+++ b/spring-boot-weixin-demo/pom.xml
@@ -14,7 +14,7 @@
org.springframework.boot
spring-boot-starter-parent
- 1.5.10.RELEASE
+ 1.5.12.RELEASE
@@ -36,7 +36,7 @@
net.dreamlu
spring-boot-starter-weixin
- 1.1.0
+ 1.2.0
org.springframework.boot
diff --git a/spring-boot-weixin-demo/src/main/java/com/example/demo/WeixinController.java b/spring-boot-weixin-demo/src/main/java/com/example/demo/WeixinController.java
index 62d7e68..339beaf 100644
--- a/spring-boot-weixin-demo/src/main/java/com/example/demo/WeixinController.java
+++ b/spring-boot-weixin-demo/src/main/java/com/example/demo/WeixinController.java
@@ -26,7 +26,7 @@ public class WeixinController extends MsgControllerAdapter {
protected void processInTextMsg(InTextMsg inTextMsg) {
System.out.println(weixinProperties.getWxaConfig().getAppId());
OutTextMsg outMsg = new OutTextMsg(inTextMsg);
- outMsg.setContent("文本消息~");
+ outMsg.setContent(inTextMsg.getContent());
render(outMsg);
}
--
GitLab