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:
@@ -39,23 +39,27 @@ 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, "至少需要配置一种检查间隔")
|
||||
}
|
||||
|
||||
config := &model.PollingConfig{
|
||||
ConfigName: req.ConfigName,
|
||||
CardCondition: req.CardCondition,
|
||||
CardCategory: req.CardCategory,
|
||||
CarrierID: req.CarrierID,
|
||||
Priority: req.Priority,
|
||||
RealnameCheckInterval: req.RealnameCheckInterval,
|
||||
CarddataCheckInterval: req.CarddataCheckInterval,
|
||||
PackageCheckInterval: req.PackageCheckInterval,
|
||||
Status: 1, // 默认启用
|
||||
Description: req.Description,
|
||||
CreatedBy: ¤tUserID,
|
||||
UpdatedBy: ¤tUserID,
|
||||
ConfigName: req.ConfigName,
|
||||
CardCondition: req.CardCondition,
|
||||
CardCategory: req.CardCategory,
|
||||
CarrierID: req.CarrierID,
|
||||
Priority: req.Priority,
|
||||
RealnameCheckInterval: req.RealnameCheckInterval,
|
||||
CarddataCheckInterval: req.CarddataCheckInterval,
|
||||
PackageCheckInterval: req.PackageCheckInterval,
|
||||
ProtectCheckInterval: req.ProtectCheckInterval,
|
||||
CardStatusCheckInterval: req.CardStatusCheckInterval,
|
||||
Status: 1,
|
||||
Description: req.Description,
|
||||
CreatedBy: ¤tUserID,
|
||||
UpdatedBy: ¤tUserID,
|
||||
}
|
||||
|
||||
if err := s.configStore.Create(ctx, config); err != nil {
|
||||
@@ -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
|
||||
}
|
||||
@@ -235,18 +245,20 @@ func (s *ConfigService) ListEnabled(ctx context.Context) ([]*dto.PollingConfigRe
|
||||
// toResponse 转换为响应 DTO
|
||||
func (s *ConfigService) toResponse(c *model.PollingConfig) *dto.PollingConfigResponse {
|
||||
return &dto.PollingConfigResponse{
|
||||
ID: c.ID,
|
||||
ConfigName: c.ConfigName,
|
||||
CardCondition: c.CardCondition,
|
||||
CardCategory: c.CardCategory,
|
||||
CarrierID: c.CarrierID,
|
||||
Priority: c.Priority,
|
||||
RealnameCheckInterval: c.RealnameCheckInterval,
|
||||
CarddataCheckInterval: c.CarddataCheckInterval,
|
||||
PackageCheckInterval: c.PackageCheckInterval,
|
||||
Status: c.Status,
|
||||
Description: c.Description,
|
||||
CreatedAt: c.CreatedAt.Format(time.RFC3339),
|
||||
UpdatedAt: c.UpdatedAt.Format(time.RFC3339),
|
||||
ID: c.ID,
|
||||
ConfigName: c.ConfigName,
|
||||
CardCondition: c.CardCondition,
|
||||
CardCategory: c.CardCategory,
|
||||
CarrierID: c.CarrierID,
|
||||
Priority: c.Priority,
|
||||
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),
|
||||
UpdatedAt: c.UpdatedAt.Format(time.RFC3339),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user