表功能增加

This commit is contained in:
2025-10-15 10:39:51 +08:00
parent 9244275a51
commit 88976d7c47
16 changed files with 2815 additions and 0 deletions

View File

@@ -0,0 +1,290 @@
# 校园思政新闻平台 - ER关系图
## 核心模块关系图
```mermaid
erDiagram
%% 用户体系
tb_sys_user ||--|| tb_sys_user_info : "1对1"
tb_sys_user ||--o{ tb_sys_login_log : "1对多"
tb_sys_user ||--o{ tb_sys_user_dept_role : "1对多"
%% 权限体系
tb_sys_dept ||--o{ tb_sys_dept : "父子关系"
tb_sys_dept ||--o{ tb_sys_dept_role : "1对多"
tb_sys_role ||--o{ tb_sys_dept_role : "1对多"
tb_sys_role ||--o{ tb_sys_user_dept_role : "1对多"
tb_sys_role ||--o{ tb_sys_role_permission : "1对多"
tb_sys_permission ||--o{ tb_sys_role_permission : "1对多"
tb_sys_permission ||--o{ tb_sys_menu_permission : "1对多"
tb_sys_menu ||--o{ tb_sys_menu : "父子关系"
tb_sys_menu ||--o{ tb_sys_menu_permission : "1对多"
%% 资源体系
tb_resource_category ||--o{ tb_resource_category : "父子关系"
tb_resource_category ||--o{ tb_resource : "1对多"
tb_resource ||--o{ tb_resource_tag : "1对多"
tb_resource ||--o| tb_resource_recommend : "1对1"
tb_resource ||--o| tb_banner : "1对1"
tb_tag ||--o{ tb_resource_tag : "1对多"
%% 课程体系
tb_course ||--o{ tb_course_chapter : "1对多"
tb_course ||--o{ tb_course_tag : "1对多"
tb_course ||--o{ tb_course_dept : "1对多"
tb_tag ||--o{ tb_course_tag : "1对多"
tb_sys_dept ||--o{ tb_course_dept : "1对多"
%% 学习体系
tb_learning_task ||--o{ tb_task_resource : "1对多"
tb_learning_task ||--o{ tb_task_course : "1对多"
tb_learning_task ||--o{ tb_task_user : "1对多"
tb_resource ||--o{ tb_task_resource : "1对多"
tb_course ||--o{ tb_task_course : "1对多"
tb_sys_user ||--o{ tb_task_user : "1对多"
tb_sys_user ||--o{ tb_learning_record : "1对多"
tb_sys_user ||--o{ tb_learning_statistics : "1对多"
%% 个人中心
tb_sys_user ||--o{ tb_user_collection : "1对多"
tb_sys_user ||--|| tb_user_points : "1对1"
tb_sys_user ||--o{ tb_points_record : "1对多"
tb_sys_user ||--o{ tb_user_achievement : "1对多"
tb_sys_user ||--o{ tb_user_browse_record : "1对多"
tb_achievement ||--o{ tb_user_achievement : "1对多"
%% 智能体
tb_sys_user ||--o{ tb_ai_conversation : "1对多"
tb_sys_user ||--o{ tb_ai_upload_file : "1对多"
tb_sys_user ||--o{ tb_ai_usage_statistics : "1对多"
tb_ai_conversation ||--o{ tb_ai_message : "1对多"
%% 系统
tb_sys_user ||--o{ tb_sys_operation_log : "1对多"
tb_sys_user ||--o{ tb_sys_notification : "1对多"
```
## 用户权限体系详细关系
```mermaid
graph TB
User[用户 tb_sys_user]
UserInfo[用户信息 tb_sys_user_info]
UDR[用户部门角色 tb_sys_user_dept_role]
Dept[部门 tb_sys_dept]
Role[角色 tb_sys_role]
RolePerm[角色权限 tb_sys_role_permission]
Perm[权限 tb_sys_permission]
MenuPerm[菜单权限 tb_sys_menu_permission]
Menu[菜单 tb_sys_menu]
User -->|1:1| UserInfo
User -->|1:N| UDR
Dept -->|1:N| UDR
Role -->|1:N| UDR
Role -->|1:N| RolePerm
Perm -->|1:N| RolePerm
Perm -->|1:N| MenuPerm
Menu -->|1:N| MenuPerm
style User fill:#e1f5ff
style Role fill:#fff4e1
style Perm fill:#ffe1f5
style Menu fill:#e1ffe1
```
## 资源课程学习体系
```mermaid
graph TB
Resource[资源 tb_resource]
Course[课程 tb_course]
Chapter[章节 tb_course_chapter]
Category[分类 tb_resource_category]
Tag[标签 tb_tag]
Task[学习任务 tb_learning_task]
TaskUser[任务用户 tb_task_user]
User[用户 tb_sys_user]
Record[学习记录 tb_learning_record]
Category -->|1:N| Resource
Resource -->|M:N| Tag
Course -->|M:N| Tag
Course -->|1:N| Chapter
Task -->|M:N| Resource
Task -->|M:N| Course
Task -->|M:N| User
Task --> TaskUser
User -->|1:N| Record
Resource -.->|记录| Record
Course -.->|记录| Record
style Resource fill:#e1f5ff
style Course fill:#ffe1f5
style Task fill:#fff4e1
style User fill:#e1ffe1
```
## 智能体对话体系
```mermaid
graph TB
User[用户 tb_sys_user]
Config[AI配置 tb_ai_agent_config]
Knowledge[知识库 tb_ai_knowledge]
Conversation[对话会话 tb_ai_conversation]
Message[对话消息 tb_ai_message]
File[上传文件 tb_ai_upload_file]
Stats[使用统计 tb_ai_usage_statistics]
User -->|1:N| Conversation
User -->|1:N| File
User -->|1:N| Stats
Conversation -->|1:N| Message
File -.->|关联| Message
Knowledge -.->|引用| Message
Config -.->|配置| Message
style User fill:#e1f5ff
style Conversation fill:#ffe1f5
style Knowledge fill:#fff4e1
style Config fill:#e1ffe1
```
## 个人中心体系
```mermaid
graph TB
User[用户 tb_sys_user]
Collection[收藏 tb_user_collection]
Points[积分 tb_user_points]
PointsRecord[积分记录 tb_points_record]
Achievement[成就 tb_achievement]
UserAchievement[用户成就 tb_user_achievement]
Browse[浏览记录 tb_user_browse_record]
Resource[资源]
Course[课程]
User -->|1:N| Collection
User -->|1:1| Points
User -->|1:N| PointsRecord
User -->|1:N| UserAchievement
User -->|1:N| Browse
Achievement -->|1:N| UserAchievement
Resource -.->|收藏| Collection
Course -.->|收藏| Collection
Resource -.->|浏览| Browse
Course -.->|浏览| Browse
style User fill:#e1f5ff
style Points fill:#ffe1f5
style Achievement fill:#fff4e1
```
## 表关系类型说明
### 1对1关系 (1:1)
- `tb_sys_user``tb_sys_user_info`: 用户与用户信息
- `tb_sys_user``tb_user_points`: 用户与积分
- `tb_resource``tb_resource_recommend`: 资源与推荐(可选)
- `tb_resource``tb_banner`: 资源与Banner可选
### 1对多关系 (1:N)
- `tb_sys_user``tb_sys_login_log`: 用户的登录记录
- `tb_sys_dept``tb_sys_dept`: 部门的子部门
- `tb_resource_category``tb_resource`: 分类下的资源
- `tb_course``tb_course_chapter`: 课程的章节
- `tb_ai_conversation``tb_ai_message`: 会话的消息
### 多对多关系 (M:N)
- `tb_sys_user``tb_sys_role`: 通过 `tb_sys_user_dept_role`
- `tb_sys_role``tb_sys_permission`: 通过 `tb_sys_role_permission`
- `tb_resource``tb_tag`: 通过 `tb_resource_tag`
- `tb_course``tb_tag`: 通过 `tb_course_tag`
- `tb_learning_task``tb_resource`: 通过 `tb_task_resource`
- `tb_learning_task``tb_course`: 通过 `tb_task_course`
- `tb_learning_task``tb_sys_user`: 通过 `tb_task_user`
- `tb_sys_user``tb_achievement`: 通过 `tb_user_achievement`
## 核心业务流程关系
### 用户学习流程
1. 用户登录 → `tb_sys_user` + `tb_sys_login_log`
2. 查看任务 → `tb_learning_task` + `tb_task_user`
3. 学习资源 → `tb_resource` / `tb_course`
4. 记录学习 → `tb_learning_record`
5. 更新进度 → `tb_task_user` + `tb_learning_statistics`
6. 获得积分 → `tb_user_points` + `tb_points_record`
7. 解锁成就 → `tb_user_achievement`
### 资源管理流程
1. 数据采集 → `tb_data_collection_config` + `tb_data_collection_log`
2. 创建资源 → `tb_resource`
3. 设置分类 → `tb_resource_category`
4. 添加标签 → `tb_tag` + `tb_resource_tag`
5. 推荐资源 → `tb_resource_recommend`
6. 设置Banner → `tb_banner`
7. 记录操作 → `tb_sys_operation_log`
### 智能体交互流程
1. 创建会话 → `tb_ai_conversation`
2. 发送消息 → `tb_ai_message`
3. 上传文件 → `tb_ai_upload_file`
4. 检索知识库 → `tb_ai_knowledge`
5. 生成回复 → `tb_ai_message`
6. 记录统计 → `tb_ai_usage_statistics`
## 数据流向图
```mermaid
flowchart LR
A[用户操作] --> B{操作类型}
B -->|学习| C[学习记录]
B -->|浏览| D[浏览记录]
B -->|收藏| E[收藏记录]
B -->|对话| F[对话记录]
C --> G[学习统计]
D --> H[访问统计]
C --> I[积分系统]
I --> J[成就系统]
F --> K[AI统计]
G --> L[数据大屏]
H --> L
K --> L
style A fill:#e1f5ff
style L fill:#ffe1e1
```
## 性能优化关键点
1. **高频查询表**
- `tb_sys_user`: 用户信息(添加缓存)
- `tb_resource`: 资源列表(分页+缓存)
- `tb_course`: 课程列表(分页+缓存)
2. **大数据量表**
- `tb_learning_record`: 学习记录(分表+归档)
- `tb_sys_operation_log`: 操作日志(分表+归档)
- `tb_user_browse_record`: 浏览记录(分表+归档)
- `tb_ai_message`: 对话消息(分表+归档)
3. **实时统计表**
- `tb_learning_statistics`: 预聚合统计
- `tb_sys_visit_statistics`: 预聚合统计
- `tb_ai_usage_statistics`: 预聚合统计
4. **关联查询优化**
- 用户权限查询:缓存权限信息
- 任务详情查询:适当冗余字段
- 资源推荐查询:使用物化视图