- 新增发起申请节点 - 发起表单改挂该节点 - 首次发起跳过发起人 - 驳回目标包含发起人 - 审批接口新增表单数据入参 - 新增表单数据更新逻辑 - 模型模板加入发起人节点 - AI 与流程引擎默认值移入公共配置
289 lines
16 KiB
Markdown
289 lines
16 KiB
Markdown
<div align="center">
|
||
|
||
# <img alt="youlai-boot" height="32" valign="middle" src="./docs/images/logo/logo.png"> youlai-boot
|
||
|
||
**Spring Boot 企业级权限管理系统后端**
|
||
|
||
[](https://spring.io/projects/spring-boot)
|
||
[](https://openjdk.org/)
|
||
[](LICENSE)
|
||
[](https://gitee.com/youlaiorg/youlai-boot/stargazers)
|
||
[](https://github.com/youlaitech/youlai-boot)
|
||
[](https://gitcode.com/youlai/youlai-boot/stargazers)
|
||
|
||
</div>
|
||
|
||
<p align="center"><img src="./docs/images/rainbow.png" alt="rainbow"></p>
|
||
|
||
<div align="center">
|
||
|
||
[](https://vue.youlai.tech)
|
||
[](https://app.youlai.tech)
|
||
[](https://www.youlai.tech/docs/server/spring-boot/)
|
||
[](./README.en.md)
|
||
|
||
</div>
|
||
|
||
## 项目简介
|
||
|
||
**youlai-boot** 是一套基于 Spring Boot 的企业级权限管理系统后端,配套前端 [vue3-element-admin](https://gitee.com/youlaiorg/vue3-element-admin) 和移动端 [youlai-app](https://gitee.com/youlaiorg/youlai-app),并提供 **7 种语言实现**(Java / Node.js / Go / Python / PHP / C# / Rust),共享同一套 API 规范与数据库结构。适用于企业中后台管理系统的学习参考与二次开发。
|
||
|
||
## 核心特性
|
||
|
||
- 🔐 **安全体系** — Spring Security + JWT/Redis Token 两种令牌格式、统一会话管理、令牌续期、多端互斥
|
||
|
||
- 🔑 **统一认证(可选,默认关闭)** — [OIDC 登录](../docs/youlai-boot/oidc/implementation.md),把登录交给外部认证中心,认证成功后关联本地用户并复用角色权限;不启用就不会加载相关组件
|
||
|
||
- 🛡️ **细粒度权限** — RBAC 五级:数据 → 菜单 → 按钮 → 接口 → 字段
|
||
|
||
- ⚡ **代码生成器** — 一键生成前后端 CRUD 代码
|
||
|
||
- 📦 **模块齐全** — 用户、角色、菜单、部门、字典、文件(OSS/RustFS/本地)、定时任务、消息中心、操作日志
|
||
|
||
- 🔀 **工作流** — Flowable 审批流:BPMN 在线设计、条件网关、角色审批、驳回回退
|
||
|
||
- 🌐 **多租户 SaaS** — 数据隔离 + 租户配置,独立 [youlai-boot-tenant](https://gitee.com/youlaiorg/youlai-boot-tenant) 版本
|
||
|
||
- 🔌 **实时通信** — [WebSocket 接入](../docs/youlai-boot/realtime.md):一次性票据鉴权、节点在线人数、字典同步、通知提示
|
||
|
||
## 系统预览
|
||
|
||
**PC 端**
|
||
|
||
<table align="center">
|
||
<tr>
|
||
<td><img alt="PC预览1" width="400" src="./docs/images/preview/pc-01.png"></td>
|
||
<td><img alt="PC预览2" width="400" src="./docs/images/preview/pc-02.png"></td>
|
||
</tr>
|
||
<tr>
|
||
<td><img alt="PC预览3" width="400" src="./docs/images/preview/pc-03.png"></td>
|
||
<td><img alt="PC预览4" width="400" src="./docs/images/preview/pc-04.png"></td>
|
||
</tr>
|
||
<tr>
|
||
<td><img alt="PC预览5" width="400" src="./docs/images/preview/pc-05.png"></td>
|
||
<td><img alt="PC预览6" width="400" src="./docs/images/preview/pc-06.png"></td>
|
||
</tr>
|
||
</table>
|
||
|
||
**移动端**
|
||
|
||
<table align="center">
|
||
<tr>
|
||
<td><img alt="APP预览1" width="200" src="./docs/images/preview/app-01.png"></td>
|
||
<td><img alt="APP预览2" width="200" src="./docs/images/preview/app-02.png"></td>
|
||
<td><img alt="APP预览3" width="200" src="./docs/images/preview/app-03.png"></td>
|
||
<td><img alt="APP预览4" width="200" src="./docs/images/preview/app-04.png"></td>
|
||
</tr>
|
||
</table>
|
||
|
||
## 快速开始
|
||
|
||
**环境要求**:JDK 17+ · MySQL 8.0+ · Redis 6.0+
|
||
|
||
1. 克隆项目:
|
||
|
||
```bash
|
||
git clone https://gitee.com/youlaiorg/youlai-boot.git
|
||
```
|
||
|
||
2. 导入数据库:
|
||
|
||
```bash
|
||
# 基础库(必装)
|
||
sql/youlai-admin.sql
|
||
|
||
# 可选扩展:不装不影响基础功能,需在基础库之后执行
|
||
sql/extensions/dynamic-form.sql # 动态表单
|
||
sql/extensions/workflow.sql # 工作流(Flowable 演示流程与演示账号,非引擎表)
|
||
sql/extensions/oidc.sql # 统一认证:应用中心菜单与演示身份关联
|
||
```
|
||
|
||
> 扩展脚本全部**可选**。用户、角色、菜单、字典、日志、代码生成等基础能力都在 `sql/youlai-admin.sql` 里,只导入基础库就能把系统跑起来。
|
||
>
|
||
> `oidc.sql` 面向已有认证中心的场景,只写入「应用中心」菜单和一条演示身份关联。后端通过 `security.oidc.enabled` 控制 OIDC,默认关闭;开启时必须填写认证中心、客户端 ID、客户端密钥和前端回跳地址。前端登录入口通过 `VITE_OIDC_ENABLED` 单独控制。暂时没有单点登录需求,跳过即可。
|
||
|
||
3. 检查开发配置,按实际环境填写 MySQL、Redis 连接信息:
|
||
|
||
```bash
|
||
src/main/resources/application-dev.yml
|
||
```
|
||
|
||
配置按「基础服务 → 安全与访问 → 文件与接口 → 可选扩展」排列。首次运行先看前半部分;邮件、短信、小程序、定时任务、OIDC、AI、工作流集中在后半部分,按需接入。`---` 分隔的各组都属于同一个环境,会一起加载。
|
||
|
||
`application.yml` 维护公共规则,`application-dev.yml` 和 `application-prod.yml` 只展开常用参数与接入信息。验证码外观、登录期限、连接池等沿用默认值,需要调整时再添加对应属性,IDE 可提示配置说明与默认值。文件上传的存储方式与凭据在 `storage` 段配置。
|
||
|
||
可选服务中的 `""` 表示尚未接入,使用时填写自己的凭据;没有相关需求可以跳过。邮件默认使用端口 587、SMTP 认证和 STARTTLS,其他邮件服务按需覆盖。微信认证源默认 `wechat-mini-main`,首次接入无需填写 `provider`;更换 AppID 时需改用新的 `wx.miniapp.provider`,避免复用已有身份关联。
|
||
|
||
本地接入可以直接填写 YAML,生产部署也可用外部配置文件或 Spring Boot 原生环境变量覆盖,例如 `WX_MINIAPP_APPID`、`SECURITY_OIDC_ENABLED`。无需在 YAML 中重复声明 `${变量名:默认值}`;[变量名转换规则](https://docs.spring.io/spring-boot/reference/features/external-config.html#features.external-config.typesafe-configuration-properties.relaxed-binding.environment-variables)为点改下划线、去掉连字符、转大写。实际密钥不要提交到版本库。
|
||
|
||
上传大小在 `spring.servlet.multipart` 中配置,单文件和整个请求默认均为 50MB。升级时请把原 `storage.upload.max-file-size` 的自定义值分别迁移到 `max-file-size` 和 `max-request-size`。
|
||
|
||
生产环境的 SQL 日志通过 SLF4J 接入 Logback。排查 SQL 时可临时将对应 Mapper 包的日志级别设为 `DEBUG`,默认 `INFO` 不输出 SQL 调试日志。
|
||
|
||
4. 启动服务:
|
||
|
||
**方式一:IDEA 启动(推荐)**
|
||
用 IDEA 打开项目,等待 Maven 依赖下载完成,运行启动类 `YouLaiBootApplication` 即可。
|
||
|
||
**方式二:命令行启动**
|
||
|
||
```bash
|
||
mvn spring-boot:run
|
||
```
|
||
|
||
启动后访问 <http://localhost:8000/swagger-ui.html>,能打开接口文档即说明后端已正常运行。
|
||
|
||
5. 启动前端(可选):
|
||
如需可视化操作界面,启动配套前端 [vue3-element-admin](https://gitee.com/youlaiorg/vue3-element-admin),访问 <http://localhost:3000>,使用 `admin` / `123456` 登录。
|
||
|
||
> 更多内容详见官方文档:[快速开始](https://www.youlai.tech/docs/server/spring-boot/quick-start.html) · [部署指南](https://www.youlai.tech/docs/server/spring-boot/deploy.html)
|
||
|
||
|
||
## 目录结构
|
||
|
||
```
|
||
youlai-boot/
|
||
├── docs/ # 项目文档与图片资源
|
||
├── sql/ # 数据库初始化脚本
|
||
├── src/ # 源码目录
|
||
│ ├── auth/ # 认证模块
|
||
│ │ ├── password/ # 账号密码登录(含图形验证码)
|
||
│ │ ├── sms/ # 短信验证码登录
|
||
│ │ ├── qrcode/ # 扫码登录
|
||
│ │ ├── wxma/ # 微信小程序登录
|
||
│ │ └── session/ # 登录态管理(登出 / 刷新令牌)
|
||
│ ├── codegen/ # 代码生成器
|
||
│ ├── common/ # 公共模块(常量/枚举/异常/统一响应/工具类)
|
||
│ ├── config/ # 配置类(Security/Redis/MyBatis/接口文档/跨域/定时任务等)
|
||
│ ├── framework/ # 基础设施层
|
||
│ │ ├── mybatis/ # MyBatis-Plus 配置
|
||
│ │ ├── security/ # Spring Security
|
||
│ │ │ ├── config/ # 安全配置与配置属性
|
||
│ │ │ ├── filter/ # Token 认证过滤器
|
||
│ │ │ ├── handler/ # 认证 / 授权失败处理器
|
||
│ │ │ ├── model/ # 安全模型(SecurityUser / 令牌 / 数据范围)
|
||
│ │ │ ├── port/ # 认证与权限端口(由 system 提供实现)
|
||
│ │ │ ├── service/ # 用户详情与权限服务
|
||
│ │ │ ├── token/ # Token 管理(JWT / Redis 双模式)
|
||
│ │ │ └── util/ # 安全工具类
|
||
│ │ └── web/ # Web 层(全局异常/跨域/限流)
|
||
│ ├── module/ # 业务扩展模块
|
||
│ │ ├── form/ # 动态表单
|
||
│ │ └── workflow/ # 工作流
|
||
│ ├── support/ # 能力服务
|
||
│ │ ├── ai/ # AI 对话(代码生成/动态表单/工作流辅助,默认关闭)
|
||
│ │ ├── file/ # 文件存储(RustFS/阿里云OSS/本地)
|
||
│ │ ├── mail/ # 邮件服务
|
||
│ │ ├── sms/ # 短信服务
|
||
│ │ └── realtime/ # WebSocket 实时通信
|
||
│ └── system/ # 系统业务(用户/角色/菜单/部门/字典等)
|
||
├── docker-compose.yml # 中间件一键编排(MySQL/Redis/RustFS/Xxl-Job)
|
||
└── pom.xml # Maven 依赖管理
|
||
```
|
||
|
||
## 生态矩阵
|
||
|
||
**前端**
|
||
|
||
| 项目 | 技术栈 | 说明 | 更新状态 |
|
||
| :------------------------------------------------------------------- | :------------------- | :---------- | :--- |
|
||
| [vue3-element-admin](https://gitee.com/youlaiorg/vue3-element-admin) | Vue 3 + Element Plus | PC 管理前端(主推) | ✅️ |
|
||
| [youlai-app](https://gitee.com/youlaiorg/youlai-app) | Vue 3 + UniApp | 移动端 App | ✅️ |
|
||
|
||
**后端**
|
||
|
||
| 项目 | 技术栈 | 说明 | 更新状态 |
|
||
| :----------------------------------------------------------- | :------------------------- | :------- | :--- |
|
||
| [youlai-boot](https://gitee.com/youlaiorg/youlai-boot) | Spring Boot + MyBatis-Plus | Java(主推) | ✅️ |
|
||
| [youlai-nest](https://gitee.com/youlaiorg/youlai-nest) | NestJS + TypeORM | Node.js | ✅️ |
|
||
| [youlai-gin](https://gitee.com/youlaiorg/youlai-gin) | Go + Gorm | Go | ✅️ |
|
||
| [youlai-django](https://gitee.com/youlaiorg/youlai-django) | Django + DRF | Python | ✅️ |
|
||
| [youlai-fastapi](https://gitee.com/youlaiorg/youlai-fastapi) | FastAPI + SQLAlchemy | Python | ✅️ |
|
||
| [youlai-think](https://gitee.com/youlaiorg/youlai-think) | ThinkPHP + ThinkORM | PHP | ✅️ |
|
||
| [youlai-aspnet](https://gitee.com/youlaiorg/youlai-aspnet) | ASP.NET Core + EF Core | C# | ✅️ |
|
||
| [youlai-axum](https://gitee.com/youlaiorg/youlai-axum) | Axum + SeaORM | Rust | ✅️ |
|
||
| [youlai-laravel](https://gitee.com/youlaiorg/youlai-laravel) | Laravel + Eloquent | PHP | ❌️ |
|
||
|
||
> 九种后端共享同一套 **RESTful API 规范** 和 **数据库结构**,前端可无缝切换。
|
||
|
||
**衍生版本**
|
||
|
||
| 项目 | 基于 | 类型 | 说明 | 更新状态 |
|
||
| :---------------------------------------------------------------------------------------- | :---------- | :--- | :----------------- | :--- |
|
||
| [youlai-boot-tenant](https://gitee.com/youlaiorg/youlai-boot-tenant) | youlai-boot | 独立仓库 | 多租户 SaaS,租户隔离与租户配置 | ✅️ |
|
||
| [youlai-boot-flex](https://gitee.com/youlaiorg/youlai-boot-flex) | youlai-boot | 独立仓库 | 改用 MyBatis-Flex | ✅️ |
|
||
| [youlai-boot (db-pg)](https://gitee.com/youlaiorg/youlai-boot/tree/db-pg) | youlai-boot | 分支 | PostgreSQL 数据库分支 | ✅️ |
|
||
| [youlai-boot (multi-module)](https://gitee.com/youlaiorg/youlai-boot/tree/multi-module) | youlai-boot | 分支 | 多模块工程拆分 | ✅️ |
|
||
| [youlai-nest (multi-tenant)](https://gitee.com/youlaiorg/youlai-nest/tree/multi-tenant) | youlai-nest | 分支 | 多租户 SaaS,租户隔离与租户配置 | ✅️ |
|
||
| [youlai-boot (spring-boot-3)](https://gitee.com/youlaiorg/youlai-boot/tree/spring-boot-3) | youlai-boot | 分支 | Spring Boot 3 兼容分支 | ❌️ |
|
||
|
||
## 可选扩展
|
||
|
||
以下功能默认关闭,需要时再开启。
|
||
|
||
**AI 辅助**:在当前环境配置中填写密钥,并加上 `spring.ai.model.chat: openai`。
|
||
|
||
```yaml
|
||
spring:
|
||
ai:
|
||
model:
|
||
chat: openai
|
||
openai:
|
||
base-url: https://dashscope.aliyuncs.com/compatible-mode/v1
|
||
api-key: ""
|
||
chat:
|
||
model: qwen3.7-flash
|
||
temperature: 0.3
|
||
extra-body:
|
||
"[enable_thinking]": false
|
||
```
|
||
|
||
**工作流**:先执行扩展脚本导入菜单、演示角色与发起表单(不含 `ACT_*` 引擎表),再在环境配置中打开开关。
|
||
|
||
```bash
|
||
sql/extensions/workflow.sql
|
||
```
|
||
|
||
```yaml
|
||
flowable:
|
||
process:
|
||
enabled: true # 唯一开关,同时控制业务模块和引擎
|
||
idm:
|
||
enabled: false
|
||
eventregistry:
|
||
enabled: false
|
||
```
|
||
|
||
开发环境启动时自动建表,生产需先建表;演示流程在「流程模型」页点「重置工作流数据」后生成。
|
||
|
||
**统一认证**:经 Nginx 接入时,取消环境配置 `server` 块中 `forward-headers-strategy: framework` 的注释,并让代理覆盖客户端的 `Forwarded` / `X-Forwarded-*`。
|
||
|
||
**多租户**:见 [youlai-boot-tenant](https://gitee.com/youlaiorg/youlai-boot-tenant)。
|
||
|
||
## 技术合作
|
||
|
||
本项目采用 [Apache License 2.0](LICENSE) 开源,可免费商用。欢迎在 [Issue](https://gitee.com/youlaiorg/youlai-boot/issues) 提交问题或反馈,也欢迎提交 [Pull Request](https://gitee.com/youlaiorg/youlai-boot/pulls) 共建。
|
||
|
||
如需技术支持、商务合作、二次开发、项目定制或私有化部署,可联系作者微信(见下方二维码)。
|
||
|
||
<table align="center">
|
||
<tr>
|
||
<td align="center">
|
||
<img src="./docs/images/qrcode/wechat-official.jpg" height="180" alt="公众号「有来技术」"><br>
|
||
<sub>公众号「有来技术」</sub>
|
||
</td>
|
||
<td> </td>
|
||
<td align="center">
|
||
<img src="./docs/images/qrcode/wechat-mp.jpg" height="180" alt="小程序「有来技术」"><br>
|
||
<sub>小程序「有来技术」</sub>
|
||
</td>
|
||
<td> </td>
|
||
<td align="center">
|
||
<img src="./docs/images/qrcode/wechat-personal.png" height="180" alt="添加作者微信"><br>
|
||
<sub>添加作者微信</sub>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
|
||
<p align="center"><em>技术交流 · 问题反馈 · 商务合作</em></p>
|