feat: [문서스냅샷] Lazy Snapshot API - snapshot 엔드포인트 + resolve에 snapshot_document_id 추가

- PATCH /documents/{id}/snapshot: canEdit 체크 없이 rendered_html만 업데이트
- DocumentService::patchSnapshot() 메서드 추가
- WorkOrderService::resolveInspectionDocument()에 snapshot_document_id 반환 (상태 무관, rendered_html NULL인 문서)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 20:59:17 +09:00
parent 5ebf940873
commit c5d5b5d076
4 changed files with 54 additions and 0 deletions

View File

@@ -2431,11 +2431,26 @@ public function resolveInspectionDocument(int $workOrderId, array $params = []):
->latest()
->first();
// Lazy Snapshot 대상: rendered_html이 없는 문서 (상태 무관)
$snapshotDocumentId = null;
$snapshotCandidate = Document::query()
->where('tenant_id', $tenantId)
->where('template_id', $templateId)
->where('linkable_type', 'work_order')
->where('linkable_id', $workOrderId)
->whereNull('rendered_html')
->latest()
->value('id');
if ($snapshotCandidate) {
$snapshotDocumentId = $snapshotCandidate;
}
return [
'work_order_id' => $workOrderId,
'template_id' => $templateId,
'template' => $formattedTemplate,
'existing_document' => $existingDocument,
'snapshot_document_id' => $snapshotDocumentId,
'work_order_info' => $this->buildWorkOrderInfo($workOrder),
];
}