Skip to content

Commit

Permalink
Feat: 푸드트럭 매니저용 - 내 푸드트럭 찾기 API
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsong111 committed May 30, 2024
1 parent eefc082 commit 8509b29
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<List<FoodTruckDetailResponse>> {
return ResponseEntity.ok(foodTruckService.getMyFoodTrucksForApi(principal.name));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ public List<FoodTruck> getMyFoodTrucks(String userEmail) {
return foodTruckRepository.findAllByManagerEmail(userEmail);
}

public List<FoodTruckDetailResponse> getMyFoodTrucksForApi(String userEmail) {
return foodTruckRepository.findAllByManagerEmail(userEmail).stream()
.map(foodTruckMapper::toFoodTruckDetailResponse)
.toList();
}

/**
* 푸드트럭 매니저인지 확인합니다.
* 푸드트럭 매니저가 아닌 경우 예외를 발생시킵니다.
Expand Down

0 comments on commit 8509b29

Please sign in to comment.