package model import "time" // OpenPlatformApiKey 开放平台 API Key(仅存哈希,创建时一次性返回明文) type OpenPlatformApiKey struct { ID uint `gorm:"primaryKey" json:"id"` Name string `gorm:"size:120;not null;default:''" json:"name"` KeyPrefix string `gorm:"size:48;not null;column:key_prefix" json:"keyPrefix"` KeyHash string `gorm:"size:64;not null;column:key_hash" json:"-"` RevokedAt *time.Time `gorm:"column:revoked_at" json:"revokedAt,omitempty"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` } func (OpenPlatformApiKey) TableName() string { return "open_platform_api_keys" } // OpenPlatformApiLog 开放平台请求明细(由网关/中间件写入;管理端查询) type OpenPlatformApiLog struct { ID uint `gorm:"primaryKey" json:"id"` ApiKeyID uint `gorm:"not null;index;column:api_key_id" json:"apiKeyId"` KeyPrefix string `gorm:"size:48;default:'';column:key_prefix" json:"keyPrefix"` Method string `gorm:"size:16;default:''" json:"method"` Path string `gorm:"size:512;default:''" json:"path"` StatusCode int `gorm:"column:status_code" json:"statusCode"` ClientIP string `gorm:"size:64;default:'';column:client_ip" json:"clientIp"` DurationMs int `gorm:"column:duration_ms" json:"durationMs"` RequestBody string `gorm:"type:text;column:request_body" json:"requestBody"` ResponseBody string `gorm:"type:text;column:response_body" json:"responseBody"` CreatedAt time.Time `gorm:"index" json:"createdAt"` } func (OpenPlatformApiLog) TableName() string { return "open_platform_api_logs" }