You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
erDiagram
USER ||--o{ TOOL : uploads
USER ||--o{ FORUM_POST : authors
USER ||--o{ FORUM_COMMENT : authors
USER ||--o{ TOOL_LIKE : likes
USER ||--o{ FORUM_LIKE : likes
USER ||--o{ POST_FAVORITE : favorites
USER ||--o{ VIDEO : uploads
USER ||--o{ VIDEO_LIKE : likes
USER ||--o{ VIDEO_FAVORITE : favorites
USER ||--o{ NOTIFICATION : receives
USER ||--o{ FEEDBACK_MESSAGE : submits
CATEGORY ||--o{ TOOL : classifies
TOOL ||--o{ TOOL_FILE : has
TOOL ||--o{ TOOL_LIKE : has
TOOL ||--o{ TOOL_COMMENT : has
TOOL ||--o{ TOOL_TAG : tagged
TAG ||--o{ TOOL_TAG : tags
TAG ||--o{ VIDEO_TAG : tags
TAG ||--o{ FORUM_POST_TAG : tags
FORUM_CATEGORY ||--o{ FORUM_POST : categorizes
FORUM_POST ||--o{ FORUM_POST_TAG : tagged
FORUM_TAG ||--o{ FORUM_POST_TAG : tags
FORUM_POST ||--o{ FORUM_COMMENT : comments
FORUM_POST ||--o{ FORUM_LIKE : likes
FORUM_POST ||--o{ POST_FAVORITE : favorites
FORUM_COMMENT ||--o{ FORUM_COMMENT : replies
VIDEO ||--o{ VIDEO_COMMENT : comments
VIDEO ||--o{ VIDEO_LIKE : likes
VIDEO ||--o{ VIDEO_FAVORITE : favorites
VIDEO ||--o{ DANMAKU : has
KNOWLEDGE_BASE ||--o{ KB_DOCUMENT : contains
USER { int id PK, string email UK, string password, string username, string role, string accountStatus, string avatar }
TOOL { int id PK, string name, int categoryId FK, string content, int uploaderId FK, string version, string status, int viewCount, float score }
CATEGORY { int id PK, string name UK, string icon, int sortOrder }
TOOL_FILE { int id PK, int toolId FK, string filePath, string originalName, int fileSize, string contentType }
TAG { int id PK, string name, string tagType, int usageCount }
FORUM_POST { int id PK, string title, string content, int authorId FK, int categoryId FK, string status, int viewCount, float score }
FORUM_COMMENT { int id PK, int postId FK, int authorId, int parentId, int rootId, string content }
VIDEO { int id PK, string title, int uploaderId FK, string videoPath, string coverPath, string status, int viewCount }
DANMAKU { int id PK, int videoId FK, string content, int time, string color }
NOTIFICATION { int id PK, int userId FK, string type, string content, boolean read }
FEEDBACK_MESSAGE { int id PK, string content, string nickname, string category, int userId FK, string status, string adminReply }
KNOWLEDGE_BASE { int id PK, string name, string description }
KB_DOCUMENT { int id PK, int kbId FK, string title, string content }
Loading
5. API 设计
5.1 认证与用户
方法
路径
说明
认证
POST
/api/v1/auth/register
注册 (status=PENDING)
否
POST
/api/v1/auth/login
登录 → accessToken + refreshToken
否
POST
/api/v1/auth/refresh
刷新 Token
refreshToken
GET
/api/v1/auth/me
当前用户信息
是
GET/PUT
/api/v1/users/me
获取/更新个人信息
是
POST
/api/v1/users/me/avatar
上传头像
是
5.2 工具与文件
方法
路径
说明
认证
GET
/api/v1/tools
列表 (分页/搜索/分类)
否
GET
/api/v1/tools/{id}
详情 (viewCount++)
否
POST
/api/v1/tools
创建
USER+
PUT
/api/v1/tools/{id}
更新 (isOwner || isAdmin)
USER+
DELETE
/api/v1/tools/{id}
软删除
isOwner || isAdmin
POST
/api/v1/tools/{id}/like
点赞切换
USER+
GET
/api/v1/tools/my
我的工具
USER+
GET
/api/v1/tools/ranking
排行榜
否
POST
/api/v1/tools/{toolId}/files
上传文件
USER+
GET
/api/v1/tools/{toolId}/files
文件列表
否
DELETE
/api/v1/tools/{toolId}/files/{fileId}
删除文件
isOwner
GET
/api/v1/tools/{toolId}/files/{fileId}/download
下载
否
5.3 分类与概览
方法
路径
说明
GET
/api/v1/categories
工具分类列表
GET
/api/overview/stats
全局统计
GET
/api/overview/tool-ranking
工具排行
GET
/api/overview/post-ranking
帖子排行
5.4 论坛
方法
路径
说明
认证
GET
/api/forum/posts
帖子列表
否
GET
/api/forum/posts/{id}
帖子详情
否
POST
/api/forum/posts
创建帖子
USER+
PUT
/api/forum/posts/{id}
更新
isOwner
DELETE
/api/forum/posts/{id}
软删除
isOwner || isAdmin
GET
/api/forum/posts/{postId}/comments
评论列表
否
POST
/api/forum/posts/{postId}/comments
创建评论
否*
DELETE
/api/forum/comments/{id}
删除评论
isOwner || isAdmin
POST
/api/forum/likes
点赞切换
否*
GET
/api/forum/categories
分类列表
否
GET
/api/forum/tags
标签列表
否
GET/POST
/api/v1/post-favorites
收藏列表/切换
USER+
*评论和点赞支持匿名 (authorId/userId 可选)。
5.5 微课视频
方法
路径
说明
认证
GET
/api/v1/videos
视频列表
否
GET
/api/v1/videos/{id}
视频详情
否
POST
/api/v1/videos
上传 (multipart, max 1GB)
USER+
PUT
/api/v1/videos/{id}
更新
isOwner
DELETE
/api/v1/videos/{id}
软删除
isOwner || isAdmin
POST
/api/v1/videos/{id}/like
点赞切换
USER+
POST
/api/v1/videos/{id}/favorite
收藏切换
USER+
GET/POST
/api/v1/videos/{id}/comments
评论列表/创建
否/USER+
5.6 管理
方法
路径
说明
权限
GET
/api/v1/admin/pending-users
待审批用户
SUPER_ADMIN
POST
/api/v1/admin/users/{id}/approve
审批通过
SUPER_ADMIN
POST
/api/v1/admin/users/{id}/reject
审批拒绝
SUPER_ADMIN
GET
/api/v1/admin/users
全部用户列表
ADMIN+
PUT
/api/v1/admin/users/{id}/status
修改用户状态
ADMIN+
5.7 知识库
方法
路径
说明
认证
GET
/api/v1/knowledge
知识库列表 (分页/排序)
否
GET
/api/v1/knowledge/{id}
知识库详情
否
POST
/api/v1/knowledge
创建知识库
USER+
PUT
/api/v1/knowledge/{id}
更新知识库
isOwner
DELETE
/api/v1/knowledge/{id}
删除知识库
isOwner || isAdmin
POST
/api/v1/knowledge/{id}/search
语义搜索知识库内容
否
5.8 留言反馈
方法
路径
说明
认证
GET
/api/v1/feedback
留言列表 (分页/分类筛选)
否
POST
/api/v1/feedback
提交留言
否
PUT
/api/v1/feedback/{id}/reply
管理员回复
ADMIN+
DELETE
/api/v1/feedback/{id}
删除留言
ADMIN+
5.9 通知
方法
路径
说明
认证
GET
/api/v1/notifications
我的通知列表
USER+
GET
/api/v1/notifications/unread-count
未读通知计数
USER+
PUT
/api/v1/notifications/{id}/read
标记已读
USER+
PUT
/api/v1/notifications/read-all
全部标记已读
USER+
5.10 统一标签
方法
路径
说明
认证
GET
/api/v1/tags
标签列表 (按类型筛选)
否
GET
/api/v1/tags/hot
热门标签
否
POST
/api/v1/tags
创建标签
否
5.11 统一互动
方法
路径
说明
认证
POST
/api/v1/interactions/likes
切换点赞/取消
否*
GET
/api/v1/interactions/likes/status
点赞状态
否*
POST
/api/v1/interactions/comments
添加评论
否*
GET
/api/v1/interactions/comments
评论列表
否
DELETE
/api/v1/interactions/comments/{id}
删除评论
isOwner || isAdmin
POST
/api/v1/interactions/favorites
切换收藏
USER+
GET
/api/v1/interactions/favorites
我的收藏
USER+
GET
/api/v1/interactions/favorites/status
收藏状态
USER+
*点赞和评论支持匿名 (IP 哈希或无登录 userName)。
5.12 MCP (18 tools via Streamable HTTP/SSE)
Streamable HTTP 入口: POST /mcp | SSE 兼容入口: GET /sse | 消息: POST /mcp/message
sequenceDiagram
participant C as 客户端
participant F as JwtAuthFilter
participant U as UserService
C->>U: POST /api/v1/auth/login
U-->>C: accessToken(15min) + refreshToken(7天)
C->>F: GET /api/v1/tools (Bearer accessToken)
F->>F: validateToken + 加载 User
F-->>C: 200 OK
Note over C: accessToken 过期
C->>U: POST /api/v1/auth/refresh
U-->>C: 新 accessToken + 新 refreshToken
sequenceDiagram
participant C as 客户端
participant TS as ToolService
participant XSS as XssSanitizer
participant TR as ToolRepository
C->>TS: POST /api/v1/tools {name, categoryId, content}
TS->>XSS: sanitize(content)
TS->>TS: 校验名称唯一性 (同用户下)
TS->>TR: save(Tool{status=NORMAL, viewCount=0})
TR-->>C: 200 + ToolSummaryDTO
Loading
7.2 论坛帖子生命周期
sequenceDiagram
participant C as 客户端
participant FPS as ForumPostService
participant FPR as ForumPostRepository
participant FCR as ForumCommentRepository
C->>FPS: createPost(userId, {title, content, categoryId, tags})
FPS->>FPS: XSS sanitize + save Post + 关联 Tags
FPS-->>C: ForumPostDTO
C->>FPS: getPost(id) → viewCount++
C->>FCR: addComment(postId, {content, parentId?})
C->>FPS: toggleLike(postId) → likeCount +/-
C->>FPS: deletePost(id) → status=DELETED
Loading
7.3 用户注册与审批
sequenceDiagram
participant C as 客户端
participant US as UserService
participant SA as SUPER_ADMIN
C->>US: register({email, username, password})
US->>US: BCrypt + save User{status=PENDING}
SA->>US: approveUser(id) → status=APPROVED
C->>US: login({username, password}) → tokens (仅 APPROVED)
flowchart LR
Browser -->|"HTTP"| Vite["Vite :5173"]
Browser -->|"API"| Spring["Spring Boot :8082"]
MCPClient["MCP Client"] -->|"Streamable HTTP/SSE"| Spring
Vite -->|"proxy"| Spring
Spring -->|"JDBC"| MySQL["MySQL :3306"]
Spring -->|"I/O"| Files["~/.aifiles"]