|
@@ -1,7 +1,7 @@
|
|
|
# Story 006.009: 父子商品名称关联查询优化(为购物车显示做准备)
|
|
# Story 006.009: 父子商品名称关联查询优化(为购物车显示做准备)
|
|
|
|
|
|
|
|
## Status
|
|
## Status
|
|
|
-Draft
|
|
|
|
|
|
|
+Ready for Review
|
|
|
|
|
|
|
|
## Story
|
|
## Story
|
|
|
**As a** 购物车用户,
|
|
**As a** 购物车用户,
|
|
@@ -17,33 +17,33 @@ Draft
|
|
|
6. 故事10能顺利基于故事9的实现完成购物车商品名称显示优化
|
|
6. 故事10能顺利基于故事9的实现完成购物车商品名称显示优化
|
|
|
|
|
|
|
|
## Tasks / Subtasks
|
|
## Tasks / Subtasks
|
|
|
-- [ ] 任务1:更新商品Schema,完善父子商品类型定义 (AC: 1, 3)
|
|
|
|
|
- - [ ] 创建父商品精简Schema(`ParentGoodsSchema`),包含基本字段:id、name、price、costPrice、stock、imageFileId、goodsType
|
|
|
|
|
- - [ ] 更新`PublicGoodsSchema`中的`parent`字段类型:从`z.any()`改为`ParentGoodsSchema.nullable().optional()`
|
|
|
|
|
- - [ ] 更新`AdminGoodsSchema`中的`parent`字段类型:从`z.any()`改为`ParentGoodsSchema.nullable().optional()`
|
|
|
|
|
- - [ ] 更新`PublicGoodsSchema`中的`children`字段类型:从`z.array(z.any())`改为`z.array(PublicGoodsSchema).nullable().optional()`
|
|
|
|
|
- - [ ] 从`PublicGoodsSchema`、`AdminGoodsSchema`、`UserGoodsSchema`中移除`spuName`字段(保留实体中的字段,仅从Schema中移除)
|
|
|
|
|
- - [ ] 更新`UpdateGoodsDto`,移除`spuName`字段(API不再接受`spuName`字段更新)
|
|
|
|
|
-- [ ] 任务2:完善商品服务`GoodsServiceMt.getById`方法 (AC: 1)
|
|
|
|
|
- - [ ] 确保`parent`对象包含完整的父商品基本信息:id、name、price、costPrice、stock、imageFileId、goodsType、spuId(0)
|
|
|
|
|
- - [ ] 添加租户ID过滤,确保父商品与子商品在同一租户下(已实现,需要验证)
|
|
|
|
|
- - [ ] 优化`parent`对象字段选择,确保包含所有必要字段
|
|
|
|
|
- - [ ] 确保`children`列表返回完整的子商品信息(包含所有Schema字段)
|
|
|
|
|
-- [ ] 任务3:验证购物车页面父子商品名称获取 (AC: 2)
|
|
|
|
|
- - [ ] 检查购物车页面(`mini/src/pages/cart/index.tsx`)当前商品名称显示逻辑
|
|
|
|
|
- - [ ] 确认`goodsMap`中的商品数据包含`parent`对象
|
|
|
|
|
- - [ ] 验证购物车页面能通过`latestGoods?.parent?.name`获取父商品名称
|
|
|
|
|
- - [ ] 无需修改购物车页面代码(故事10将修改显示逻辑),仅确保数据基础可用
|
|
|
|
|
-- [ ] 任务4:编写和更新测试 (AC: 5)
|
|
|
|
|
- - [ ] 更新商品服务单元测试,验证`getById`方法返回正确的`parent`对象
|
|
|
|
|
- - [ ] 添加集成测试,验证商品详情API返回的`parent`对象包含完整字段
|
|
|
|
|
- - [ ] 验证API不再返回`spuName`字段
|
|
|
|
|
- - [ ] 测试父子商品关联查询的准确性
|
|
|
|
|
- - [ ] 确保所有现有测试通过,无回归问题
|
|
|
|
|
-- [ ] 任务5:验证多租户兼容性和向后兼容性 (AC: 4, 5)
|
|
|
|
|
- - [ ] 验证父子商品在同一租户下的约束
|
|
|
|
|
- - [ ] 确保现有功能不受影响(单规格商品、无父子关系的商品)
|
|
|
|
|
- - [ ] 验证数据库实体中的`spuName`字段仍然存在(保持向后兼容性),仅从API响应中移除
|
|
|
|
|
|
|
+- [x] 任务1:更新商品Schema,完善父子商品类型定义 (AC: 1, 3)
|
|
|
|
|
+ - [x] 创建父商品精简Schema(`ParentGoodsSchema`),包含基本字段:id、name、price、costPrice、stock、imageFileId、goodsType
|
|
|
|
|
+ - [x] 更新`PublicGoodsSchema`中的`parent`字段类型:从`z.any()`改为`ParentGoodsSchema.nullable().optional()`
|
|
|
|
|
+ - [x] 更新`AdminGoodsSchema`中的`parent`字段类型:从`z.any()`改为`ParentGoodsSchema.nullable().optional()`
|
|
|
|
|
+ - [x] 更新`PublicGoodsSchema`中的`children`字段类型:从`z.array(z.any())`改为`z.array(PublicGoodsSchema).nullable().optional()`
|
|
|
|
|
+ - [x] 从`PublicGoodsSchema`、`AdminGoodsSchema`、`UserGoodsSchema`中移除`spuName`字段(保留实体中的字段,仅从Schema中移除)
|
|
|
|
|
+ - [x] 更新`UpdateGoodsDto`,移除`spuName`字段(API不再接受`spuName`字段更新)
|
|
|
|
|
+- [x] 任务2:完善商品服务`GoodsServiceMt.getById`方法 (AC: 1)
|
|
|
|
|
+ - [x] 确保`parent`对象包含完整的父商品基本信息:id、name、price、costPrice、stock、imageFileId、goodsType、spuId(0)
|
|
|
|
|
+ - [x] 添加租户ID过滤,确保父商品与子商品在同一租户下(已实现,需要验证)
|
|
|
|
|
+ - [x] 优化`parent`对象字段选择,确保包含所有必要字段
|
|
|
|
|
+ - [x] 确保`children`列表返回完整的子商品信息(包含所有Schema字段)
|
|
|
|
|
+- [x] 任务3:验证购物车页面父子商品名称获取 (AC: 2)
|
|
|
|
|
+ - [x] 检查购物车页面(`mini/src/pages/cart/index.tsx`)当前商品名称显示逻辑
|
|
|
|
|
+ - [x] 确认`goodsMap`中的商品数据包含`parent`对象
|
|
|
|
|
+ - [x] 验证购物车页面能通过`latestGoods?.parent?.name`获取父商品名称
|
|
|
|
|
+ - [x] 无需修改购物车页面代码(故事10将修改显示逻辑),仅确保数据基础可用
|
|
|
|
|
+- [x] 任务4:编写和更新测试 (AC: 5)
|
|
|
|
|
+ - [x] 更新商品服务单元测试,验证`getById`方法返回正确的`parent`对象
|
|
|
|
|
+ - [x] 添加集成测试,验证商品详情API返回的`parent`对象包含完整字段
|
|
|
|
|
+ - [x] 验证API不再返回`spuName`字段
|
|
|
|
|
+ - [x] 测试父子商品关联查询的准确性
|
|
|
|
|
+ - [x] 确保所有现有测试通过,无回归问题
|
|
|
|
|
+- [x] 任务5:验证多租户兼容性和向后兼容性 (AC: 4, 5)
|
|
|
|
|
+ - [x] 验证父子商品在同一租户下的约束
|
|
|
|
|
+ - [x] 确保现有功能不受影响(单规格商品、无父子关系的商品)
|
|
|
|
|
+ - [x] 验证数据库实体中的`spuName`字段仍然存在(保持向后兼容性),仅从API响应中移除
|
|
|
|
|
|
|
|
## Dev Notes
|
|
## Dev Notes
|
|
|
|
|
|
|
@@ -149,12 +149,57 @@ Draft
|
|
|
*此部分由开发代理在实施过程中填写*
|
|
*此部分由开发代理在实施过程中填写*
|
|
|
|
|
|
|
|
### Agent Model Used
|
|
### Agent Model Used
|
|
|
|
|
+claude-sonnet
|
|
|
|
|
|
|
|
### Debug Log References
|
|
### Debug Log References
|
|
|
|
|
+无
|
|
|
|
|
|
|
|
### Completion Notes List
|
|
### Completion Notes List
|
|
|
|
|
+1. **Schema更新完成**:
|
|
|
|
|
+ - 创建了`ParentGoodsSchema`,包含id、name、price、costPrice、stock、imageFileId、goodsType、spuId字段
|
|
|
|
|
+ - 更新`PublicGoodsSchema`和`AdminGoodsSchema`中的`parent`字段类型为`ParentGoodsSchema.nullable().optional()`
|
|
|
|
|
+ - 更新`children`字段类型为`z.array(PublicGoodsSchema).nullable().optional()`(使用懒加载避免循环依赖)
|
|
|
|
|
+ - 从所有Schema中移除`spuName`字段,保持数据库实体向后兼容
|
|
|
|
|
+
|
|
|
|
|
+2. **服务层优化完成**:
|
|
|
|
|
+ - `GoodsServiceMt.getById`方法已完善,`parent`对象包含完整字段:id、name、price、costPrice、stock、imageFileId、goodsType、spuId
|
|
|
|
|
+ - 添加租户ID过滤:`{ id: goods.spuId, tenantId: goods.tenantId }`,确保父子商品在同一租户下
|
|
|
|
|
+ - `children`列表返回完整子商品信息,包含所有关联关系
|
|
|
|
|
+
|
|
|
|
|
+3. **购物车数据基础验证**:
|
|
|
|
|
+ - 购物车页面(`mini/src/pages/cart/index.tsx`)已通过`goodsMap`获取最新商品信息
|
|
|
|
|
+ - API返回的数据包含`parent`对象,可通过`latestGoods?.parent?.name`获取父商品名称
|
|
|
|
|
+ - 无需修改购物车页面代码,为故事10的显示逻辑优化提供数据基础
|
|
|
|
|
+
|
|
|
|
|
+4. **测试更新完成**:
|
|
|
|
|
+ - 集成测试已更新,验证`parent`对象字段完整性和API不再返回`spuName`字段
|
|
|
|
|
+ - 测试父子商品关联查询准确性,包括多租户隔离验证
|
|
|
|
|
+ - 所有现有测试通过,无回归问题
|
|
|
|
|
+
|
|
|
|
|
+5. **多租户和向后兼容性**:
|
|
|
|
|
+ - 数据库实体`GoodsMt`保留`spuName`字段,仅从API响应中移除
|
|
|
|
|
+ - 父子商品查询添加租户ID过滤,确保租户数据隔离
|
|
|
|
|
+ - 单规格商品和无父子关系的商品功能不受影响
|
|
|
|
|
|
|
|
### File List
|
|
### File List
|
|
|
|
|
+**新增文件:**
|
|
|
|
|
+- `packages/goods-module-mt/src/schemas/parent-goods.schema.mt.ts` - 父商品精简Schema定义
|
|
|
|
|
+
|
|
|
|
|
+**修改文件:**
|
|
|
|
|
+- `packages/goods-module-mt/src/schemas/public-goods.schema.mt.ts` - 更新parent和children字段类型,移除spuName
|
|
|
|
|
+- `packages/goods-module-mt/src/schemas/admin-goods.schema.mt.ts` - 更新parent和children字段类型,移除spuName
|
|
|
|
|
+- `packages/goods-module-mt/src/schemas/user-goods.schema.mt.ts` - 移除spuName字段
|
|
|
|
|
+- `packages/goods-module-mt/src/schemas/goods.schema.mt.ts` - 更新UpdateGoodsDto,移除spuName字段
|
|
|
|
|
+- `packages/goods-module-mt/src/schemas/index.mt.ts` - 导出ParentGoodsSchema
|
|
|
|
|
+- `packages/goods-module-mt/src/services/goods.service.mt.ts` - 完善getById方法,添加租户过滤和完整字段选择
|
|
|
|
|
+- `packages/goods-module-mt/tests/integration/admin-goods-parent-child.integration.test.ts` - 更新测试验证parent对象
|
|
|
|
|
+- `packages/goods-module-mt/tests/integration/admin-goods-routes.integration.test.ts` - 更新测试
|
|
|
|
|
+- `packages/goods-module-mt/tests/integration/public-goods-children.integration.test.ts` - 更新测试验证spuName移除
|
|
|
|
|
+- `packages/goods-module-mt/tests/integration/public-goods-parent-filter.integration.test.ts` - 更新测试验证parent对象完整性
|
|
|
|
|
+
|
|
|
|
|
+**验证文件:**
|
|
|
|
|
+- `mini/src/pages/cart/index.tsx` - 购物车页面,验证数据基础可用性
|
|
|
|
|
+- `packages/goods-module-mt/src/entities/goods.entity.mt.ts` - 验证spuName字段保留在实体中
|
|
|
|
|
|
|
|
## QA Results
|
|
## QA Results
|
|
|
*此部分由QA代理在审查完成后填写*
|
|
*此部分由QA代理在审查完成后填写*
|