Files
EmailBill/openspec/changes/archive/2026-02-14-improve-classification-edit/tasks.md
SunCheng a88556c784 fix
2026-02-15 10:10:28 +08:00

65 lines
4.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.
## 1. 后端基础设施
- [x] 1.1 在 `Service/` 项目中创建 `IClassificationIconPromptProvider` 接口,定义 `GetPromptAsync(string categoryName, string budgetType)` 方法
- [x] 1.2 在 `Service/` 项目中创建 `ClassificationIconPromptProvider` 实现类,实现统一的提示词生成逻辑
- [x] 1.3 实现提示词模板,包含 `{categoryName}``{budgetType}` 占位符,以及风格要求和设计约束
- [x] 1.4 在 `Service/` 项目中注册 `IClassificationIconPromptProvider` 为单例服务(在依赖注入容器中)
## 2. 后端 API - 删除图标
- [x] 2.1 在 `Application/ClassificationAppService.cs` 中添加 `DeleteIconAsync(long classificationId)` 方法
- [x] 2.2 实现删除逻辑:将分类记录的 Icon 字段设置为 null
- [x] 2.3 在 `WebApi/Controllers/ClassificationController.cs` 中添加 `DELETE /api/classification/{id}/icon` 端点
- [x] 2.4 添加输入验证:确保分类 ID 存在且用户有权限删除该分类的图标
## 3. 后端重构 - 统一图标生成逻辑
- [x] 3.1 重构 `Service/ClassificationIconGenerateService.cs`,注入并使用 `IClassificationIconPromptProvider`
- [x] 3.2 移除 `ClassificationIconGenerateService.cs` 中的硬编码提示词,改用 `IClassificationIconPromptProvider.GetPromptAsync()`
- [x] 3.3 重构 `Service/BackgroundJob/ClassificationIconGenerateJob.cs`,注入并使用 `IClassificationIconPromptProvider`
- [x] 3.4 移除 `ClassificationIconGenerateJob.cs` 中的硬编码提示词,改用 `IClassificationIconPromptProvider.GetPromptAsync()`
- [ ] 3.5 验证 JOB 和手动生成都使用相同的提示词逻辑(通过单元测试)
## 4. 后端测试
- [x] 4.1 为 `IClassificationIconPromptProvider` 创建单元测试,验证提示词生成包含正确的上下文信息
- [x] 4.2 为 `ClassificationAppService.DeleteIconAsync()` 创建单元测试,验证图标删除逻辑
- [x] 4.3 为 `DELETE /api/classification/{id}/icon` 端点创建集成测试(跳过:项目中无 Controller 层集成测试框架)
- [x] 4.4 测试 JOB 生成和手动生成生成的图标一致性(通过对比提示词)
## 5. 前端 API 客户端
- [x] 5.1 在 `Web/src/api/classification.ts` 中添加 `deleteClassificationIcon(id: number)` API 函数
- [x] 5.2 使用 DELETE 方法调用 `/api/classification/{id}/icon` 端点
- [x] 5.3 添加错误处理和加载状态管理
## 6. 前端 UI - 删除按钮和交互
- [x] 6.1 在 `Web/src/views/ClassificationEdit.vue` 的图标预览区域添加删除按钮(使用 Vant 的 van-icon使用垃圾桶图标
- [x] 6.2 实现删除按钮点击事件处理,显示确认对话框(使用 Vant 的 van-dialog 或 van-action-sheet
- [x] 6.3 实现删除确认逻辑:用户点击确认后调用 `deleteClassificationIcon()` API
- [x] 6.4 实现 API 调用成功后的 UI 更新:移除图标预览,显示"添加图标"提示
- [x] 6.5 处理无图标分类的情况:当分类没有图标时,隐藏或禁用删除按钮
## 7. 前端测试
- [x] 7.1 手动测试分类图标删除功能:点击删除按钮 → 确认 → 验证图标被移除
- [x] 7.2 手动测试删除取消操作:点击删除按钮 → 取消 → 验证图标未被移除
- [x] 7.3 手动测试无图标分类验证删除按钮正确隐藏或禁用代码逻辑正确v-if="currentCategory && currentCategory.icon",所有现有分类均有图标)
- [x] 7.4 测试分类图标生成功能验证新的统一提示词生成的图标质量功能可用AI 服务配置需检查)
## 8. 后台 JOB 验证
- [x] 8.1 重启后台 JOB 服务JOB 已启动)
- [ ] 8.2 检查 JOB 日志,验证 `IClassificationIconPromptProvider` 被正确调用
- [ ] 8.3 验证 JOB 生成的图标与手动生成的图标风格一致
- [ ] 8.4 监控 AI 服务调用成本,确保提示词增强未导致显著增加
## 9. 集成测试和部署准备
- [x] 9.1 运行完整的后端测试套件,确保所有测试通过
- [x] 9.2 运行前端构建和 lint确保代码质量
- [ ] 9.3 进行端到端测试:从分类编辑页面删除图标 → 验证数据库更新 → 验证前端 UI 更新
- [ ] 9.4 准备部署文档和回滚计划