OL-LearnPlatform-Admin/docs/apifox_config.md
yl 59d31d4b47 feat: 添加我的课程模块功能
- 新增我的课程列表API接口
- 支持按学习状态筛选(全部/学习中/已完结)
- 支持分页查询
- 包含课程基本信息、学习进度等数据
- 添加Apifox接口文档配置指南

文件变更:
- server/api/admin/mycourse/mycourse.go - API接口定义
- server/internal/controller/admin/mycourse/mycourse.go - 控制器层
- server/internal/service/mycourse.go - 服务层(模拟数据)
- server/internal/router/admin.go - 路由配置
- docs/apifox_config.md - 接口文档
2025-07-28 15:30:04 +08:00

130 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Apifox接口文档配置指南 - 我的课程模块
## 项目基本信息
- **项目名称**:在线学习平台-我的课程模块
- **基础URL**http://localhost:8000/admin
- **认证方式**Bearer Token (JWT)
## 接口说明
### 获取我的课程列表
- **接口名称**:获取我的课程列表
- **请求方法**GET
- **接口路径**/mycourse/list
- **接口描述**:获取当前用户的课程列表,支持分页和状态筛选
**请求参数Query**
```json
{
"page": {
"type": "integer",
"description": "页码默认1",
"example": 1
},
"size": {
"type": "integer",
"description": "每页数量默认10",
"example": 10
},
"study_status": {
"type": "integer",
"description": "学习状态0全部课程 1学习中 2已完结",
"example": 1
}
}
```
**响应示例:**
```json
{
"code": 0,
"message": "success",
"data": {
"list": [
{
"id": 1,
"course_id": 1,
"title": "教育心理学的起源",
"subtitle": "计算机二级考前直播",
"cover_image": "/uploads/course/cover1.jpg",
"instructor": "代万权",
"subject": "史学",
"description": "本课程紧跟风向让每一位数据了解数据分析使用DeepSeek结合办公自动化职业岗位标准以实际工作任务为导向强调课程内容的实用性和针对性课程内容紧贴全国计算机等级考试技能。",
"total_episodes": 9,
"total_lessons": 54,
"total_duration": "12小时43分钟",
"studied_duration": "10小时20分钟",
"study_status": 1,
"study_status_text": "学习中",
"enrollment_time": "2025-01-20 10:30:00"
}
],
"page": 1,
"size": 10,
"total": 2
},
"timestamp": 1706428800
}
```
## 认证配置
### JWT Token配置
1. 在Apifox项目设置中添加认证方式
2. 选择"Bearer Token"
3. 在请求头中添加:
```
Authorization: Bearer {token}
```
### 环境变量配置
```json
{
"base_url": "http://localhost:8000",
"admin_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user_id": 1
}
```
## 测试步骤
### 1. 启动服务
```bash
cd e:\桌面\Remote/OL-LearnPlatform-Admin-main\ol-learnplatform-admin/server
go run main.go
```
### 2. 获取Token
先调用登录接口获取JWT Token
- 方法POST
- 路径:/admin/site/accountLogin
- 请求体:
```json
{
"username": "admin",
"password": "123456",
"cid": "",
"code": ""
}
```
### 3. 测试课程列表接口
- URLhttp://localhost:8000/admin/mycourse/list
- 方法GET
- 请求头Authorization: Bearer {token}
- 参数:
- page: 1
- size: 10
- study_status: 1 (学习中) 或 2 (已完结) 或 0 (全部)
## 预期响应
接口将返回符合截图显示的课程数据:
- 课程标题和副标题
- 讲师和学科信息
- 课程描述
- 集数、节数、时长信息
- 学习状态(学习中/已完结)
这个简化版本只包含截图中实际需要的功能,没有添加额外的复杂功能。