- 微信小程序登录。
- 微信用户信息同步。
- 微信小程序支付。
- 新增
微信小程序用户体系
:新增用户表,区别于若依原有的管理后台用户角色权限体系,单独用于保存微信小程序用户。小程序用户仅操作微信小程序,不登录若依后台。 - 新增
微信小程序后端接口鉴权体系
:新增过滤器,单独用于拦截微信小程序后端模块接口做鉴权。 - 新增
微信小程序后端模块
。
在根项目,新增了ruoyi-wxmini
module模块。在根pom.xml
文件内:
<modules>
标签内,会自动将新增模块纳入管理。增加内容如下。<modules> <module>ruoyi-wxmini</module> </modules>
<dependencies>
标签内,手动添加新增的模块。增加内容如下。<dependency> <groupId>com.ruoyi</groupId> <artifactId>ruoyi-wxmini</artifactId> <version>${ruoyi.version}</version> </dependency>
在ruoyi-admin
模块的pom.xml
中,<dependencies>
依赖中手动增加了ruoyi-wxmini
模块依赖,使得ruoyi-wxmini
模块中的controller
控制器被加载和url生效。增加内容如下。
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-wxmini</artifactId>
</dependency>
修改了过滤器配置,修改com.ruoyi.framework.config.SecurityConfig
对象的filterChain
方法,追加匹配规则,对自定义的微信小程序接口url不做登录等鉴权。该部分接口鉴权将交由ruoyi-wxmini
模块定义的过滤器处理。增加内容如下。
.antMatchers("/wxmini/**").permitAll()
使用了若依自带的代码生成工具,自动生成业务层代码,并放置在ruoyi-system
模块中,对应com.ruoyi.wxmini
包。
新增微信用户表,执行sql\wx_user.sql
建表。
在ruoyi-admin
模块里的application.yml
配置文件,增加了微信对接配置,示例如下。
wx:
miniapp:
configs:
- appid: test #微信小程序的appid
secret: test #微信小程序的Secret
token: #微信小程序消息服务器配置的token
aesKey: #微信小程序消息服务器配置的EncodingAESKey
msgDataFormat: JSON
# 支付配置
pay:
appId: test #微信小程序的appid
mchId: 110 #商户id
apiV3Key: test #V3密钥
# https://pay.weixin.qq.com/doc/v3/merchant/4012365345
# openssl x509 -in apiclient_cert.pem -noout -serial
certSerialNo: test
privateKeyPath: classpath:cert/apiclient_key.pem #apiclient_key.pem证书文件的绝对路径或者以classpath:开头的类路径
privateCertPath: classpath:cert/apiclient_cert.pem #apiclient_cert.pem证书文件的绝对路径或者以classpath:开头的类路径
在ruoyi-admin
模块的resources
资源文件目录下,增加cert
目录,放置支付用的证书。
TODO