feat: [document] 검사 템플릿 섹션에 image_url(presigned URL) 추가
- DocumentService: 섹션 데이터에 image_url 반환 - QmsLotAuditService: 동일하게 image_url 반환 - file_id 또는 image_path 기반으로 R2 presigned URL 생성
This commit is contained in:
@@ -977,12 +977,22 @@ public function formatTemplateForReact(DocumentTemplate $template): array
|
||||
'is_required' => $field->is_required,
|
||||
'sort_order' => $field->sort_order,
|
||||
])->toArray(),
|
||||
'sections' => $template->sections->map(fn ($section) => [
|
||||
'sections' => $template->sections->map(function ($section) {
|
||||
$imageUrl = null;
|
||||
if ($section->file_id) {
|
||||
$file = \App\Models\Commons\File::withoutGlobalScopes()->find($section->file_id);
|
||||
$imageUrl = $file?->presignedUrl();
|
||||
} elseif ($section->image_path) {
|
||||
$imageUrl = \Illuminate\Support\Facades\Storage::disk('r2')->temporaryUrl($section->image_path, now()->addMinutes(30));
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $section->id,
|
||||
'name' => $section->title,
|
||||
'title' => $section->title,
|
||||
'image_path' => $section->image_path,
|
||||
'file_id' => $section->file_id,
|
||||
'image_url' => $imageUrl,
|
||||
'sort_order' => $section->sort_order,
|
||||
'items' => $section->items->map(function ($item) use ($methodCodes) {
|
||||
// method 코드를 한글 이름으로 변환
|
||||
@@ -1007,7 +1017,8 @@ public function formatTemplateForReact(DocumentTemplate $template): array
|
||||
'sort_order' => $item->sort_order,
|
||||
];
|
||||
})->toArray(),
|
||||
])->toArray(),
|
||||
];
|
||||
})->toArray(),
|
||||
'columns' => $template->columns->map(fn ($col) => [
|
||||
'id' => $col->id,
|
||||
'label' => $col->label,
|
||||
|
||||
@@ -787,12 +787,23 @@ private function formatFqcTemplate($template): ?array
|
||||
'is_required' => $f->is_required,
|
||||
'sort_order' => $f->sort_order,
|
||||
])->all(),
|
||||
'sections' => $template->sections->map(fn ($s) => [
|
||||
'sections' => $template->sections->map(function ($s) {
|
||||
$imageUrl = null;
|
||||
if ($s->file_id) {
|
||||
$file = \App\Models\Commons\File::withoutGlobalScopes()->find($s->file_id);
|
||||
$imageUrl = $file?->presignedUrl();
|
||||
} elseif ($s->image_path) {
|
||||
$imageUrl = \Illuminate\Support\Facades\Storage::disk('r2')->temporaryUrl($s->image_path, now()->addMinutes(30));
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $s->id,
|
||||
'name' => $s->name,
|
||||
'title' => $s->title,
|
||||
'description' => $s->description,
|
||||
'image_path' => $s->image_path,
|
||||
'file_id' => $s->file_id,
|
||||
'image_url' => $imageUrl,
|
||||
'sort_order' => $s->sort_order,
|
||||
'items' => $s->items->map(fn ($i) => [
|
||||
'id' => $i->id,
|
||||
@@ -806,7 +817,8 @@ private function formatFqcTemplate($template): ?array
|
||||
'category' => $i->category,
|
||||
'method' => $i->method,
|
||||
])->all(),
|
||||
])->all(),
|
||||
];
|
||||
})->all(),
|
||||
'columns' => $template->columns->map(fn ($c) => [
|
||||
'id' => $c->id,
|
||||
'label' => $c->label,
|
||||
|
||||
Reference in New Issue
Block a user