feat(通道流量阈值): AUG26-011 运营商通道流量阈值达量停机与周期复机
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 12m59s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 12m59s
This commit is contained in:
@@ -15,6 +15,13 @@ type Carrier struct {
|
||||
RealnameLinkType string `gorm:"column:realname_link_type;type:varchar(20);not null;default:'none';comment:实名链接类型 none-不支持 template-模板URL gateway-Gateway接口" json:"realname_link_type"`
|
||||
RealnameLinkTemplate string `gorm:"column:realname_link_template;type:varchar(500);default:'';comment:实名链接模板URL" json:"realname_link_template"`
|
||||
DataResetDay int `gorm:"column:data_reset_day;type:int;not null;default:1;comment:上游流量重置日(1-28) 运营商每月清零网关计数器的日期" json:"data_reset_day"`
|
||||
// TrafficThresholdEnabled 是通道流量阈值开关,取值 0-未启用 1-已启用(ENG-STATE-001 启停语义)。
|
||||
// 未启用时达量判定直接跳过;停用只停止后续新锁创建,不删除既有锁与历史任务结果。
|
||||
TrafficThresholdEnabled int `gorm:"column:traffic_threshold_enabled;type:smallint;not null;default:0;comment:通道流量阈值是否启用 0-未启用 1-已启用" json:"traffic_threshold_enabled"`
|
||||
// TrafficThresholdValue 是阈值数值,单位由 TrafficThresholdUnit 决定,必须为正数;NULL 表示未配置。
|
||||
TrafficThresholdValue *float64 `gorm:"column:traffic_threshold_value;type:numeric(18,2);comment:通道流量阈值数值,单位由 traffic_threshold_unit 决定" json:"traffic_threshold_value"`
|
||||
// TrafficThresholdUnit 是阈值单位,取值 MB/GB(1 GB = 1024 MB),换算后与网关累计读数同单位比较;空字符串表示未配置。
|
||||
TrafficThresholdUnit string `gorm:"column:traffic_threshold_unit;type:varchar(8);not null;default:'';comment:通道流量阈值单位 MB/GB,空字符串-未配置" json:"traffic_threshold_unit"`
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
|
||||
38
internal/model/carrier_traffic_threshold_lock.go
Normal file
38
internal/model/carrier_traffic_threshold_lock.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// CarrierTrafficThresholdLock 是「卡在某运营商计费周期内已触发通道流量阈值停机」的持久化事实。
|
||||
//
|
||||
// 一行表达一个 (carrier_id, card_id, period_start) 组合,由部分唯一索引保证至多一条:
|
||||
// Status 表达整行生命周期(locked 进行中 / unlocked 已跨期解锁);StopStatus 与 ResumeStatus
|
||||
// 分别表达停机与复机两个子任务;StopSubmittedAt/ResumeSubmittedAt 是提交认领字段,
|
||||
// 由消费者以「字段为 NULL」条件更新取得至多一次的外部调用权;AnomalyFlag 与 FailureReason
|
||||
// 承载查询窗口超期等需人工核对的结果。周期起点按触发时该运营商的 data_reset_day 计算,
|
||||
// 换运营商后旧周期锁保留、新周期按新运营商的重置日另建一行。
|
||||
type CarrierTrafficThresholdLock struct {
|
||||
gorm.Model
|
||||
CarrierID uint `gorm:"column:carrier_id;type:bigint;not null" json:"carrier_id"`
|
||||
CardID uint `gorm:"column:card_id;type:bigint;not null" json:"card_id"`
|
||||
PeriodStart time.Time `gorm:"column:period_start;type:timestamptz;not null" json:"period_start"`
|
||||
Status string `gorm:"column:status;type:varchar(16);not null;default:'locked'" json:"status"`
|
||||
StopStatus string `gorm:"column:stop_status;type:varchar(16);not null;default:'pending'" json:"stop_status"`
|
||||
ResumeStatus string `gorm:"column:resume_status;type:varchar(16);not null;default:'pending'" json:"resume_status"`
|
||||
StopSubmittedAt *time.Time `gorm:"column:stop_submitted_at;type:timestamptz" json:"stop_submitted_at,omitempty"`
|
||||
ResumeSubmittedAt *time.Time `gorm:"column:resume_submitted_at;type:timestamptz" json:"resume_submitted_at,omitempty"`
|
||||
StopIntegrationID string `gorm:"column:stop_integration_id;type:varchar(64);not null;default:''" json:"stop_integration_id"`
|
||||
// ResumeIntegrationID 记录复机 Gateway 调用的 Integration Log 标识,便于人工核对。
|
||||
ResumeIntegrationID string `gorm:"column:resume_integration_id;type:varchar(64);not null;default:''" json:"resume_integration_id"`
|
||||
// AnomalyFlag 为 1 表示查询窗口超期或失败无法自动确认,必须退出自动扫描转人工核对。
|
||||
AnomalyFlag int `gorm:"column:anomaly_flag;type:smallint;not null;default:0" json:"anomaly_flag"`
|
||||
FailureReason string `gorm:"column:failure_reason;type:varchar(500);not null;default:''" json:"failure_reason"`
|
||||
}
|
||||
|
||||
// TableName 指定运营商通道流量阈值周期锁表名。
|
||||
func (CarrierTrafficThresholdLock) TableName() string {
|
||||
return "tb_carrier_traffic_threshold_lock"
|
||||
}
|
||||
@@ -1,21 +1,45 @@
|
||||
package dto
|
||||
|
||||
type CreateCarrierRequest struct {
|
||||
CarrierCode string `json:"carrier_code" validate:"required,min=1,max=50" required:"true" minLength:"1" maxLength:"50" description:"运营商编码"`
|
||||
CarrierName string `json:"carrier_name" validate:"required,min=1,max=100" required:"true" minLength:"1" maxLength:"100" description:"运营商名称"`
|
||||
CarrierType string `json:"carrier_type" validate:"required,oneof=CMCC CUCC CTCC CBN" required:"true" description:"运营商类型 (CMCC:中国移动, CUCC:中国联通, CTCC:中国电信, CBN:中国广电)"`
|
||||
Description string `json:"description" validate:"omitempty,max=500" maxLength:"500" description:"运营商描述"`
|
||||
DataResetDay *int `json:"data_reset_day" validate:"omitempty,min=1,max=28" minimum:"1" maximum:"28" description:"上游流量重置日(1-28),运营商每月清零网关计数器的日期,默认1"`
|
||||
RealnameLinkType *string `json:"realname_link_type" validate:"omitempty,oneof=none template gateway" description:"实名链接类型 none-不支持 template-模板URL gateway-Gateway接口"`
|
||||
RealnameLinkTemplate *string `json:"realname_link_template" validate:"omitempty,max=500" maxLength:"500" description:"实名链接模板URL,支持 {iccid}/{msisdn}/{virtual_no} 占位符"`
|
||||
CarrierCode string `json:"carrier_code" validate:"required,min=1,max=50" required:"true" minLength:"1" maxLength:"50" description:"运营商编码"`
|
||||
CarrierName string `json:"carrier_name" validate:"required,min=1,max=100" required:"true" minLength:"1" maxLength:"100" description:"运营商名称"`
|
||||
CarrierType string `json:"carrier_type" validate:"required,oneof=CMCC CUCC CTCC CBN" required:"true" description:"运营商类型 (CMCC:中国移动, CUCC:中国联通, CTCC:中国电信, CBN:中国广电)"`
|
||||
Description string `json:"description" validate:"omitempty,max=500" maxLength:"500" description:"运营商描述"`
|
||||
DataResetDay *int `json:"data_reset_day" validate:"omitempty,min=1,max=28" minimum:"1" maximum:"28" description:"上游流量重置日(1-28),运营商每月清零网关计数器的日期,默认1"`
|
||||
RealnameLinkType *string `json:"realname_link_type" validate:"omitempty,oneof=none template gateway" description:"实名链接类型 none-不支持 template-模板URL gateway-Gateway接口"`
|
||||
RealnameLinkTemplate *string `json:"realname_link_template" validate:"omitempty,max=500" maxLength:"500" description:"实名链接模板URL,支持 {iccid}/{msisdn}/{virtual_no} 占位符"`
|
||||
TrafficThresholdEnabled *int `json:"traffic_threshold_enabled" validate:"omitempty,oneof=0 1" description:"通道流量阈值是否启用 (0:禁用, 1:启用),仅超级管理员与平台账号可配置"`
|
||||
TrafficThresholdValue *float64 `json:"traffic_threshold_value" validate:"omitempty,gt=0" description:"通道流量阈值数值,必须为正数,单位由 traffic_threshold_unit 决定,仅超级管理员与平台账号可配置"`
|
||||
TrafficThresholdUnit *string `json:"traffic_threshold_unit" validate:"omitempty,oneof=MB GB" description:"通道流量阈值单位 (MB:兆字节, GB:吉字节,1 GB = 1024 MB),仅超级管理员与平台账号可配置"`
|
||||
}
|
||||
|
||||
// HasTrafficThresholdFields 判断请求是否携带通道流量阈值字段。
|
||||
// 非超管、非平台账号提交携带阈值字段的请求必须被整体拒绝。
|
||||
func (r *CreateCarrierRequest) HasTrafficThresholdFields() bool {
|
||||
if r == nil {
|
||||
return false
|
||||
}
|
||||
return r.TrafficThresholdEnabled != nil || r.TrafficThresholdValue != nil || r.TrafficThresholdUnit != nil
|
||||
}
|
||||
|
||||
type UpdateCarrierRequest struct {
|
||||
CarrierName *string `json:"carrier_name" validate:"omitempty,min=1,max=100" minLength:"1" maxLength:"100" description:"运营商名称"`
|
||||
Description *string `json:"description" validate:"omitempty,max=500" maxLength:"500" description:"运营商描述"`
|
||||
DataResetDay *int `json:"data_reset_day" validate:"omitempty,min=1,max=28" minimum:"1" maximum:"28" description:"上游流量重置日(1-28),运营商每月清零网关计数器的日期"`
|
||||
RealnameLinkType *string `json:"realname_link_type" validate:"omitempty,oneof=none template gateway" description:"实名链接类型 none-不支持 template-模板URL gateway-Gateway接口"`
|
||||
RealnameLinkTemplate *string `json:"realname_link_template" validate:"omitempty,max=500" maxLength:"500" description:"实名链接模板URL,支持 {iccid}/{msisdn}/{virtual_no} 占位符"`
|
||||
CarrierName *string `json:"carrier_name" validate:"omitempty,min=1,max=100" minLength:"1" maxLength:"100" description:"运营商名称"`
|
||||
Description *string `json:"description" validate:"omitempty,max=500" maxLength:"500" description:"运营商描述"`
|
||||
DataResetDay *int `json:"data_reset_day" validate:"omitempty,min=1,max=28" minimum:"1" maximum:"28" description:"上游流量重置日(1-28),运营商每月清零网关计数器的日期"`
|
||||
RealnameLinkType *string `json:"realname_link_type" validate:"omitempty,oneof=none template gateway" description:"实名链接类型 none-不支持 template-模板URL gateway-Gateway接口"`
|
||||
RealnameLinkTemplate *string `json:"realname_link_template" validate:"omitempty,max=500" maxLength:"500" description:"实名链接模板URL,支持 {iccid}/{msisdn}/{virtual_no} 占位符"`
|
||||
TrafficThresholdEnabled *int `json:"traffic_threshold_enabled" validate:"omitempty,oneof=0 1" description:"通道流量阈值是否启用 (0:禁用, 1:启用),仅超级管理员与平台账号可配置"`
|
||||
TrafficThresholdValue *float64 `json:"traffic_threshold_value" validate:"omitempty,gt=0" description:"通道流量阈值数值,必须为正数,单位由 traffic_threshold_unit 决定,仅超级管理员与平台账号可配置"`
|
||||
TrafficThresholdUnit *string `json:"traffic_threshold_unit" validate:"omitempty,oneof=MB GB" description:"通道流量阈值单位 (MB:兆字节, GB:吉字节,1 GB = 1024 MB),仅超级管理员与平台账号可配置"`
|
||||
}
|
||||
|
||||
// HasTrafficThresholdFields 判断请求是否携带通道流量阈值字段。
|
||||
// 非超管、非平台账号提交携带阈值字段的请求必须被整体拒绝。
|
||||
func (r *UpdateCarrierRequest) HasTrafficThresholdFields() bool {
|
||||
if r == nil {
|
||||
return false
|
||||
}
|
||||
return r.TrafficThresholdEnabled != nil || r.TrafficThresholdValue != nil || r.TrafficThresholdUnit != nil
|
||||
}
|
||||
|
||||
type CarrierListRequest struct {
|
||||
@@ -40,8 +64,12 @@ type CarrierResponse struct {
|
||||
RealnameLinkType string `json:"realname_link_type" description:"实名链接类型 none-不支持 template-模板URL gateway-Gateway接口"`
|
||||
RealnameLinkTemplate string `json:"realname_link_template" description:"实名链接模板URL"`
|
||||
Status int `json:"status" description:"状态 (1:启用, 0:禁用)"`
|
||||
CreatedAt string `json:"created_at" description:"创建时间"`
|
||||
UpdatedAt string `json:"updated_at" description:"更新时间"`
|
||||
// 阈值字段仅对超级管理员与平台账号返回;其他账号响应中不出现这三个字段。
|
||||
TrafficThresholdEnabled *int `json:"traffic_threshold_enabled,omitempty" description:"通道流量阈值是否启用 (0:禁用, 1:启用),仅超级管理员与平台账号可见"`
|
||||
TrafficThresholdValue *float64 `json:"traffic_threshold_value,omitempty" description:"通道流量阈值数值,单位由 traffic_threshold_unit 决定,未配置时不返回,仅超级管理员与平台账号可见"`
|
||||
TrafficThresholdUnit *string `json:"traffic_threshold_unit,omitempty" description:"通道流量阈值单位 (MB:兆字节, GB:吉字节,1 GB = 1024 MB),未配置时不返回,仅超级管理员与平台账号可见"`
|
||||
CreatedAt string `json:"created_at" description:"创建时间"`
|
||||
UpdatedAt string `json:"updated_at" description:"更新时间"`
|
||||
}
|
||||
|
||||
type UpdateCarrierParams struct {
|
||||
|
||||
Reference in New Issue
Block a user