xiongzhu 2 年 前
コミット
3167dc9f56
1 ファイル変更2 行追加2 行削除
  1. 2 2
      src/task/task.service.ts

+ 2 - 2
src/task/task.service.ts

@@ -168,8 +168,8 @@ export class TaskService implements OnModuleInit {
 
 
     async delete(id: number) {
     async delete(id: number) {
         const task = await this.taskRepository.findOneBy({ id })
         const task = await this.taskRepository.findOneBy({ id })
-        if (task.status !== TaskStatus.Pending) {
-            throw new BadRequestException('只能删除未执行任务')
+        if (task.status === TaskStatus.InProgress) {
+            throw new BadRequestException('不能删除正在执行的任务')
         }
         }
         await this.taskRepository.delete(id)
         await this.taskRepository.delete(id)
         const job = this.schedulerRegistry.getCronJob(id + '')
         const job = this.schedulerRegistry.getCronJob(id + '')