feat: PollingConfig DTO 和 Service 支持卡状态检查间隔
dto: 新增 CardStatusCheckInterval 字段(validate min=30,description 含枚举说明) config_service.go: 创建/更新/响应映射均支持 CardStatusCheckInterval Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -10,6 +10,8 @@ type CreatePollingConfigRequest struct {
|
||||
RealnameCheckInterval *int `json:"realname_check_interval" validate:"omitempty,min=30" minimum:"30" description:"实名检查间隔(秒),NULL表示不检查,最小30秒"`
|
||||
CarddataCheckInterval *int `json:"carddata_check_interval" validate:"omitempty,min=60" minimum:"60" description:"流量检查间隔(秒),NULL表示不检查,最小60秒"`
|
||||
PackageCheckInterval *int `json:"package_check_interval" validate:"omitempty,min=60" minimum:"60" description:"套餐检查间隔(秒),NULL表示不检查,最小60秒"`
|
||||
ProtectCheckInterval *int `json:"protect_check_interval" validate:"omitempty,min=30" minimum:"30" description:"保护期一致性检查间隔(秒),NULL表示不检查,最小30秒"`
|
||||
CardStatusCheckInterval *int `json:"card_status_check_interval" validate:"omitempty,min=30" minimum:"30" description:"卡状态检查间隔(秒),NULL表示不检查,最小30秒"`
|
||||
Description string `json:"description" validate:"omitempty,max=500" maxLength:"500" description:"配置说明"`
|
||||
}
|
||||
|
||||
@@ -23,6 +25,8 @@ type UpdatePollingConfigRequest struct {
|
||||
RealnameCheckInterval *int `json:"realname_check_interval" validate:"omitempty,min=30" minimum:"30" description:"实名检查间隔(秒),NULL表示不检查,最小30秒"`
|
||||
CarddataCheckInterval *int `json:"carddata_check_interval" validate:"omitempty,min=60" minimum:"60" description:"流量检查间隔(秒),NULL表示不检查,最小60秒"`
|
||||
PackageCheckInterval *int `json:"package_check_interval" validate:"omitempty,min=60" minimum:"60" description:"套餐检查间隔(秒),NULL表示不检查,最小60秒"`
|
||||
ProtectCheckInterval *int `json:"protect_check_interval" validate:"omitempty,min=30" minimum:"30" description:"保护期一致性检查间隔(秒),NULL表示不检查,最小30秒"`
|
||||
CardStatusCheckInterval *int `json:"card_status_check_interval" validate:"omitempty,min=30" minimum:"30" description:"卡状态检查间隔(秒),NULL表示不检查,最小30秒"`
|
||||
Description *string `json:"description" validate:"omitempty,max=500" maxLength:"500" description:"配置说明"`
|
||||
}
|
||||
|
||||
@@ -53,6 +57,8 @@ type PollingConfigResponse struct {
|
||||
RealnameCheckInterval *int `json:"realname_check_interval" description:"实名检查间隔(秒),NULL表示不检查"`
|
||||
CarddataCheckInterval *int `json:"carddata_check_interval" description:"流量检查间隔(秒),NULL表示不检查"`
|
||||
PackageCheckInterval *int `json:"package_check_interval" description:"套餐检查间隔(秒),NULL表示不检查"`
|
||||
ProtectCheckInterval *int `json:"protect_check_interval" description:"保护期一致性检查间隔(秒),NULL表示不检查"`
|
||||
CardStatusCheckInterval *int `json:"card_status_check_interval" description:"卡状态检查间隔(秒),NULL表示不检查"`
|
||||
Status int16 `json:"status" description:"状态 (1:启用, 0:禁用)"`
|
||||
Description string `json:"description" description:"配置说明"`
|
||||
CreatedAt string `json:"created_at" description:"创建时间"`
|
||||
|
||||
@@ -39,7 +39,9 @@ func (s *ConfigService) Create(ctx context.Context, req *dto.CreatePollingConfig
|
||||
}
|
||||
|
||||
// 验证检查间隔(至少一个不为空)
|
||||
if req.RealnameCheckInterval == nil && req.CarddataCheckInterval == nil && req.PackageCheckInterval == nil {
|
||||
if req.RealnameCheckInterval == nil && req.CarddataCheckInterval == nil &&
|
||||
req.PackageCheckInterval == nil && req.ProtectCheckInterval == nil &&
|
||||
req.CardStatusCheckInterval == nil {
|
||||
return nil, errors.New(errors.CodeInvalidParam, "至少需要配置一种检查间隔")
|
||||
}
|
||||
|
||||
@@ -52,7 +54,9 @@ func (s *ConfigService) Create(ctx context.Context, req *dto.CreatePollingConfig
|
||||
RealnameCheckInterval: req.RealnameCheckInterval,
|
||||
CarddataCheckInterval: req.CarddataCheckInterval,
|
||||
PackageCheckInterval: req.PackageCheckInterval,
|
||||
Status: 1, // 默认启用
|
||||
ProtectCheckInterval: req.ProtectCheckInterval,
|
||||
CardStatusCheckInterval: req.CardStatusCheckInterval,
|
||||
Status: 1,
|
||||
Description: req.Description,
|
||||
CreatedBy: ¤tUserID,
|
||||
UpdatedBy: ¤tUserID,
|
||||
@@ -122,6 +126,12 @@ func (s *ConfigService) Update(ctx context.Context, id uint, req *dto.UpdatePoll
|
||||
if req.PackageCheckInterval != nil {
|
||||
config.PackageCheckInterval = req.PackageCheckInterval
|
||||
}
|
||||
if req.ProtectCheckInterval != nil {
|
||||
config.ProtectCheckInterval = req.ProtectCheckInterval
|
||||
}
|
||||
if req.CardStatusCheckInterval != nil {
|
||||
config.CardStatusCheckInterval = req.CardStatusCheckInterval
|
||||
}
|
||||
if req.Description != nil {
|
||||
config.Description = *req.Description
|
||||
}
|
||||
@@ -244,6 +254,8 @@ func (s *ConfigService) toResponse(c *model.PollingConfig) *dto.PollingConfigRes
|
||||
RealnameCheckInterval: c.RealnameCheckInterval,
|
||||
CarddataCheckInterval: c.CarddataCheckInterval,
|
||||
PackageCheckInterval: c.PackageCheckInterval,
|
||||
ProtectCheckInterval: c.ProtectCheckInterval,
|
||||
CardStatusCheckInterval: c.CardStatusCheckInterval,
|
||||
Status: c.Status,
|
||||
Description: c.Description,
|
||||
CreatedAt: c.CreatedAt.Format(time.RFC3339),
|
||||
|
||||
Reference in New Issue
Block a user