CheckImageGenerationTasksCommand.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Services\AiImageGenerationService;
  4. use Illuminate\Console\Command;
  5. class CheckImageGenerationTasksCommand extends Command
  6. {
  7. /**
  8. * The name and signature of the console command.
  9. *
  10. * @var string
  11. */
  12. protected $signature = 'image-generation:check-tasks';
  13. /**
  14. * The console command description.
  15. *
  16. * @var string
  17. */
  18. protected $description = '检查图片生成任务状态并更新';
  19. /**
  20. * Execute the console command.
  21. *
  22. * @param AiImageGenerationService $aiImageGenerationService
  23. * @return int
  24. */
  25. public function handle(AiImageGenerationService $aiImageGenerationService)
  26. {
  27. $this->info('开始检查图片生成任务状态...');
  28. try {
  29. $aiImageGenerationService->updatePendingTasks();
  30. $this->info('任务状态检查完成');
  31. } catch (\Exception $e) {
  32. $this->error('任务状态检查失败: ' . $e->getMessage());
  33. return 1;
  34. }
  35. return 0;
  36. }
  37. }