From 8509b295416f373237eba3a1a21fa8a9bdb95950 Mon Sep 17 00:00:00 2001 From: Namju Kim Date: Thu, 30 May 2024 19:42:46 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=ED=91=B8=EB=93=9C=ED=8A=B8=EB=9F=AD=20?= =?UTF-8?q?=EB=A7=A4=EB=8B=88=EC=A0=80=EC=9A=A9=20-=20=EB=82=B4=20?= =?UTF-8?q?=ED=91=B8=EB=93=9C=ED=8A=B8=EB=9F=AD=20=EC=B0=BE=EA=B8=B0=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FoodTruckRestController.kt | 22 +++++++++++++++++++ .../food_truck/service/FoodTruckService.java | 6 +++++ 2 files changed, 28 insertions(+) diff --git a/src/main/java/ac/kr/deu/connect/luck/food_truck/controller/FoodTruckRestController.kt b/src/main/java/ac/kr/deu/connect/luck/food_truck/controller/FoodTruckRestController.kt index d8f56f1..db1bf2e 100644 --- a/src/main/java/ac/kr/deu/connect/luck/food_truck/controller/FoodTruckRestController.kt +++ b/src/main/java/ac/kr/deu/connect/luck/food_truck/controller/FoodTruckRestController.kt @@ -120,4 +120,26 @@ class FoodTruckRestController( foodTruckService.deleteFoodTruck(id) return ResponseEntity.noContent().build() } + + @Operation( + summary = "내 푸드트럭 정보를 조회합니다.", description = "내 푸드트럭 정보를 조회합니다." + ) + @ApiResponses( + value = [ + ApiResponse( + responseCode = "200", + description = "내 푸드트럭 정보 조회 성공", + content = [Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = Schema(implementation = FoodTruckDetailResponse::class))] + ), + ApiResponse( + responseCode = "403", + description = "내 푸드트럭 정보 조회 실패 (권한 없음)", + content = [Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = Schema(implementation = CustomErrorResponse::class))] + ) + ] + ) + @GetMapping("/my") + fun getMyFoodTruck(principal: Principal): ResponseEntity> { + return ResponseEntity.ok(foodTruckService.getMyFoodTrucksForApi(principal.name)); + } } diff --git a/src/main/java/ac/kr/deu/connect/luck/food_truck/service/FoodTruckService.java b/src/main/java/ac/kr/deu/connect/luck/food_truck/service/FoodTruckService.java index 63b7570..39beb4e 100644 --- a/src/main/java/ac/kr/deu/connect/luck/food_truck/service/FoodTruckService.java +++ b/src/main/java/ac/kr/deu/connect/luck/food_truck/service/FoodTruckService.java @@ -136,6 +136,12 @@ public List getMyFoodTrucks(String userEmail) { return foodTruckRepository.findAllByManagerEmail(userEmail); } + public List getMyFoodTrucksForApi(String userEmail) { + return foodTruckRepository.findAllByManagerEmail(userEmail).stream() + .map(foodTruckMapper::toFoodTruckDetailResponse) + .toList(); + } + /** * 푸드트럭 매니저인지 확인합니다. * 푸드트럭 매니저가 아닌 경우 예외를 발생시킵니다.