|
@@ -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 + '')
|