Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mica
mica-weixin
提交
afb5f427
M
mica-weixin
项目概览
mica
/
mica-weixin
通知
8
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mica-weixin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
afb5f427
编写于
4月 27, 2021
作者:
如梦技术
🐛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🔖
2.1.0
上级
1a7ac2b7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
38 addition
and
15 deletion
+38
-15
README.md
README.md
+9
-2
mica-weixin-demo/pom.xml
mica-weixin-demo/pom.xml
+9
-3
mica-weixin/build.gradle
mica-weixin/build.gradle
+2
-2
mica-weixin/gradle.properties
mica-weixin/gradle.properties
+1
-1
mica-weixin/src/main/java/net/dreamlu/weixin/cache/SpringAccessTokenCache.java
...java/net/dreamlu/weixin/cache/SpringAccessTokenCache.java
+16
-4
mica-weixin/src/main/java/net/dreamlu/weixin/config/DreamWeixinAutoConfiguration.java
...t/dreamlu/weixin/config/DreamWeixinAutoConfiguration.java
+1
-3
未找到文件。
README.md
浏览文件 @
afb5f427
...
...
@@ -20,7 +20,7 @@ jfinal weixin 的 spring boot starter,这个starter是为了方便boot用户
<dependency>
<groupId>
net.dreamlu
</groupId>
<artifactId>
mica-weixin
</artifactId>
<version>
2.
0.6
</version>
<version>
2.
1.0
</version>
</dependency>
```
...
...
@@ -39,6 +39,9 @@ jfinal weixin 的 spring boot starter,这个starter是为了方便boot用户
### Api
-
类添加
`@WxApi`
,注解value为你的消息地址,使用/weixin/api,已经组合[@RequestMapping和@Controller]
### access token cache
您可以配置
[
mica-caffeine
](
https://gitee.com/596392912/mica/tree/master/mica-caffeine
)
或
[
mica-redis
](
https://gitee.com/596392912/mica/tree/master/mica-redis
)
实现 access token 的缓存。
### 配置
| 配置项 | 默认值 | 说明 |
| ----- | ------ | ------ |
...
...
@@ -71,7 +74,11 @@ dream:
-
`access-token-cache`
建议配置有效时间7100秒。
## 更新说明
### 2020-12-16 2.0.6
### 2021-04-27 2.1.0
-
Spring cache 对象改为每次读取, caffeine 会刷新,照成引用为 null。
-
升级 jfinal-weixin 到 3.1。
### 2020-03-20 2.0.6
-
升级 jfinal-weixin 到 3.0。
### 2020-12-16 2.0.5
...
...
mica-weixin-demo/pom.xml
浏览文件 @
afb5f427
...
...
@@ -33,13 +33,19 @@
<dependency>
<groupId>
net.dreamlu
</groupId>
<artifactId>
mica-weixin
</artifactId>
<version>
2.
0.6
</version>
<version>
2.
1.0
</version>
</dependency>
<!-- redis 存储 weixin,可选依赖,对 Spring boot 有版本兼容,需要自行选择合适的版本 -->
<!-- caffeine 存储 weixin token,可选依赖,对 Spring boot 有版本兼容,需要自行选择合适的版本 -->
<!-- <dependency>-->
<!-- <groupId>net.dreamlu</groupId>-->
<!-- <artifactId>mica-caffeine</artifactId>-->
<!-- <version>2.4.5-GA</version>-->
<!-- </dependency>-->
<!-- redis 存储 weixin token,可选依赖,对 Spring boot 有版本兼容,需要自行选择合适的版本 -->
<!-- <dependency>-->
<!-- <groupId>net.dreamlu</groupId>-->
<!-- <artifactId>mica-redis</artifactId>-->
<!-- <version>2.4.
3
-GA</version>-->
<!-- <version>2.4.
5
-GA</version>-->
<!-- </dependency>-->
</dependencies>
...
...
mica-weixin/build.gradle
浏览文件 @
afb5f427
...
...
@@ -5,10 +5,10 @@ ext {
javaVersion
=
JavaVersion
.
VERSION_1_8
springBootVersion
=
"2.4.4"
jfinalVersion
=
"4.9.08"
jfinalWeixinVersion
=
"3.
0
"
jfinalWeixinVersion
=
"3.
1
"
okhttpVersion
=
"3.14.9"
micaAutoVersion
=
"2.0.4"
lombokVersion
=
"1.18.
18
"
lombokVersion
=
"1.18.
20
"
}
allprojects
{
...
...
mica-weixin/gradle.properties
浏览文件 @
afb5f427
VERSION
=
2.
0.6
VERSION
=
2.
1.0
GROUPID
=
net.dreamlu
userName
=
chunmeng
...
...
mica-weixin/src/main/java/net/dreamlu/weixin/cache/SpringAccessTokenCache.java
浏览文件 @
afb5f427
...
...
@@ -2,7 +2,11 @@ package net.dreamlu.weixin.cache;
import
com.jfinal.weixin.sdk.cache.IAccessTokenCache
;
import
lombok.RequiredArgsConstructor
;
import
net.dreamlu.weixin.properties.DreamWeixinProperties
;
import
org.springframework.cache.Cache
;
import
org.springframework.cache.CacheManager
;
import
java.util.Objects
;
/**
* 基于 spring cache 的 weixin token 缓存
...
...
@@ -12,20 +16,28 @@ import org.springframework.cache.Cache;
@RequiredArgsConstructor
public
class
SpringAccessTokenCache
implements
IAccessTokenCache
{
private
final
static
String
ACCESS_TOKEN_PREFIX
=
"dream-weixin:token:"
;
private
final
Cache
cache
;
private
final
CacheManager
cacheManager
;
private
final
DreamWeixinProperties
properties
;
@Override
public
String
get
(
String
key
)
{
return
cache
.
get
(
ACCESS_TOKEN_PREFIX
+
key
,
String
.
class
);
return
getCache
()
.
get
(
ACCESS_TOKEN_PREFIX
+
key
,
String
.
class
);
}
@Override
public
void
set
(
String
key
,
String
jsonValue
)
{
cache
.
put
(
ACCESS_TOKEN_PREFIX
+
key
,
jsonValue
);
getCache
()
.
put
(
ACCESS_TOKEN_PREFIX
+
key
,
jsonValue
);
}
@Override
public
void
remove
(
String
key
)
{
cache
.
evict
(
ACCESS_TOKEN_PREFIX
+
key
);
getCache
().
evict
(
ACCESS_TOKEN_PREFIX
+
key
);
}
private
Cache
getCache
()
{
String
accessTokenCacheName
=
properties
.
getAccessTokenCache
();
Cache
cache
=
cacheManager
.
getCache
(
accessTokenCacheName
);
return
Objects
.
requireNonNull
(
cache
,
"AccessToken cache is null."
);
}
}
mica-weixin/src/main/java/net/dreamlu/weixin/config/DreamWeixinAutoConfiguration.java
浏览文件 @
afb5f427
...
...
@@ -5,7 +5,6 @@ import net.dreamlu.weixin.cache.SpringAccessTokenCache;
import
net.dreamlu.weixin.properties.DreamWeixinProperties
;
import
net.dreamlu.weixin.spring.MsgInterceptor
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cache.Cache
;
import
org.springframework.cache.CacheManager
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -26,8 +25,7 @@ public class DreamWeixinAutoConfiguration {
@Bean
public
SpringAccessTokenCache
springAccessTokenCache
(
CacheManager
cacheManager
,
DreamWeixinProperties
properties
)
{
Cache
cache
=
cacheManager
.
getCache
(
properties
.
getAccessTokenCache
());
return
new
SpringAccessTokenCache
(
cache
);
return
new
SpringAccessTokenCache
(
cacheManager
,
properties
);
}
@Configuration
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录