hl-api-changelog/changelogs/2026-05/23_fix_compare_strip_subtitle_intro_crowd.md
API Changelog Bot b5ceb15d50 docs: 23日累计 3 条 changelog (banner 字段补全 + SMS info hotfix + compare 抹空)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 11:22:04 +08:00

1.8 KiB

fix(mp): /mp/product/compare 抹空 subtitle / introduction / crowdBenefit

仓库: HL (后端 hl-product-service-v2) 关联 PR/Issue: PR #2944, Closes #2943 日期: 2026-05-23 影响范围: /mp/product/compare 响应 3 个字段抹空 接收方: mmg (前端) 前端: 建议忽略 null 字段 — compare 页面无需展示这 3 字段


业务背景

wx 反馈: 产品对比接口前端只关心核心规格差异 (price / tier / itinerary / hotel 等), 简介性字段不需要返回。

改动

MpProductService.compareByLine 调完 getDetail 后, 循环把每个 VO 的 subtitle / introduction / crowdBenefit set null。

抽 private stripCompareIrrelevantFields(vo) helper, 单职责清晰。

为什么用 set null 而不删 VO 字段

MpProductDetailRespVO/mp/product/detail/mp/product/compare 共享的 VO。直接删字段会破坏详情接口。新建 compare 独立 VO 字段众多 (30+) 复制成本高。set null 是最小改动 + 详情接口零影响 + 前端忽略 null 即可。

API 行为变化

POST /mp/product/compare

每个产品对象:

  • subtitle: null (本来有值)
  • introduction: null (本来有值)
  • crowdBenefit: null (本来是嵌套对象)

其他字段不变。

/mp/product/detail 不受影响

仍返完整 subtitle / introduction / crowdBenefit。


🚨 前端

  • compare 页面渲染时忽略 subtitle / introduction / crowdBenefit (反正都是 null)
  • detail 页面继续读这 3 字段, 不变

单测

MpProductServiceTest 76 全绿, 含新加 compareByLine_stripsCompareIrrelevantFields 回归断言三字段都为 null。


联系人

后端: wx (呼籁旅行) 前端: mmg

如有疑问可在 #2943 评论区留言。