From d12ea0566d97aed5c73cb11a9b481a29d1feba0f Mon Sep 17 00:00:00 2001 From: chengqian Date: Thu, 27 Aug 2026 17:22:12 +0800 Subject: [PATCH] =?UTF-8?q?chore(dao):=20gf=20gen=20dao=20=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E5=81=A5=E5=BA=B7=E5=BA=A6=E4=B8=A4=E5=BC=A0=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E7=94=9F=E6=88=90=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 迁移 000017 执行后重跑 gf gen dao,把修正后的列注释同步进 entity/do/dao。 纯注释变更,无字段与类型改动——entity 中 success_rate / latency_ms / health_score 仍为 float64(非金额小数,符合 float64/decimal 分类规范)。 此前 entity 里 health_score 的注释写着已废止的四因子加权公式,是全链路唯一会 主动误导后来人的地方,至此与实现对齐。 --- internal/dao/internal/chn_health_scores.go | 12 +++++------ internal/dao/internal/chn_health_snapshots.go | 6 +++--- internal/model/do/chn_health_scores.go | 12 +++++------ internal/model/do/chn_health_snapshots.go | 6 +++--- internal/model/entity/chn_health_scores.go | 20 +++++++++---------- internal/model/entity/chn_health_snapshots.go | 16 +++++++-------- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/internal/dao/internal/chn_health_scores.go b/internal/dao/internal/chn_health_scores.go index e550c6a..bb1cf8b 100644 --- a/internal/dao/internal/chn_health_scores.go +++ b/internal/dao/internal/chn_health_scores.go @@ -23,12 +23,12 @@ type ChnHealthScoresDao struct { type ChnHealthScoresColumns struct { Id string // 主键ID ChannelId string // 关联渠道ID - SuccessRate string // 请求成功率(0-100) - LatencyMs string // 平均延迟(毫秒) - StabilityScore string // 稳定性评分(0-100,基于延迟波动计算) - ConsecutiveFailures string // 连续失败次数(成功后归零) - HealthScore string // 综合健康度(0-100)= 成功率×0.40 + 延迟分×0.25 + 稳定性×0.20 + 连续失败分×0.15 - CalculatedAt string // 最近一次计算时间 + SuccessRate string // 成功率(0-100)= 该渠道各模型 succ_ewma 均值×100,仅统计有真实上报的模型 + LatencyMs string // 平均延迟(毫秒)= 该渠道各模型 lat_ewma 均值,仅统计有真实上报的模型;仅展示用,不参与健康分计算 + StabilityScore string // 【已废弃】稳定性评分,健康体系重写后不再写入,保留列仅为兼容历史数据 + ConsecutiveFailures string // 【已废弃】连续失败次数,已由 Redis 熔断器的滑动窗口计数取代(dispatch:v1:breaker:*),保留列仅为兼容历史数据 + HealthScore string // 综合健康度(0-100)= avg(succ_ewma)^α × 100,α 取路由策略 health.alpha(默认 2),与调度 healthFactor 同源;每 5 分钟由维护任务聚合落盘,另可由渠道测试/重置健康度即时触发;Redis 读失败或全部模型无真实上报时保留旧值不覆盖。调度决策不读此表,仅供管理后台展示 + CalculatedAt string // 最近一次聚合落盘时间 CreatedAt string // 创建时间 UpdatedAt string // 更新时间 } diff --git a/internal/dao/internal/chn_health_snapshots.go b/internal/dao/internal/chn_health_snapshots.go index 7034d1e..02e7702 100644 --- a/internal/dao/internal/chn_health_snapshots.go +++ b/internal/dao/internal/chn_health_snapshots.go @@ -23,11 +23,11 @@ type ChnHealthSnapshotsDao struct { type ChnHealthSnapshotsColumns struct { Id string // 主键ID ChannelId string // 关联渠道ID - HealthScore string // 综合健康度(0-100) + HealthScore string // 综合健康度(0-100)快照,取自 chn_health_scores.health_score SuccessRate string // 请求成功率(0-100) LatencyMs string // 平均延迟(毫秒) - StabilityScore string // 稳定性评分(0-100) - ConsecutiveFailures string // 连续失败次数 + StabilityScore string // 【已废弃】稳定性评分,不再写入,新快照为 0 + ConsecutiveFailures string // 【已废弃】连续失败次数,不再写入,新快照为 0 SnapshotAt string // 快照时间 } diff --git a/internal/model/do/chn_health_scores.go b/internal/model/do/chn_health_scores.go index 6812339..6247223 100644 --- a/internal/model/do/chn_health_scores.go +++ b/internal/model/do/chn_health_scores.go @@ -14,12 +14,12 @@ type ChnHealthScores struct { g.Meta `orm:"table:chn_health_scores, do:true"` Id any // 主键ID ChannelId any // 关联渠道ID - SuccessRate any // 请求成功率(0-100) - LatencyMs any // 平均延迟(毫秒) - StabilityScore any // 稳定性评分(0-100,基于延迟波动计算) - ConsecutiveFailures any // 连续失败次数(成功后归零) - HealthScore any // 综合健康度(0-100)= 成功率×0.40 + 延迟分×0.25 + 稳定性×0.20 + 连续失败分×0.15 - CalculatedAt *gtime.Time // 最近一次计算时间 + SuccessRate any // 成功率(0-100)= 该渠道各模型 succ_ewma 均值×100,仅统计有真实上报的模型 + LatencyMs any // 平均延迟(毫秒)= 该渠道各模型 lat_ewma 均值,仅统计有真实上报的模型;仅展示用,不参与健康分计算 + StabilityScore any // 【已废弃】稳定性评分,健康体系重写后不再写入,保留列仅为兼容历史数据 + ConsecutiveFailures any // 【已废弃】连续失败次数,已由 Redis 熔断器的滑动窗口计数取代(dispatch:v1:breaker:*),保留列仅为兼容历史数据 + HealthScore any // 综合健康度(0-100)= avg(succ_ewma)^α × 100,α 取路由策略 health.alpha(默认 2),与调度 healthFactor 同源;每 5 分钟由维护任务聚合落盘,另可由渠道测试/重置健康度即时触发;Redis 读失败或全部模型无真实上报时保留旧值不覆盖。调度决策不读此表,仅供管理后台展示 + CalculatedAt *gtime.Time // 最近一次聚合落盘时间 CreatedAt *gtime.Time // 创建时间 UpdatedAt *gtime.Time // 更新时间 } diff --git a/internal/model/do/chn_health_snapshots.go b/internal/model/do/chn_health_snapshots.go index aa0ed6d..c832a21 100644 --- a/internal/model/do/chn_health_snapshots.go +++ b/internal/model/do/chn_health_snapshots.go @@ -14,10 +14,10 @@ type ChnHealthSnapshots struct { g.Meta `orm:"table:chn_health_snapshots, do:true"` Id any // 主键ID ChannelId any // 关联渠道ID - HealthScore any // 综合健康度(0-100) + HealthScore any // 综合健康度(0-100)快照,取自 chn_health_scores.health_score SuccessRate any // 请求成功率(0-100) LatencyMs any // 平均延迟(毫秒) - StabilityScore any // 稳定性评分(0-100) - ConsecutiveFailures any // 连续失败次数 + StabilityScore any // 【已废弃】稳定性评分,不再写入,新快照为 0 + ConsecutiveFailures any // 【已废弃】连续失败次数,不再写入,新快照为 0 SnapshotAt *gtime.Time // 快照时间 } diff --git a/internal/model/entity/chn_health_scores.go b/internal/model/entity/chn_health_scores.go index b3afa6f..0b696ca 100644 --- a/internal/model/entity/chn_health_scores.go +++ b/internal/model/entity/chn_health_scores.go @@ -10,14 +10,14 @@ import ( // ChnHealthScores is the golang structure for table chn_health_scores. type ChnHealthScores struct { - Id int64 `json:"id" orm:"id" description:"主键ID"` // 主键ID - ChannelId int64 `json:"channel_id" orm:"channel_id" description:"关联渠道ID"` // 关联渠道ID - SuccessRate float64 `json:"success_rate" orm:"success_rate" description:"请求成功率(0-100)"` // 请求成功率(0-100) - LatencyMs float64 `json:"latency_ms" orm:"latency_ms" description:"平均延迟(毫秒)"` // 平均延迟(毫秒) - StabilityScore float64 `json:"stability_score" orm:"stability_score" description:"稳定性评分(0-100,基于延迟波动计算)"` // 稳定性评分(0-100,基于延迟波动计算) - ConsecutiveFailures int `json:"consecutive_failures" orm:"consecutive_failures" description:"连续失败次数(成功后归零)"` // 连续失败次数(成功后归零) - HealthScore float64 `json:"health_score" orm:"health_score" description:"综合健康度(0-100)= 成功率×0.40 + 延迟分×0.25 + 稳定性×0.20 + 连续失败分×0.15"` // 综合健康度(0-100)= 成功率×0.40 + 延迟分×0.25 + 稳定性×0.20 + 连续失败分×0.15 - CalculatedAt *gtime.Time `json:"calculated_at" orm:"calculated_at" description:"最近一次计算时间"` // 最近一次计算时间 - CreatedAt *gtime.Time `json:"created_at" orm:"created_at" description:"创建时间"` // 创建时间 - UpdatedAt *gtime.Time `json:"updated_at" orm:"updated_at" description:"更新时间"` // 更新时间 + Id int64 `json:"id" orm:"id" description:"主键ID"` // 主键ID + ChannelId int64 `json:"channel_id" orm:"channel_id" description:"关联渠道ID"` // 关联渠道ID + SuccessRate float64 `json:"success_rate" orm:"success_rate" description:"成功率(0-100)= 该渠道各模型 succ_ewma 均值×100,仅统计有真实上报的模型"` // 成功率(0-100)= 该渠道各模型 succ_ewma 均值×100,仅统计有真实上报的模型 + LatencyMs float64 `json:"latency_ms" orm:"latency_ms" description:"平均延迟(毫秒)= 该渠道各模型 lat_ewma 均值,仅统计有真实上报的模型;仅展示用,不参与健康分计算"` // 平均延迟(毫秒)= 该渠道各模型 lat_ewma 均值,仅统计有真实上报的模型;仅展示用,不参与健康分计算 + StabilityScore float64 `json:"stability_score" orm:"stability_score" description:"【已废弃】稳定性评分,健康体系重写后不再写入,保留列仅为兼容历史数据"` // 【已废弃】稳定性评分,健康体系重写后不再写入,保留列仅为兼容历史数据 + ConsecutiveFailures int `json:"consecutive_failures" orm:"consecutive_failures" description:"【已废弃】连续失败次数,已由 Redis 熔断器的滑动窗口计数取代(dispatch:v1:breaker:*),保留列仅为兼容历史数据"` // 【已废弃】连续失败次数,已由 Redis 熔断器的滑动窗口计数取代(dispatch:v1:breaker:*),保留列仅为兼容历史数据 + HealthScore float64 `json:"health_score" orm:"health_score" description:"综合健康度(0-100)= avg(succ_ewma)^α × 100,α 取路由策略 health.alpha(默认 2),与调度 healthFactor 同源;每 5 分钟由维护任务聚合落盘,另可由渠道测试/重置健康度即时触发;Redis 读失败或全部模型无真实上报时保留旧值不覆盖。调度决策不读此表,仅供管理后台展示"` // 综合健康度(0-100)= avg(succ_ewma)^α × 100,α 取路由策略 health.alpha(默认 2),与调度 healthFactor 同源;每 5 分钟由维护任务聚合落盘,另可由渠道测试/重置健康度即时触发;Redis 读失败或全部模型无真实上报时保留旧值不覆盖。调度决策不读此表,仅供管理后台展示 + CalculatedAt *gtime.Time `json:"calculated_at" orm:"calculated_at" description:"最近一次聚合落盘时间"` // 最近一次聚合落盘时间 + CreatedAt *gtime.Time `json:"created_at" orm:"created_at" description:"创建时间"` // 创建时间 + UpdatedAt *gtime.Time `json:"updated_at" orm:"updated_at" description:"更新时间"` // 更新时间 } diff --git a/internal/model/entity/chn_health_snapshots.go b/internal/model/entity/chn_health_snapshots.go index 5ddd15a..97b9e63 100644 --- a/internal/model/entity/chn_health_snapshots.go +++ b/internal/model/entity/chn_health_snapshots.go @@ -10,12 +10,12 @@ import ( // ChnHealthSnapshots is the golang structure for table chn_health_snapshots. type ChnHealthSnapshots struct { - Id int64 `json:"id" orm:"id" description:"主键ID"` // 主键ID - ChannelId int64 `json:"channel_id" orm:"channel_id" description:"关联渠道ID"` // 关联渠道ID - HealthScore float64 `json:"health_score" orm:"health_score" description:"综合健康度(0-100)"` // 综合健康度(0-100) - SuccessRate float64 `json:"success_rate" orm:"success_rate" description:"请求成功率(0-100)"` // 请求成功率(0-100) - LatencyMs float64 `json:"latency_ms" orm:"latency_ms" description:"平均延迟(毫秒)"` // 平均延迟(毫秒) - StabilityScore float64 `json:"stability_score" orm:"stability_score" description:"稳定性评分(0-100)"` // 稳定性评分(0-100) - ConsecutiveFailures int `json:"consecutive_failures" orm:"consecutive_failures" description:"连续失败次数"` // 连续失败次数 - SnapshotAt *gtime.Time `json:"snapshot_at" orm:"snapshot_at" description:"快照时间"` // 快照时间 + Id int64 `json:"id" orm:"id" description:"主键ID"` // 主键ID + ChannelId int64 `json:"channel_id" orm:"channel_id" description:"关联渠道ID"` // 关联渠道ID + HealthScore float64 `json:"health_score" orm:"health_score" description:"综合健康度(0-100)快照,取自 chn_health_scores.health_score"` // 综合健康度(0-100)快照,取自 chn_health_scores.health_score + SuccessRate float64 `json:"success_rate" orm:"success_rate" description:"请求成功率(0-100)"` // 请求成功率(0-100) + LatencyMs float64 `json:"latency_ms" orm:"latency_ms" description:"平均延迟(毫秒)"` // 平均延迟(毫秒) + StabilityScore float64 `json:"stability_score" orm:"stability_score" description:"【已废弃】稳定性评分,不再写入,新快照为 0"` // 【已废弃】稳定性评分,不再写入,新快照为 0 + ConsecutiveFailures int `json:"consecutive_failures" orm:"consecutive_failures" description:"【已废弃】连续失败次数,不再写入,新快照为 0"` // 【已废弃】连续失败次数,不再写入,新快照为 0 + SnapshotAt *gtime.Time `json:"snapshot_at" orm:"snapshot_at" description:"快照时间"` // 快照时间 }