后端架构概览
技术栈
| 技术 | 版本 | 说明 |
|---|---|---|
| Spring Boot | 2.x | 应用框架 |
| MyBatis Plus | - | ORM 框架,支持自动下划线转驼峰 |
| MyBatis Plus Join | - | 多表联查扩展 |
| Spring Security | - | 安全框架(JWT Token 认证) |
| Redis | 6.x | 缓存与会话管理 |
| MySQL | 8.x | 主数据库 |
| RocketMQ / Kafka | - | 消息队列 |
| Flowable | - | 工作流引擎 |
| Knife4j / SpringDoc | - | API 文档(Swagger 增强) |
| Easy Trans | - | 数据翻译(VO 字段自动翻译) |
项目模块结构
后端采用多模块架构,基于若依(RuoYi)框架扩展:
ruoyi-live-mall-service-v2/
├── yudao-framework/ # 基础框架(安全、Web、MyBatis 等)
├── yudao-dependencies/ # 依赖版本管理(BOM)
├── yudao-server/ # 主启动模块(打包入口)
├── yudao-module-system/ # 系统管理(用户、角色、权限、字典)
├── yudao-module-infra/ # 基础设施(文件、代码生成、定时任务)
├── yudao-module-member/ # 会员模块(用户认证、会员信息)
├── yudao-module-mall/ # 商城模块(商品、订单、售后、物流)
│ ├── yudao-module-product-biz/ # 商品业务
│ ├── yudao-module-trade-biz/ # 交易业务
│ ├── yudao-module-trade-api/ # 交易 API 接口
│ ├── yudao-module-statistics-biz/ # 统计业务
│ └── ...
├── yudao-module-pay/ # 支付模块(钱包、支付订单)
├── yudao-module-live/ # 直播模块(腾讯直播集成)
├── yudao-module-museum/ # 博物馆模块
├── yudao-module-circle/ # 圈子/社区模块
├── yudao-module-website/ # 官网/资讯模块
├── yudao-module-bpm/ # 工作流模块(Flowable)
├── yudao-module-crm/ # CRM 模块
├── yudao-module-erp/ # ERP 模块
├── yudao-module-ai/ # AI 模块
├── yudao-module-iot/ # IoT 模块
├── yudao-module-school/ # 学校模块
├── yudao-module-amap/ # 高德地图模块
└── yudao-module-report/ # 报表模块
分层架构
每个业务模块遵循标准分层:
yudao-module-xxx/
├── yudao-module-xxx-api/ # API 层(对外暴露的接口定义、DTO)
└── yudao-module-xxx-biz/ # 业务层
├── controller/
│ ├── admin/ # 管理后台接口
│ └── app/ # 用户端接口(/app-api/ 前缀)
├── service/ # 业务逻辑层
├── dal/ # 数据访问层(Mapper + DataObject)
│ ├── dataobject/ # 数据对象(DO)
│ └── mysql/ # MyBatis Mapper 接口
├── convert/ # 对象转换器(MapStruct)
├── enums/ # 枚举常量
└── framework/ # 模块级框架配置
请求路径约定
| 前缀 | 用途 |
|---|---|
/admin-api/ | 管理后台接口,需要管理员权限 |
/app-api/ | 用户端接口,需要会员登录 |
前端请求拦截器会自动拼接 /app-api/ 前缀,因此前端 API 服务层中定义的 URL 不需要手动添加该前缀。
统一响应格式
所有接口返回 CommonResult<T> 包装:
{
"code": 0, // 0 表示成功,非 0 为错误码
"data": {}, // 业务数据
"msg": "" // 错误信息(code 非 0 时)
}
数据库配置
多数据源
支持主从数据源配置:
spring:
datasource:
dynamic:
datasource:
master:
url: jdbc:mysql://localhost:3306/ruoyi-vue-pro
username: root
password: 123456
slave:
url: jdbc:mysql://localhost:3306/ruoyi-vue-pro
username: root
password: 123456
MyBatis Plus 配置
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 开发环境打印 SQL
global-config:
db-config:
id-type: NONE # 自动适配(AUTO/INPUT)
logic-delete-value: 1
logic-not-delete-value: 0
文件上传限制
spring:
servlet:
multipart:
max-file-size: 250MB
max-request-size: 250MB
缓存策略
spring:
cache:
type: REDIS
redis:
time-to-live: 1h # 默认 1 小时过期
安全配置
免登录路径
以下路径配置为 permit-all,无需登录即可访问:
yudao:
security:
permit-all_urls:
- /app-api/member/**
- /app-api/promotion/**
- /app-api/product/**
- /app-api/txlive/**
- /app-api/txvod/**
- /app-api/museum/**
- /app-api/circle/**
- /admin-api/pay/notify/**
验证码配置
aj:
captcha:
type: blockPuzzle # 滑块拼图验证码
cache-type: redis
water-mark: 久滴科技(北京)有限公司
req-get-lock-limit: 5 # 失败 5 次锁定
req-get-lock-seconds: 10 # 锁定 10 秒
交易配置
yudao:
trade:
order:
pay-expire-time: 24h # 支付超时 24 小时
receive-expire-time: 14d # 自动确认收货 14 天
comment-expire-time: 7d # 评价超时 7 天
express:
client: ali_kdi # 物流查询使用阿里云快递 API
WebSocket 配置
yudao:
websocket:
enable: true
path: /infra/ws
sender-type: local # 可选 local、redis、rocketmq、kafka、rabbitmq
服务端口
| 服务 | 端口 |
|---|---|
| 后端 API | 48080 |
| 管理后台前端 | 8080 |
| MySQL | 3306 |
| Redis | 6379 |
sidebar_position: 1 title: ��˼ܹ�����
��˼ܹ�����
���ĵ����ڽ����У������ڴ���