Skip to content

Commit d3c0e37

Browse files
committed
faet: 레스토랑 id로 레스토랑 조회 api 구현
1 parent 0d4b3eb commit d3c0e37

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

src/main/java/com/qithon/clearplate/domain/CLPrestaurant/controller/CLPController.java

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,71 @@ public ResponseEntity<?> getAllRestaurants() {
156156

157157

158158

159+
160+
@ApiResponse(
161+
responseCode = "200",
162+
description = "### ✅ 조회에 성공했을 경우",
163+
content = @Content(
164+
mediaType = "application/json",
165+
schema = @Schema(
166+
example = """
167+
{
168+
"timestamp": "2025-07-12 15:16:54",
169+
"data": {
170+
"id": 93,
171+
"addressName": "경기 성남시 분당구 삼평동 660",
172+
"clpCategory": {
173+
"category_group_code": "FD6",
174+
"category_group_name": "음식점",
175+
"category_name": "음식점 > 일식 > 돈까스,우동"
176+
},
177+
"distance": "",
178+
"restaurantId": "26797370",
179+
"phone": "",
180+
"placeName": "판교매일식당 판교본점",
181+
"placeUrl": "http://place.map.kakao.com/26797370",
182+
"roadAddressName": "경기 성남시 분당구 판교역로192번길 14-2",
183+
"x": "127.11210628616844",
184+
"y": "37.39738062184579",
185+
"imageUrl": null,
186+
"subtitle": "매일 먹어도 질리지 않는 든든한 한 끼"
187+
}
188+
}
189+
"""
190+
)
191+
)
192+
)
193+
@ApiResponse(
194+
responseCode = "400",
195+
description = "--- \n### ❌ 레스토랑 조회에 실패한 경우",
196+
content = @Content(
197+
mediaType = "application/json",
198+
schema = @Schema(
199+
example = """
200+
{
201+
"timestamp": "2025-07-12 15:17:27",
202+
"status": "BAD_REQUEST",
203+
"message": "레스토랑을 찾을 수 없습니다."
204+
}
205+
"""
206+
207+
)
208+
)
209+
)
210+
@Operation(summary = "id 로 CLP 레스토랑을 조회합니다. ", description = "현재 등록된 CLP 레스토랑을 id 로 조회합니다")
211+
@GetMapping("/{restaurantId}")
212+
public ResponseEntity<?> getRestaurantById(@PathVariable String restaurantId) {
213+
try {
214+
CLPRestaurant response = clpService.getRestaurantById(restaurantId);
215+
return ResponseEntity.ok(ResponseDTO.response(response));
216+
} catch (RuntimeException e) {
217+
return ResponseEntity.badRequest()
218+
.body(ResponseDTO.response(HttpStatus.BAD_REQUEST, e.getMessage(), null));
219+
}
220+
}
221+
222+
223+
159224
@ApiResponse(
160225
responseCode = "200",
161226
description = "### ✅ 레스토랑 조회에 성공한 경우",

src/main/java/com/qithon/clearplate/domain/CLPrestaurant/service/CLPService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public List<CLPRestaurantRegisterResponse> registerRestaurantList(
3131
.toList();
3232
}
3333

34+
public CLPRestaurant getRestaurantById(String restauranId) {
35+
return clpRepository.findByRestaurantId(restauranId)
36+
.orElseThrow(() -> new RuntimeException("레스토랑을 찾을 수 없습니다."));
37+
}
38+
3439
public List<CLPRestaurant> getAllRestaurants() throws RuntimeException {
3540
List<CLPRestaurant> clpRestaurants = clpRepository.findAll();
3641

0 commit comments

Comments
 (0)