前端项目初始化提交
This commit is contained in:
357
api接口文档.txt
Normal file
357
api接口文档.txt
Normal file
@@ -0,0 +1,357 @@
|
||||
文件管理系统 API 文档
|
||||
基础信息
|
||||
Base URL: http://localhost:8080/api
|
||||
认证方式: JWT Bearer Token
|
||||
Token Header: Authorization: Bearer {token}
|
||||
Swagger UI: http://localhost:8080/api/swagger-ui.html
|
||||
API Docs: http://localhost:8080/api/v3/api-docs
|
||||
|
||||
1. 认证管理 (/auth)
|
||||
1.1 用户登录
|
||||
POST /auth/login
|
||||
描述: 使用用户名和密码登录系统
|
||||
请求体:{
|
||||
"username": "string",
|
||||
"password": "string"
|
||||
}
|
||||
限流: 60秒内最多5次请求(基于IP)
|
||||
|
||||
1.2 用户登出
|
||||
POST /auth/logout
|
||||
Headers:
|
||||
Authorization: Bearer {token}
|
||||
|
||||
1.3 获取用户信息
|
||||
GET /auth/user/info
|
||||
Headers:
|
||||
Authorization: Bearer {token}
|
||||
|
||||
1.4 获取用户角色
|
||||
GET /auth/user/roles
|
||||
Headers:
|
||||
Authorization: Bearer {token}
|
||||
|
||||
1.5 获取主要角色
|
||||
GET /auth/user/main-role
|
||||
Headers:
|
||||
Authorization: Bearer {token}
|
||||
|
||||
2. 用户管理 (/user)
|
||||
2.1 分页查询用户
|
||||
GET /user/page
|
||||
Query Parameters:
|
||||
pageNum: 页码 (默认: 1)
|
||||
pageSize: 每页大小 (默认: 10)
|
||||
username: 用户名 (可选)
|
||||
deptId: 部门ID (可选)
|
||||
|
||||
2.2 查询用户详情
|
||||
GET /user/{id}
|
||||
Path Parameters:
|
||||
id: 用户ID
|
||||
|
||||
2.3 创建用户
|
||||
POST /user
|
||||
请求体:{
|
||||
"username": "newuser",
|
||||
"realName": "新用户",
|
||||
"email": "user@example.com",
|
||||
"phone": "13800138001",
|
||||
"deptId": 1,
|
||||
"userType": "普通用户",
|
||||
"status": 1
|
||||
}
|
||||
|
||||
2.4 更新用户
|
||||
PUT /user
|
||||
请求体:{
|
||||
"id": 1,
|
||||
"realName": "更新后的名字",
|
||||
"email": "newemail@example.com",
|
||||
"phone": "13800138002"
|
||||
}
|
||||
|
||||
2.5 删除用户
|
||||
DELETE /user/{id}
|
||||
Path Parameters:
|
||||
id: 用户ID
|
||||
|
||||
2.6 重置密码
|
||||
PUT /user/{id}/reset-password
|
||||
Path Parameters:
|
||||
id: 用户ID
|
||||
说明: 重置密码为默认密码 123456
|
||||
|
||||
2.7 更新用户状态
|
||||
PUT /user/{id}/status
|
||||
Path Parameters:
|
||||
id: 用户ID
|
||||
Query Parameters:
|
||||
status: 状态 (1:启用, 0:禁用)
|
||||
|
||||
2.8 分配用户角色
|
||||
PUT /user/{id}/roles
|
||||
Path Parameters:
|
||||
id: 用户ID
|
||||
请求体:[1, 2, 3]
|
||||
说明: 角色ID列表
|
||||
|
||||
3. 部门管理 (/department)3.1 查询部门列表
|
||||
GET /department
|
||||
|
||||
3.2 创建部门
|
||||
POST /department
|
||||
请求体:{
|
||||
"deptName": "新部门",
|
||||
"parentId": 1,
|
||||
"orderNum": 1
|
||||
}
|
||||
|
||||
3.3 更新部门
|
||||
PUT /department/{id}
|
||||
Path Parameters:
|
||||
id: 部门ID
|
||||
请求体:{
|
||||
"deptName": "更新后的部门名",
|
||||
"orderNum": 2
|
||||
}
|
||||
|
||||
3.4 删除部门
|
||||
DELETE /department/{id}
|
||||
Path Parameters:
|
||||
id: 部门ID
|
||||
|
||||
3.5 设置部门管理员
|
||||
PUT /department/{id}/manager
|
||||
Path Parameters:
|
||||
id: 部门ID
|
||||
Query Parameters:
|
||||
managerId: 管理员用户ID
|
||||
|
||||
3.6 查询部门用户
|
||||
GET /department/{id}/users
|
||||
Path Parameters:
|
||||
id: 部门ID
|
||||
|
||||
4. 角色管理 (/role)
|
||||
4.1 查询角色列表
|
||||
GET /role
|
||||
|
||||
4.2 创建角色
|
||||
POST /role
|
||||
请求体:{
|
||||
"roleName": "新角色",
|
||||
"roleCode": "NEW_ROLE",
|
||||
"description": "角色描述"
|
||||
}
|
||||
|
||||
4.3 更新角色
|
||||
PUT /role/{id}
|
||||
Path Parameters:
|
||||
id: 角色ID
|
||||
请求体:{
|
||||
"roleName": "更新后的角色名",
|
||||
"description": "更新后的描述"
|
||||
}
|
||||
|
||||
4.4 删除角色
|
||||
DELETE /role/{id}
|
||||
Path Parameters:
|
||||
id: 角色ID
|
||||
|
||||
4.5 分配权限
|
||||
PUT /role/{id}/permissions
|
||||
Path Parameters:
|
||||
id: 角色ID
|
||||
请求体:[1, 2, 3]
|
||||
说明: 权限ID列表
|
||||
|
||||
4.6 查询角色权限
|
||||
GET /role/{id}/permissions
|
||||
Path Parameters:
|
||||
id: 角色ID
|
||||
|
||||
5. 文件管理 (/file)
|
||||
5.1 分页查询文件
|
||||
GET /file/page
|
||||
Headers:
|
||||
Authorization: Bearer {token}
|
||||
Query Parameters:
|
||||
pageNum: 页码 (默认: 1)
|
||||
pageSize: 每页大小 (默认: 10)
|
||||
fileName: 文件名 (可选)
|
||||
deptId: 部门ID (可选)
|
||||
|
||||
5.2 查询文件详情
|
||||
GET /file/{id}
|
||||
Path Parameters:
|
||||
id: 文件ID
|
||||
|
||||
5.3 上传文件
|
||||
POST /file/upload
|
||||
Headers:
|
||||
Authorization: Bearer {token}
|
||||
Content-Type: multipart/form-data
|
||||
Form Data:
|
||||
file: 文件对象
|
||||
限制:
|
||||
文件大小: 最大 10MB
|
||||
允许格式: .doc, .docx, .pdf, .txt, .jpg, .jpeg, .png, .gif, .webp
|
||||
限流: 60秒内最多10次请求(基于用户)
|
||||
|
||||
5.4 RAG流式问答
|
||||
POST /file/rag/stream
|
||||
Headers:
|
||||
Authorization: Bearer {token}
|
||||
Accept: text/event-stream
|
||||
请求体:5.4 RAG流式问答
|
||||
POST /file/rag/stream
|
||||
Headers:
|
||||
Authorization: Bearer {token}
|
||||
Accept: text/event-stream
|
||||
|
||||
5.5 下载文件
|
||||
GET /file/download/{id}
|
||||
Path Parameters:
|
||||
id: 文件ID
|
||||
响应: 文件二进制流
|
||||
Headers:
|
||||
Content-Disposition: attachment; filename*=UTF-8''{filename}
|
||||
Content-Type: application/octet-stream
|
||||
|
||||
5.6 获取文件内容
|
||||
GET /file/content/{id}
|
||||
Path Parameters:
|
||||
id: 文件ID
|
||||
说明: 供后端服务使用,返回文件二进制内容
|
||||
|
||||
5.7 获取文件详细信息
|
||||
GET /file/info/{id}
|
||||
Path Parameters:
|
||||
id: 文件ID
|
||||
说明: 获取文件的所有信息包括内容,供后端服务使用
|
||||
|
||||
5.8 删除文件
|
||||
DELETE /file/{id}
|
||||
Path Parameters:
|
||||
id: 文件ID
|
||||
|
||||
6. 文件权限管理 (/file/permission)
|
||||
6.1 授权文件权限
|
||||
POST /file/permission
|
||||
Headers:
|
||||
Authorization: Bearer {token}
|
||||
请求体:{
|
||||
"fileId": 1,
|
||||
"targetUserId": 2,
|
||||
"permissionType": "read",
|
||||
"expireTime": "2024-12-31 23:59:59"
|
||||
}
|
||||
说明:
|
||||
permissionType: 权限类型 (read:只读, write:读写)
|
||||
expireTime: 过期时间 (可选)
|
||||
|
||||
6.2 撤销文件权限
|
||||
DELETE /file/permission/{id}
|
||||
Path Parameters:
|
||||
id: 权限ID
|
||||
|
||||
6.3 查询文件权限列表
|
||||
GET /file/permission/file/{fileId}
|
||||
Path Parameters:
|
||||
fileId: 文件ID
|
||||
Headers:
|
||||
Authorization: Bearer {token}
|
||||
|
||||
6.4 更新权限过期时间
|
||||
PUT /file/permission/{id}/expire
|
||||
Path Parameters:
|
||||
id: 权限ID
|
||||
请求体:{
|
||||
"expireTime": "2025-12-31 23:59:59"
|
||||
}
|
||||
|
||||
7. 日志管理 (/log)
|
||||
7.1 分页查询日志
|
||||
GET /log/page
|
||||
Query Parameters:
|
||||
pageNum: 页码 (默认: 1)
|
||||
pageSize: 每页大小 (默认: 10)
|
||||
username: 用户名 (可选)
|
||||
operationType: 操作类型 (可选)
|
||||
|
||||
|
||||
8. 第三方接口 (/third-party)
|
||||
8.1 接收JSON数据
|
||||
POST /third-party/json
|
||||
请求体:{
|
||||
"data": {
|
||||
"key1": "value1",
|
||||
"key2": "value2"
|
||||
},
|
||||
"fileName": "custom_file"
|
||||
}
|
||||
说明: 接收第三方系统的JSON数据并生成TXT文件
|
||||
|
||||
8.2 调用第三方接口
|
||||
POST /third-party/call
|
||||
Query Parameters:
|
||||
filePath: 文件路径
|
||||
userId: 用户ID
|
||||
说明: 根据文件路径和用户ID调用第三方接口并保存返回数据
|
||||
|
||||
通用响应格式
|
||||
所有接口均使用统一的响应格式:{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"data": {}
|
||||
}
|
||||
|
||||
|
||||
常见状态码:
|
||||
200: 成功
|
||||
400: 请求参数错误
|
||||
401: 未授权(Token无效或过期)
|
||||
403: 权限不足
|
||||
404: 资源不存在
|
||||
500: 服务器内部错误
|
||||
|
||||
环境变量配置
|
||||
变量名
|
||||
说明
|
||||
默认值
|
||||
DB_USERNAME
|
||||
数据库用户名
|
||||
root
|
||||
DB_PASSWORD
|
||||
数据库密码
|
||||
123456
|
||||
REDIS_HOST
|
||||
Redis主机
|
||||
localhost
|
||||
REDIS_PORT
|
||||
Redis端口
|
||||
6379
|
||||
REDIS_PASSWORD
|
||||
Redis密码
|
||||
(空)
|
||||
JWT_SECRET
|
||||
JWT密钥
|
||||
your-secret-key-for-jwt-token-generation-2024-change-in-production
|
||||
DIFY_API_URL
|
||||
Dify API地址
|
||||
http://172.20.10.2/v1/workflows/run
|
||||
DIFY_API_KEY
|
||||
Dify API密钥
|
||||
app-0iWrwSYdTczCmRmtVNhfjWnq
|
||||
X_KEY
|
||||
X-Key
|
||||
password123
|
||||
CORS_ALLOWED_ORIGINS
|
||||
CORS允许的源
|
||||
*
|
||||
SWAGGER_ENABLED
|
||||
是否启用Swagger
|
||||
true
|
||||
|
||||
这份API文档涵盖了系统中所有的接口,包括认证、用户管理、部门管理、角色管理、文件管理、文件权限管理、日志管理和第三方接口。你可以直接在浏览器中访问 Swagger UI (http://localhost:8080/api/swagger-ui.html) 进行在线测试和调试。
|
||||
Reference in New Issue
Block a user