Kaynağa Gözat

调整任务状态修改的接口,支持调整任务为 waitting 或者 ignore

Signed-off-by: allan716 <[email protected]>
allan716 3 yıl önce
ebeveyn
işleme
8da5b7cb8b

+ 6 - 1
internal/backend/controllers/v1/jobs_things.go

@@ -75,7 +75,12 @@ func (cb ControllerBase) ChangeJobStatusHandler(c *gin.Context) {
 		// low
 		nowOneJob.TaskPriority = task_queue2.LowTaskPriorityLevel
 	}
-	nowOneJob.JobStatus = task_queue.Waiting
+	// 默认只能把任务改变为这两种状态
+	if desJobStatus.JobStatus == task_queue.Waiting || desJobStatus.JobStatus == task_queue.Ignore {
+		nowOneJob.JobStatus = desJobStatus.JobStatus
+	} else {
+		nowOneJob.JobStatus = task_queue.Waiting
+	}
 
 	bok, err = cb.cronHelper.DownloadQueue.Update(nowOneJob)
 	if err != nil {

+ 5 - 2
internal/types/backend/req_change_job_status.go

@@ -1,6 +1,9 @@
 package backend
 
+import "github.com/allanpk716/ChineseSubFinder/internal/types/task_queue"
+
 type ReqChangeJobStatus struct {
-	Id           string `json:"id"`                           // 任务的唯一 ID
-	TaskPriority string `json:"task_priority" default:"high"` // 任务的优先级,high or middle or low priority
+	Id           string               `json:"id"`                           // 任务的唯一 ID
+	TaskPriority string               `json:"task_priority" default:"high"` // 任务的优先级,high or middle or low priority
+	JobStatus    task_queue.JobStatus `json:"job_status"`                   // 任务的状态 允许设置 Waiting(0) or Ignore(5)
 }