Files
go-sms-V2/internal/model/entity/base.go
T
Tory bb60d60529
ci / test (push) Canceled after 0s
ci / web-test (push) Canceled after 0s
ci / build (push) Canceled after 0s
ci / deploy-dev (push) Canceled after 0s
S4-D1/D2: C1 回调推送引擎+C2 上行自动拉黑——验收项「死信可查/拒收即拉黑」✅: ①C1=callback_task 队列表(迁移 v21,状态机 pending→sent/dead+attempt/next_retry_at/last_code)+PushWorker(2s 扫/批 100/并发 8/2^n 秒指数退避封顶 10min/10 次耗尽死信/UPDATE CAS 防竞态)+双挂点(report 终态首锁[Consumer+PairService,与 CMPP Deliver 同点同语义]+uplink 消费尾)+URL 门控 account_config.report_url/uplink_url(60s TTL 缓存,未配置零任务)+GET /ops/callback(列表+状态计数面板)/POST /ops/callback/:id/resend(casbin ops callback:read/write v21 所种)+前端回调管理页(ops-callback 路由系统管理组+api/callback.ts+状态面板/筛选/载荷展开/死信重派;matrix+guard 33 菜单显式更)+metrics callback_push_total{type,result}/blacklist_total+openapi v1.4.0;②C2=AutoBlacklister 等值词表(trim+lower 防误伤,默认 R/TD/退订/拒收;SystemConfig uplink.blacklist.keywords 可配 60s 刷新)→policy_blacklist(source=2/账号级/uk 幂等)+Redis Set 即时生效,拉黑不影响上行推送(需求原文);③真机全链六步实证(dev 中间件):回执 DELIVRD→detail 终态→HTTP 回调 JSON 送达(200/sent)+上行 R→拉黑(source=2+Redis=1)+推送送达+坏 URL→attempt10→dead→resend ISC:000→修复重投 sent+status_counts 面板;一次性探针 cmd/cbprobe 用后即删+冒烟数据全清;④单测 +13(callback 6[入队门控/载荷/状态机全链/并发批]+uplink 5[词表/配置覆盖/幂等缓存/消费链]+report 2[首锁一次/nil]);⑤门禁=build/vet/-race 40 包/lint 0/eslint0/vue-tsc0/vitest 148/build 全绿;迁移测试 v15..v21 两遍幂等+dev 实跑 v21;gofmt 存量 8 文件顺手清零(S2 遗留);⑥口径诚实标注:载荷无签名挂账/拦截终态 HTTP 未挂(CMPP 侧已有)/PushWorker 单实例 at-least-once;验收单 s4-d1d2-callback.md+CHANGELOG+memory-bank 回填
2026-11-16 11:19:55 +08:00

56 lines
2.1 KiB
Go

// Package entity GORM 实体模型(Day 11):与 scripts/init_schema.sql 一一对应。
// 命名:表名 <module>_<entity>;通用字段见 Model / SnowflakeModel。
package entity
import (
"time"
"gorm.io/gorm"
)
// Model 通用模型:自增主键 + 时间戳 + 软删除。
type Model struct {
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
// LogModel 日志/统计模型:自增主键 + 创建时间,无软删(高吞吐写入)。
type LogModel struct {
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
}
// SnowflakeModel 雪花主键模型(message_detail 等全局唯一明细)。
type SnowflakeModel struct {
ID int64 `gorm:"primaryKey;autoIncrement:false" json:"id"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
}
// All 返回全部实体(AutoMigrate / schema 校验用),顺序与 init_schema.sql 一致。
func All() []any {
return []any{
// 账号体系(7)
&AccountUser{}, &AccountConfig{}, &AccountPrice{}, &AccountRole{},
&AccountPermission{}, &AccountRolePermission{}, &AccountBalanceLog{},
// 通道体系(7)
&ChannelChannel{}, &ChannelUpstream{}, &ChannelPrice{}, &ChannelGroup{},
&ChannelGroupItem{}, &ChannelBlockedCode{}, &ChannelLog{},
// 路由与策略(5)
&RouteRule{}, &PolicyBlacklist{}, &PolicyWhitelist{}, &PolicyKeyword{},
&PolicyFrequency{},
// 消息与审核(8)
&MessageTask{}, &MessageDetail{}, &MessageReport{}, &MessageUplink{},
&AuditRecord{}, &TemplateSMS{}, &SendBlockLog{}, &UplinkCode{},
// 计费与结算(5)
&BillingOrder{}, &BillingConsumeLog{}, &SettleCustomer{}, &SettleUpstream{},
&SettleRecord{},
// 统计与运维(7)
&StatsChannelDaily{}, &SystemConfig{}, &SystemAlertRule{},
&SystemLoginLog{}, &SystemOperateLog{}, &SystemErrorCode{}, &FeErrorLog{},
// 回调与通知(S4·C1)
&CallbackTask{},
}
}