<?php

namespace Kylin\LawCase\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

/**
 * 文档生成 Job
 *
 * 异步生成法律文书。
 */
class GenerateDocument implements ShouldQueue
{
    use InteractsWithQueue, Queueable;

    public int $tries = 3;
    public int $timeout = 120;

    public function __construct(
        public int $templateId,
        public int $caseId,
        public array $variables = []
    ) {}

    public function handle(): void
    {
        $documentService = app(\Kylin\LawCase\Services\DocumentService::class);
        $documentService->generateFromTemplate($this->templateId, $this->caseId, $this->variables);
    }
}
