Files
xuan-deduct/src/main/resources/application.properties
T
H1d3rOne caac642120 实现微信登录功能,首次使用自动保存用户信息
前端实现:
- 修改auth.vue登录逻辑
- 使用getUserProfile获取微信用户信息
- 获取用户昵称和头像URL
- 调用uni.login获取code
- 将code和用户信息发送到后端
- 登录成功后保存完整用户信息到本地

后端实现:
- 修改UserController登录接口
- 接收code参数而不是openId
- 调用微信API jscode2session获取openId
- 使用RestTemplate调用微信接口
- 支持配置微信appid和secret
- 首次登录自动创建用户并保存到数据库

配置文件:
- application.properties新增微信配置项
- wechat.appid: 微信小程序AppID
- wechat.secret: 微信小程序AppSecret

功能特点:
- 首次使用小程序自动获取微信用户信息
- 用户信息保存到user_info表
- 支持游客模式(未配置微信参数时)
- 完整的错误处理和日志记录
2026-03-09 00:10:45 +08:00

22 lines
724 B
Properties

server.port=8080
spring.application.name=xuan-utils-pro
# MySQL Database Configuration
spring.datasource.url=jdbc:mysql://localhost:3306/xuan_deduct?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=utf8&allowPublicKeyRetrieval=true
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.username=xuan_user
spring.datasource.password=xuan_password
# JPA Configuration
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
# Logging
logging.level.xuan=DEBUG
# WeChat Mini Program Configuration
wechat.appid=your_wechat_appid_here
wechat.secret=your_wechat_secret_here