# 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. 测试课程列表接口 - URL:http://localhost:8000/admin/mycourse/list - 方法:GET - 请求头:Authorization: Bearer {token} - 参数: - page: 1 - size: 10 - study_status: 1 (学习中) 或 2 (已完结) 或 0 (全部) ## 预期响应 接口将返回符合截图显示的课程数据: - 课程标题和副标题 - 讲师和学科信息 - 课程描述 - 集数、节数、时长信息 - 学习状态(学习中/已完结) 这个简化版本只包含截图中实际需要的功能,没有添加额外的复杂功能。