本文档详细列出了系统的后端接口,包括请求地址、请求方式、参数说明及认证要求。 所有接口的前缀均为
/api。
- URL:
/api/auth/login - Method:
POST - Auth: 无需认证
- Body:
{ "username": "admin", "password": "password123" } - Response:
{ "code": 200, "message": "登录成功", "data": { "token": "eyJhbGciOiJIUzI1Ni...", "user": { "id": 1, "username": "admin", "nickname": "管理员", "role": "admin", "avatarUrl": "..." } } }
- URL:
/api/auth/register - Method:
POST - Auth: 无需认证
- Body:
{ "username": "newuser", "password": "password123", "nickname": "新用户" } - Response:
{ "code": 200, "message": "注册成功", "data": { ...user info... } }
- URL:
/api/auth/logout - Method:
POST - Auth: 需要 Token
- Response:
{ "code": 200, "message": "登出成功", "data": null }
- URL:
/api/auth/user - Method:
GET - Auth: 需要 Token
- Response: 返回当前登录用户的详细信息。
- URL:
/api/auth/check - Method:
GET - Auth: 无需认证 (用于前端判断 Token 有效性)
- Response:
{ "code": 200, "data": { "isLogin": true, "userId": 1, "tokenTimeout": 7200 } }
- URL:
/api/user/profile - Method:
GET - Auth: 需要 Token
- Response: 返回当前用户的个人资料(不含密码等敏感信息)。
- URL:
/api/user/profile - Method:
PUT - Auth: 需要 Token
- Body:
{ "nickname": "新昵称", "email": "newemail@example.com", "avatarUrl": "..." }
- URL:
/api/user/password - Method:
PUT - Auth: 需要 Token
- Body:
{ "oldPassword": "oldPass", "newPassword": "newPass" }
以下接口均需要
admin角色权限。
- URL:
/api/admin/statistics - Method:
GET - Response:
{ "code": 200, "data": { "userCount": 100, "questionCount": 5000, "todayLoginCount": 25, "todayPracticeCount": 150 } }
- 获取列表:
GET /api/admin/users?page=1&size=10&username=xxx - 获取详情:
GET /api/admin/users/{id} - 修改状态:
PUT /api/admin/users/{id}/status(Body:{ "status": 0 }) - 重置密码:
PUT /api/admin/users/{id}/reset-password - 删除用户:
DELETE /api/admin/users/{id}
- 登录日志:
GET /api/admin/login-logs?page=1&size=10 - 操作日志:
GET /api/admin/operation-logs?page=1&size=10
- URL:
/api/questions - Method:
GET - Query Params:
page: 页码 (默认1)size: 每页数量 (默认10)subject: 科目名type: 题型 (single-choice,multiple-choice,judge)difficulty: 难度keyword: 关键词搜索
- Auth: 需要 Token
- URL:
/api/questions - Method:
POST - Body:
{ "type": "single-choice", "subject": "马原", "content": "题目内容...", "options": ["A:选项1", "B:选项2"], "answer": "A", "difficulty": "medium" }
- 更新:
PUT /api/questions/{id} - 删除:
DELETE /api/questions/{id} - 批量删除:
DELETE /api/questions/batch(Body:[1, 2, 3])
- URL:
/api/questions/random - Method:
GET - Query Params:
subject,type,count
- URL:
/api/practice/submit - Method:
POST - Body:
{ "questionId": 123, "userAnswer": "A", "costTime": 15 } - Response: 返回是否正确及正确答案解析。
- URL:
/api/practice/wrong - Method:
GET - Query Params:
page,size,subject
- URL:
/api/practice/statistics - Method:
GET - Response: 返回用户的练习总数、正确率、各科目掌握情况等。
- URL:
/api/import/excel - Method:
POST - ContentType:
multipart/form-data - Params:
file: Excel文件subject: 科目名称 (可选)
- URL:
/api/export - Method:
POST - Response: 下载 Excel 文件
- 选择题模板:
GET /api/import/template/choice - 判断题模板:
GET /api/import/template/judge