归档: fix-status-convention-comments

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-04-11 12:21:02 +08:00
parent 510a5bfb21
commit 7e613a0d2b
5 changed files with 168 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
## 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.go`PackageSeries.Status, Package.Status
- `internal/model/shop_package_allocation.go`ShopPackageAllocation.Status
- `internal/model/shop_series_allocation.go`ShopSeriesAllocation.Status
- `internal/model/system.go`DevCapabilityConfig.Status
- `internal/model/financial.go`PaymentMerchantSetting.Status
- **删除僵尸常量**`pkg/constants/iot.go` 中的 `DevCapabilityStatusEnabled = 1` / `DevCapabilityStatusDisabled = 2` 从未被 service 层调用,直接删除
- **修正 DTO description**`internal/model/dto/` 中描述为 `(1:启用, 2:禁用)` 的字段改为 `(0:禁用, 1:启用)`(涉及 `package_series_dto.go``shop_series_grant_dto.go``my_package.go` 等)
- **修正语义混用**`shop_series_grant/service.go``ShelfStatus: constants.StatusEnabled` 改为 `constants.ShelfStatusOn`(值相同,但语义正确)
**无任何数据库迁移**:所有有数据的表中 status 均为 1没有 status=2 的行service 代码已在用 `0=禁用` 约定。
## Capabilities
### New Capabilities
无新能力引入。
### Modified Capabilities
无 spec 级别的行为变更,仅修正文档注释与代码的一致性。
## Impact
- **受影响文件**`internal/model/`6 个 model`internal/model/dto/`(若干 DTO`pkg/constants/iot.go``internal/service/shop_series_grant/service.go`
- **API 行为**不变。status 字段的实际读写逻辑不变,仅注释和常量修正
- **数据库**:不变。无需迁移
- **前端/接口消费方**:接口返回的 status 值本就是 0/1由 service 代码决定),与注释写什么无关,不受影响