kindergarten_java/docs/dev-logs/2026-03-21.md
Claude Opus 4.6 c2e4477cdf docs: 更新开发日志 2026-03-21
记录学校端课程中心重构工作:
- 后端 SchoolCourseController 返回完整 CourseResponse
- 新增 CourseCenterView.vue 组件
- 新增 course-center.ts API 层
- 菜单文案修改:课程管理 → 课程中心
- 课程详情页现在展示完整数据

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 18:25:39 +08:00

204 lines
5.1 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.

# 开发日志 - 2026-03-21
## 学校端课程中心重构
### 背景
原有学校端"课程管理"模块功能单一:
- 课程详情页展示数据不完整(缺少课程介绍、排课参考、环创建设等)
- 与教师端课程中心存在功能重复
- 用户体验与教师端不一致
### 目标
1. 学校端课程中心照搬教师端实现
2. 课程详情页返回完整数据
3. 统一两端浏览体验
---
## 完成的工作
### 1. 后端修改
#### SchoolCourseController.java
- `getSchoolCourse()` 改为返回 `CourseResponse`(之前返回 `SchoolCourseResponse`
- 使用 `courseService.getCourseByIdWithLessons(id)` 获取完整数据
- 与教师端 `TeacherCourseController.getCourse()` 保持一致
```java
// 修改后
@GetMapping("/{id}")
public Result<CourseResponse> getSchoolCourse(@PathVariable Long id) {
Long tenantId = SecurityUtils.getCurrentTenantId();
courseService.getCourseByIdWithTenantCheck(id, tenantId);
return Result.success(courseService.getCourseByIdWithLessons(id));
}
```
#### SchoolPackageController.java
- 新增 `getPackagesByCollection()` - 获取套餐下的课程包列表
- 新增 `getFilterMeta()` - 获取筛选元数据(年级、主题)
#### CourseCollectionService.java / Impl
- 新增 `getPackagesByCollection()` 方法
- 新增 `getFilterMeta()` 方法
#### PackageFilterMetaResponse.java新增
- 筛选元数据响应类
- 包含 grades 和 themes 两个列表
### 2. 前端修改
#### 新增文件
| 文件 | 说明 |
|-----|------|
| `src/api/course-center.ts` | 课程中心通用 API |
| `src/views/school/courses-new/CourseCenterView.vue` | 学校端课程中心页面 |
| `src/views/school/courses-new/components/CoursePackageCard.vue` | 课程包卡片组件 |
| `src/views/teacher/courses-new/CourseCenterView.vue` | 教师端课程中心页面 |
| `src/views/teacher/courses-new/components/CoursePackageCard.vue` | 课程包卡片组件 |
#### 修改文件
| 文件 | 修改内容 |
|-----|---------|
| `src/router/index.ts` | 课程中心路由指向新组件 |
| `src/views/school/LayoutView.vue` | 菜单文案:课程管理 → 课程中心 |
| `src/api/school.ts` | `getSchoolCourse()` 返回 `Promise<any>` |
### 3. 设计文档
新增:`docs/design/25-课程中心重构设计.md`
内容包括:
- 功能对比矩阵(教师端 vs 学校端)
- 数据展示对比(重构前后)
- 架构设计组件、API、后端
- 页面布局设计
- 关键技术实现
- 文件变更清单
- 测试验证清单
---
## 课程详情页数据对比
| 数据项 | 重构前 | 重构后 |
|-------|:------:|:------:|
| 基本信息 | ✅ | ✅ |
| 使用统计 | ✅ | ✅ |
| 版本记录 | ✅ | ✅ |
| 课程介绍8项 | ❌ | ✅ |
| 排课计划参考 | ❌ | ✅ |
| 环创建设 | ❌ | ✅ |
| 课程配置lessons | ❌ | ✅ |
| 数字资源 | ❌ | ✅ |
---
## 关键技术点
### 1. API 返回完整 CourseResponse
课程详情 API 现在返回完整的 `CourseResponse`,包含:
```typescript
{
// 基本信息
id, name, description, coverImagePath, durationMinutes,
gradeTags, domainTags,
// 课程介绍8项
introSummary, introHighlights, introGoals, introSchedule,
introKeyPoints, introMethods, introEvaluation, introNotes,
// 排课参考
scheduleRefData: JSON 格式的周计划表,
// 环创建设
environmentConstruction,
// 课程配置
courseLessons: [
{
id, name, lessonType, duration,
objectives, preparation, extension, reflection,
videoPath, pptPath, pdfPath,
steps: [{ id, name, duration, objective, content }]
}
],
// 统计
usageCount, teacherCount, avgRating
}
```
### 2. 前端页面布局
课程中心采用左右两栏布局:
- **左侧**:套餐列表(垂直列表)
- **右侧**:课程包网格 + 筛选区
课程详情页展示区域:
1. 封面图
2. 基本信息卡片3列
3. 课程介绍Tab 切换)
4. 排课计划参考(表格)
5. 环创建设
6. 课程配置(课程卡片列表)
7. 数字资源(分类展示)
---
## 测试验证
### API 测试
```bash
# 登录获取 token
curl -X POST http://localhost:8480/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"school1","password":"123456"}'
# 获取课程详情
curl -H "Authorization: Bearer $TOKEN" \
http://localhost:8480/api/v1/school/courses/17 | jq '.data | keys'
```
结果验证:
- ✅ courseLessons: 7 个课程
- ✅ scheduleRefData: 存在
- ✅ introSummary 等字段: 存在
- ✅ environmentConstruction: 存在
### 前端测试
- ✅ 学校端课程中心页面正常加载
- ✅ 套餐列表正常显示
- ✅ 课程包网格正常显示
- ✅ 筛选功能正常
- ✅ 课程详情页展示完整数据
---
## Git 提交记录
```
ca56d85 docs: 添加课程中心重构设计文档
3183d1d feat: 学校端课程中心优化 - 照搬教师端实现
```
---
## 遗留问题
1. **组件复用**:学校端和教师端的 CourseCenterView 代码高度相似,可考虑抽象为通用组件
2. **学校端收藏**:暂未实现收藏功能
3. **学校端创建校本**:暂未实现
---
*本日志创建于 2026-03-21*