From 0d9a8403586b0c38b78adb74adec5a93d4d27fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A0=EB=B3=91=EC=B2=A0?= Date: Thu, 12 Mar 2026 19:21:38 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[equipment-inspection]=20=EC=84=A4?= =?UTF-8?q?=EB=B9=84=EB=B3=84=20=EC=A0=90=EA=B2=80=20=ED=85=9C=ED=94=8C?= =?UTF-8?q?=EB=A6=BF=20=EC=A1=B0=ED=9A=8C=20API=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - templates 엔드포인트에 cycle 필터 파라미터 추가 - getTemplatesByEquipment 서비스 메서드 신규 추가 - Controller에서 Request 주입하여 cycle 쿼리 파라미터 전달 Co-Authored-By: Claude Opus 4.6 --- .../V1/Equipment/EquipmentInspectionController.php | 4 ++-- app/Services/Equipment/EquipmentInspectionService.php | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/V1/Equipment/EquipmentInspectionController.php b/app/Http/Controllers/V1/Equipment/EquipmentInspectionController.php index 7433efe..661d6b9 100644 --- a/app/Http/Controllers/V1/Equipment/EquipmentInspectionController.php +++ b/app/Http/Controllers/V1/Equipment/EquipmentInspectionController.php @@ -84,10 +84,10 @@ public function resetInspection(Request $request): JsonResponse ); } - public function templates(int $id): JsonResponse + public function templates(Request $request, int $id): JsonResponse { return ApiResponse::handle( - fn () => $this->service->getActiveCycles($id), + fn () => $this->service->getTemplatesByEquipment($id, $request->input('cycle')), __('message.fetched') ); } diff --git a/app/Services/Equipment/EquipmentInspectionService.php b/app/Services/Equipment/EquipmentInspectionService.php index ebc5972..e56133e 100644 --- a/app/Services/Equipment/EquipmentInspectionService.php +++ b/app/Services/Equipment/EquipmentInspectionService.php @@ -365,6 +365,15 @@ public function copyTemplates(int $equipmentId, string $sourceCycle, array $targ }); } + public function getTemplatesByEquipment(int $equipmentId, ?string $cycle = null): \Illuminate\Database\Eloquent\Collection + { + return EquipmentInspectionTemplate::where('equipment_id', $equipmentId) + ->when($cycle, fn ($q) => $q->byCycle($cycle)) + ->active() + ->orderBy('sort_order') + ->get(); + } + public function getActiveCycles(int $equipmentId): array { return EquipmentInspectionTemplate::where('equipment_id', $equipmentId)