Files
junhong_cmp_fiber/openspec/changes/archive/2026-04-11-fix-status-convention-comments/proposal.md
2026-04-11 12:21:02 +08:00

2.1 KiB
Raw Blame History

Why

model 层 6 个结构体的 status 字段注释写的是 1-启用 2-禁用,与项目全局约定 0=禁用, 1=启用 相反。虽然 service 层代码已经在用正确的 constants.StatusDisabled = 0,但错误注释会误导开发者,同时 DTO description 和一个僵尸常量也需要同步修正。

What Changes

  • 修正 6 个 model 注释:将 comment: "状态 1-启用 2-禁用" 改为 comment: "状态 0=禁用 1=启用"
    • internal/model/package.goPackageSeries.Status, Package.Status
    • internal/model/shop_package_allocation.goShopPackageAllocation.Status
    • internal/model/shop_series_allocation.goShopSeriesAllocation.Status
    • internal/model/system.goDevCapabilityConfig.Status
    • internal/model/financial.goPaymentMerchantSetting.Status
  • 删除僵尸常量pkg/constants/iot.go 中的 DevCapabilityStatusEnabled = 1 / DevCapabilityStatusDisabled = 2 从未被 service 层调用,直接删除
  • 修正 DTO descriptioninternal/model/dto/ 中描述为 (1:启用, 2:禁用) 的字段改为 (0:禁用, 1:启用)(涉及 package_series_dto.goshop_series_grant_dto.gomy_package.go 等)
  • 修正语义混用shop_series_grant/service.goShelfStatus: constants.StatusEnabled 改为 constants.ShelfStatusOn(值相同,但语义正确)

无任何数据库迁移:所有有数据的表中 status 均为 1没有 status=2 的行service 代码已在用 0=禁用 约定。

Capabilities

New Capabilities

无新能力引入。

Modified Capabilities

无 spec 级别的行为变更,仅修正文档注释与代码的一致性。

Impact

  • 受影响文件internal/model/6 个 modelinternal/model/dto/(若干 DTOpkg/constants/iot.gointernal/service/shop_series_grant/service.go
  • API 行为不变。status 字段的实际读写逻辑不变,仅注释和常量修正
  • 数据库:不变。无需迁移
  • 前端/接口消费方:接口返回的 status 值本就是 0/1由 service 代码决定),与注释写什么无关,不受影响