package entity import "time" // (S2·R2 裁决)StatsUserDaily 用户日统计已废弃:与 billing_consume_log // 同粒度双空壳,消耗事实源统一归 billing_consume_log(账号×业务×天), // 表由迁移 v20 DROP;用户侧统计查询走 billing_consume_log API。 // StatsChannelDaily 通道日统计(含估算余额)。 type StatsChannelDaily struct { ID int64 `gorm:"primaryKey;autoIncrement" json:"id"` ChannelID int64 `gorm:"uniqueIndex:uk_channel_date,priority:1" json:"channel_id"` StatDate time.Time `gorm:"type:date;uniqueIndex:uk_channel_date,priority:2;index:idx_date" json:"stat_date"` SubmitCount int `json:"submit_count"` SuccessCount int `json:"success_count"` FailCount int `json:"fail_count"` UnknownCount int `json:"unknown_count"` CostTotal float64 `gorm:"type:decimal(12,4)" json:"cost_total"` EstBalance int64 `json:"est_balance"` UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"` } func (StatsChannelDaily) TableName() string { return "stats_channel_daily" } // SystemConfig 系统参数配置。 type SystemConfig struct { Model CfgKey string `gorm:"size:64;uniqueIndex:uk_key" json:"cfg_key"` CfgValue string `gorm:"size:1024" json:"cfg_value"` Remark string `gorm:"size:255" json:"remark"` UpdatedBy string `gorm:"size:64" json:"updated_by"` } func (SystemConfig) TableName() string { return "system_config" } // SystemAlertRule 告警规则(余额/通道)。 type SystemAlertRule struct { Model TargetType string `gorm:"size:16;index:idx_target,priority:1" json:"target_type"` // account/channel/system TargetID int64 `gorm:"index:idx_target,priority:2" json:"target_id"` Metric string `gorm:"size:32" json:"metric"` Op string `gorm:"size:4;default:lt" json:"op"` Threshold float64 `gorm:"type:decimal(12,4)" json:"threshold"` NotifyType string `gorm:"size:32;default:wechat" json:"notify_type"` NotifyTo string `gorm:"size:128" json:"notify_to"` CooldownMin int `gorm:"default:30" json:"cooldown_min"` Status int8 `gorm:"index:idx_target,priority:3;default:1" json:"status"` LastAlertAt *time.Time `json:"last_alert_at"` // Day 27:上次告警时间(冷却去重锚点) } func (SystemAlertRule) TableName() string { return "system_alert_rule" } // SystemLoginLog 登录审计。 type SystemLoginLog struct { ID int64 `gorm:"primaryKey;autoIncrement" json:"id"` Username string `gorm:"size:64;index:idx_username_time,priority:1" json:"username"` AccountID int64 `json:"account_id"` IP string `gorm:"size:45;index:idx_ip" json:"ip"` UserAgent string `gorm:"size:255" json:"user_agent"` Ok int8 `gorm:"default:1" json:"ok"` FailReason string `gorm:"size:64" json:"fail_reason"` LoginAt time.Time `gorm:"index:idx_username_time,priority:2;index:idx_login_at" json:"login_at"` CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"` } func (SystemLoginLog) TableName() string { return "system_login_log" } // SystemOperateLog 操作日志。 type SystemOperateLog struct { ID int64 `gorm:"primaryKey;autoIncrement" json:"id"` Operator string `gorm:"size:64;index:idx_operator_time,priority:1" json:"operator"` AccountID int64 `json:"account_id"` Module string `gorm:"size:32;index:idx_module_time,priority:1" json:"module"` Action string `gorm:"size:32" json:"action"` Target string `gorm:"size:64" json:"target"` Detail string `gorm:"size:1024" json:"detail"` IP string `gorm:"size:45" json:"ip"` CreatedAt time.Time `gorm:"autoCreateTime;index:idx_operator_time,priority:2;index:idx_module_time,priority:2" json:"created_at"` } func (SystemOperateLog) TableName() string { return "system_operate_log" } // SystemErrorCode 错误代码表(UT:xxxx 体系)。 type SystemErrorCode struct { ID int64 `gorm:"primaryKey;autoIncrement" json:"id"` Code string `gorm:"size:16;uniqueIndex:uk_errcode_code" json:"code"` Name string `gorm:"size:64" json:"name"` RawValue string `gorm:"size:64" json:"raw_value"` Action int8 `gorm:"default:0" json:"action"` // 0失败 1重发 2入审 Status int8 `gorm:"default:1" json:"status"` CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"` UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"` } func (SystemErrorCode) TableName() string { return "system_error_code" }