fix(supply-api): 修复编译错误和测试问题
- 添加 ErrNotFound 和 ErrConcurrencyConflict 错误定义 - 修复 pgx.NullTime 替换为 *time.Time - 修复 db.go 事务类型 (pgx.Tx vs pgxpool.Tx) - 移除未使用的导入和变量 - 修复 NewSupplyAPI 调用参数 - 修复中间件链路 handler 类型问题 - 修复适配器类型引用 (storage.InMemoryAccountStore 等) - 所有测试通过 Test: go test ./...
This commit is contained in:
@@ -42,48 +42,48 @@ const (
|
||||
|
||||
// 账号
|
||||
type Account struct {
|
||||
ID int64 `json:"account_id"`
|
||||
SupplierID int64 `json:"supplier_id"`
|
||||
Provider Provider `json:"provider"`
|
||||
AccountType AccountType `json:"account_type"`
|
||||
CredentialHash string `json:"-"` // 不暴露
|
||||
KeyID string `json:"key_id,omitempty"` // 不暴露
|
||||
Alias string `json:"account_alias,omitempty"`
|
||||
Status AccountStatus `json:"status"`
|
||||
RiskLevel string `json:"risk_level"`
|
||||
TotalQuota float64 `json:"total_quota,omitempty"`
|
||||
AvailableQuota float64 `json:"available_quota,omitempty"`
|
||||
FrozenQuota float64 `json:"frozen_quota,omitempty"`
|
||||
IsVerified bool `json:"is_verified"`
|
||||
VerifiedAt *time.Time `json:"verified_at,omitempty"`
|
||||
LastCheckAt *time.Time `json:"last_check_at,omitempty"`
|
||||
TosCompliant bool `json:"tos_compliant"`
|
||||
TosCheckResult string `json:"tos_check_result,omitempty"`
|
||||
TotalRequests int64 `json:"total_requests"`
|
||||
TotalTokens int64 `json:"total_tokens"`
|
||||
TotalCost float64 `json:"total_cost"`
|
||||
SuccessRate float64 `json:"success_rate"`
|
||||
RiskScore int `json:"risk_score"`
|
||||
RiskReason string `json:"risk_reason,omitempty"`
|
||||
IsFrozen bool `json:"is_frozen"`
|
||||
FrozenReason string `json:"frozen_reason,omitempty"`
|
||||
ID int64 `json:"account_id"`
|
||||
SupplierID int64 `json:"supplier_id"`
|
||||
Provider Provider `json:"provider"`
|
||||
AccountType AccountType `json:"account_type"`
|
||||
CredentialHash string `json:"-"` // 不暴露
|
||||
KeyID string `json:"key_id,omitempty"` // 不暴露
|
||||
Alias string `json:"account_alias,omitempty"`
|
||||
Status AccountStatus `json:"status"`
|
||||
RiskLevel string `json:"risk_level"`
|
||||
TotalQuota float64 `json:"total_quota,omitempty"`
|
||||
AvailableQuota float64 `json:"available_quota,omitempty"`
|
||||
FrozenQuota float64 `json:"frozen_quota,omitempty"`
|
||||
IsVerified bool `json:"is_verified"`
|
||||
VerifiedAt *time.Time `json:"verified_at,omitempty"`
|
||||
LastCheckAt *time.Time `json:"last_check_at,omitempty"`
|
||||
TosCompliant bool `json:"tos_compliant"`
|
||||
TosCheckResult string `json:"tos_check_result,omitempty"`
|
||||
TotalRequests int64 `json:"total_requests"`
|
||||
TotalTokens int64 `json:"total_tokens"`
|
||||
TotalCost float64 `json:"total_cost"`
|
||||
SuccessRate float64 `json:"success_rate"`
|
||||
RiskScore int `json:"risk_score"`
|
||||
RiskReason string `json:"risk_reason,omitempty"`
|
||||
IsFrozen bool `json:"is_frozen"`
|
||||
FrozenReason string `json:"frozen_reason,omitempty"`
|
||||
|
||||
// 加密元数据字段 (XR-001)
|
||||
CredentialCipherAlgo string `json:"credential_cipher_algo,omitempty"`
|
||||
CredentialKMSKeyAlias string `json:"credential_kms_key_alias,omitempty"`
|
||||
CredentialKeyVersion int `json:"credential_key_version,omitempty"`
|
||||
CredentialFingerprint string `json:"credential_fingerprint,omitempty"`
|
||||
LastRotationAt *time.Time `json:"last_rotation_at,omitempty"`
|
||||
CredentialCipherAlgo string `json:"credential_cipher_algo,omitempty"`
|
||||
CredentialKMSKeyAlias string `json:"credential_kms_key_alias,omitempty"`
|
||||
CredentialKeyVersion int `json:"credential_key_version,omitempty"`
|
||||
CredentialFingerprint string `json:"credential_fingerprint,omitempty"`
|
||||
LastRotationAt *time.Time `json:"last_rotation_at,omitempty"`
|
||||
|
||||
// 单位与币种 (XR-001)
|
||||
QuotaUnit string `json:"quota_unit"`
|
||||
CurrencyCode string `json:"currency_code"`
|
||||
|
||||
// 审计字段 (XR-001)
|
||||
Version int `json:"version"`
|
||||
Version int `json:"version"`
|
||||
CreatedIP *netip.Addr `json:"created_ip,omitempty"`
|
||||
UpdatedIP *netip.Addr `json:"updated_ip,omitempty"`
|
||||
AuditTraceID string `json:"audit_trace_id,omitempty"`
|
||||
AuditTraceID string `json:"audit_trace_id,omitempty"`
|
||||
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
@@ -91,10 +91,10 @@ type Account struct {
|
||||
|
||||
// 验证结果
|
||||
type VerifyResult struct {
|
||||
VerifyStatus string `json:"verify_status"` // pass, review_required, reject
|
||||
AvailableQuota float64 `json:"available_quota,omitempty"`
|
||||
RiskScore int `json:"risk_score"`
|
||||
CheckItems []CheckItem `json:"check_items,omitempty"`
|
||||
VerifyStatus string `json:"verify_status"` // pass, review_required, reject
|
||||
AvailableQuota float64 `json:"available_quota,omitempty"`
|
||||
RiskScore int `json:"risk_score"`
|
||||
CheckItems []CheckItem `json:"check_items,omitempty"`
|
||||
}
|
||||
|
||||
type CheckItem struct {
|
||||
@@ -115,12 +115,12 @@ type AccountService interface {
|
||||
|
||||
// 创建账号请求
|
||||
type CreateAccountRequest struct {
|
||||
SupplierID int64
|
||||
Provider Provider
|
||||
AccountType AccountType
|
||||
Credential string
|
||||
Alias string
|
||||
RiskAck bool
|
||||
SupplierID int64
|
||||
Provider Provider
|
||||
AccountType AccountType
|
||||
Credential string
|
||||
Alias string
|
||||
RiskAck bool
|
||||
}
|
||||
|
||||
// 账号仓储接口
|
||||
@@ -133,7 +133,7 @@ type AccountStore interface {
|
||||
|
||||
// 账号服务实现
|
||||
type accountService struct {
|
||||
store AccountStore
|
||||
store AccountStore
|
||||
auditStore audit.AuditStore
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user