You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
1.4 KiB

# 04 — DictItem 出入参规范化
**What to build:** DictItemVO 改名为 DictItemDTO(继承 BaseDTO,加 `fromEntity`/`toEntity`)。DictItemController.saveOrUpdate 入参从 DictItem(实体)改为 DictItemDTO——消除 mass assignment 漏洞。DictItemController.enabledList 出参从 `List<DictItem>`(实体直出)改为 `List<DictItemDTO>`——`deleted`/`creatorId`/`updaterId` 不再泄露。Service 层手工置空审计字段的代码删除。与 03 同模式,作用于 DictItem 实体。
**Blocked by:** 01 (BaseDTO 重构), 02 (InitBinder)
**Status:** resolved
- [x] `DictItemVO` 改名为 `DictItemDTO`,加 `@Data` + `@EqualsAndHashCode(callSuper = true)`,继承 `BaseDTO`
- [x] `DictItemDTO` 上实现 `fromEntity(DictItem)` 静态方法和 `toEntity()` 实例方法
- [x] `DictItemController.saveOrUpdate` 入参从 `DictItem` 改为 `DictItemDTO`
- [x] `DictItemController.enabledList` 出参从 `List<DictItem>` 改为 `List<DictItemDTO>`
- [x] Service 层手工置空 `createTime`/`creatorId`/`updaterId`/`deleted` 的代码删除
- [x] Service 层手工强制 `builtin = false` 的代码删除
- [x] DictItemController 不再 import `DictItem` 实体
- [x] 测试:saveOrUpdate 入参为 DictItemDTO,提交 `builtin=true` 被strip
- [x] 测试:enabledList 返回的 JSON 中不包含 `deleted`/`creatorId`/`updaterId`
- [x] 测试:现有 dict 模块测试在改入参类型后仍全绿