diff --git a/const.go b/const.go index 9ce836e..78f271d 100644 --- a/const.go +++ b/const.go @@ -1,3 +1,3 @@ package gojobs -const Version = "1.0.67" +const Version = "1.0.68" diff --git a/jobs_gorm_model.go b/jobs_gorm_model.go index 3fd6dbf..2eb4334 100644 --- a/jobs_gorm_model.go +++ b/jobs_gorm_model.go @@ -124,6 +124,29 @@ func (j *JobsGorm) TaskFindAllWait(tx *gorm.DB, frequency int64) []jobs_gorm_mod return j.taskFindAll(tx, frequency, TASK_WAIT) } +// StartTask 任务启动 +func (j *JobsGorm) StartTask(tx *gorm.DB, id uint) error { + return j.EditTask(tx, id). + Select("status", "status_desc"). + Updates(jobs_gorm_model.Task{ + Status: TASK_IN, + StatusDesc: "启动任务", + }).Error +} + +// StartTaskCustom 任务启动自定义 +func (j *JobsGorm) StartTaskCustom(tx *gorm.DB, customId string, customSequence int64) error { + return tx.Model(&jobs_gorm_model.Task{}). + Where("custom_id = ?", customId). + Where("custom_sequence = ?", customSequence). + Where("status = ?", TASK_WAIT). + Select("status", "status_desc"). + Updates(jobs_gorm_model.Task{ + Status: TASK_IN, + StatusDesc: "启动任务", + }).Error +} + // EditTask 任务修改 func (j *JobsGorm) EditTask(tx *gorm.DB, id uint) *gorm.DB { return tx.Model(&jobs_gorm_model.Task{}).Where("id = ?", id)