feat:add batch-task trigger_type

#337
This commit is contained in:
samwaf
2025-06-03 11:05:58 +08:00
parent f31a0bf09d
commit a0da4c2e77
4 changed files with 13 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ type BatchTask struct {
BatchType string `json:"batch_type"` //任务类型
BatchHostCode string `json:"batch_host_code"` //网站唯一码 是否绑定到某个主机上
BatchSourceType string `json:"batch_source_type"` //来源类型(local,url)
BatchTriggerType string `json:"batch_trigger_type"` //触发类型 定时任务 cron ,手动任务 manual
BatchSource string `json:"batch_source"` //来源内容 路径或者实际的url内容
BatchExecuteMethod string `json:"batch_execute_method"` //任务执行方式 追加,覆盖
Remark string `json:"remark"` //备注

View File

@@ -7,6 +7,7 @@ type BatchTaskAddReq struct {
BatchType string `json:"batch_type"` //任务类型
BatchHostCode string `json:"batch_host_code"` //网站唯一码 是否绑定到某个主机上
BatchSourceType string `json:"batch_source_type"` //来源类型(local,url)
BatchTriggerType string `json:"batch_trigger_type"` //触发类型 定时任务 cron ,手动任务 manual
BatchSource string `json:"batch_source"` //来源内容 路径或者实际的url内容
BatchExecuteMethod string `json:"batch_execute_method"` //任务执行方式 追加,覆盖
Remark string `json:"remark"` //备注
@@ -17,6 +18,7 @@ type BatchTaskEditReq struct {
BatchType string `json:"batch_type"` //任务类型
BatchHostCode string `json:"batch_host_code"` //网站唯一码 是否绑定到某个主机上
BatchSourceType string `json:"batch_source_type"` //来源类型(local,url)
BatchTriggerType string `json:"batch_trigger_type"` //触发类型 默认定时任务 cron ,手动任务 manual
BatchSource string `json:"batch_source"` //来源内容 路径或者实际的url内容
BatchExecuteMethod string `json:"batch_execute_method"` //任务执行方式 追加,覆盖
Remark string `json:"remark"` //备注

View File

@@ -35,6 +35,7 @@ func (receiver *WafBatchTaskService) AddApi(req request.BatchTaskAddReq) error {
BatchExecuteMethod: req.BatchExecuteMethod,
BatchSource: req.BatchSource,
BatchSourceType: req.BatchSourceType,
BatchTriggerType: req.BatchTriggerType,
BatchType: req.BatchType,
Remark: req.Remark,
}
@@ -60,6 +61,7 @@ func (receiver *WafBatchTaskService) ModifyApi(req request.BatchTaskEditReq) err
"BatchExecuteMethod": req.BatchExecuteMethod,
"BatchSource": req.BatchSource,
"BatchSourceType": req.BatchSourceType,
"BatchTriggerType": req.BatchTriggerType,
"BatchType": req.BatchType,
"Remark": req.Remark,
}

View File

@@ -169,6 +169,14 @@ func pathCoreSql(db *gorm.DB) {
}
}
//20250603 批量任务执行策略
err = db.Exec("UPDATE batch_tasks SET batch_trigger_type='cron' WHERE batch_trigger_type IS NULL").Error
if err != nil {
panic("failed to batch_tasks: batch_trigger_type " + err.Error())
} else {
zlog.Info("db", "batch_tasks: batch_trigger_type init successfully")
}
// 记录结束时间并计算耗时
duration := time.Since(startTime)
zlog.Info("create core default value completely", "duration", duration.String())