-
Notifications
You must be signed in to change notification settings - Fork 7
/
GetFoodController.java
42 lines (35 loc) · 1.67 KB
/
GetFoodController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.gaebaljip.exceed.adapter.in.food;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import com.gaebaljip.exceed.application.port.in.food.GetFoodQuery;
import com.gaebaljip.exceed.common.ApiResponse;
import com.gaebaljip.exceed.common.ApiResponseGenerator;
import com.gaebaljip.exceed.adapter.in.food.response.GetFoodResponse;
import com.gaebaljip.exceed.adapter.in.food.response.GetFoodsAutoResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@RestController
@SecurityRequirement(name = "access-token")
@RequiredArgsConstructor
@Slf4j
@RequestMapping("/v1")
@Tag(name = "[음식 조회]")
public class GetFoodController {
private final GetFoodQuery getFoodQuery;
@Operation(summary = "음식 자동완성 조회", description = "음식을 자동완성으로 조회한다.")
@GetMapping("/foods/auto")
public ApiResponse<ApiResponse.CustomBody<GetFoodsAutoResponse>> getFoods(
@RequestParam String prefix) {
GetFoodsAutoResponse response = getFoodQuery.execute(prefix);
return ApiResponseGenerator.success(response, HttpStatus.OK);
}
@Operation(summary = "음식 정보 조회", description = "음식 정보를 조회한다.")
@GetMapping("/foods/{foodId}")
public ApiResponse<ApiResponse.CustomBody<GetFoodResponse>> getFood(@PathVariable Long foodId) {
GetFoodResponse response = getFoodQuery.execute(foodId);
return ApiResponseGenerator.success(response, HttpStatus.OK);
}
}