# 统一错误消息数据源 - 任务清单 ## 1. 基础设施改造 - [x] 1.1 在 `pkg/errors/codes.go` 中添加 `allErrorCodes` 错误码注册表 - [x] 1.2 改造 `pkg/errors/errors.go` 中的 `New()` 函数签名为可变参数 - [x] 1.3 改造 `pkg/errors/errors.go` 中的 `Wrap()` 函数签名为可变参数 - [x] 1.4 在 `pkg/errors/codes.go` 中添加 `init()` 启动时校验函数 ## 2. 测试保障 - [x] 2.1 在 `pkg/errors/codes_test.go` 中添加 `TestAllCodesHaveMessages` 测试 - [x] 2.2 在 `pkg/errors/codes_test.go` 中添加 `TestNoOrphanMessages` 测试(检测孤立映射) - [x] 2.3 更新 `pkg/errors/handler_test.go` 测试覆盖新的函数签名 ## 3. 业务代码清理 - Service 层 - [x] 3.1 清理 `internal/service/commission_withdrawal/service.go` 冗余硬编码 - [x] 3.2 清理 `internal/service/shop/service.go` 冗余硬编码 - [x] 3.3 清理 `internal/service/auth/service.go` 冗余硬编码 - [x] 3.4 清理 `internal/service/shop_account/service.go` 冗余硬编码 - [x] 3.5 清理 `internal/service/enterprise/service.go` 冗余硬编码 - [x] 3.6 清理 `internal/service/customer/service.go` 冗余硬编码 - [x] 3.7 清理 `internal/service/customer_account/service.go` 冗余硬编码 - [x] 3.8 清理 `internal/service/role/service.go` 冗余硬编码 - [x] 3.9 清理 `internal/service/permission/service.go` 冗余硬编码 - [x] 3.10 清理 `internal/service/account/service.go` 冗余硬编码 - [x] 3.11 清理 `internal/service/enterprise_card/service.go` 冗余硬编码 - [x] 3.12 清理 `internal/service/my_commission/service.go` 冗余硬编码 - [x] 3.13 清理 `internal/service/shop_commission/service.go` 冗余硬编码 - [x] 3.14 清理 `internal/service/commission_withdrawal_setting/service.go` 冗余硬编码 ## 4. 业务代码清理 - Handler 层 - [x] 4.1 清理 `internal/handler/admin/*.go` 冗余硬编码(无需清理,都是业务特定消息) - [x] 4.2 清理 `internal/handler/h5/*.go` 冗余硬编码(无需清理,都是业务特定消息) - [x] 4.3 清理 `internal/handler/app/*.go` 冗余硬编码(无需清理,都是业务特定消息) ## 5. 业务代码清理 - Middleware 和其他 - [x] 5.1 清理 `pkg/middleware/*.go` 冗余硬编码(无需清理,都是业务特定消息) - [x] 5.2 清理 `internal/middleware/*.go` 冗余硬编码(无需清理,都是业务特定消息) - [x] 5.3 清理 `internal/bootstrap/*.go` 冗余硬编码(无需清理,都是业务特定消息) ## 6. 验证和收尾 - [x] 6.1 运行完整测试套件 `go test ./pkg/...` - 全部通过 - [x] 6.2 运行 lsp_diagnostics 检查类型错误 - 无错误 - [x] 6.3 编译验证 `go build ./...` - 成功