|
| 1 | +package com.example.myongsick.domain.dish.controller; |
| 2 | + |
| 3 | +import com.example.myongsick.domain.dish.dto.DishRequest; |
| 4 | +import com.example.myongsick.domain.dish.dto.DishResponse; |
| 5 | +import com.example.myongsick.domain.dish.service.DishService; |
| 6 | +import com.example.myongsick.domain.dish.dto.HateRequest; |
| 7 | +import com.example.myongsick.domain.dish.dto.LoveRequest; |
| 8 | +import com.example.myongsick.domain.dish.dto.RestaurantRequest; |
| 9 | +import com.example.myongsick.global.object.ApplicationResponse; |
| 10 | +import java.util.List; |
| 11 | +import lombok.RequiredArgsConstructor; |
| 12 | +import org.springframework.web.bind.annotation.GetMapping; |
| 13 | +import org.springframework.web.bind.annotation.PostMapping; |
| 14 | +import org.springframework.web.bind.annotation.PutMapping; |
| 15 | +import org.springframework.web.bind.annotation.RequestBody; |
| 16 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 17 | +import org.springframework.web.bind.annotation.RestController; |
| 18 | + |
| 19 | +@RestController |
| 20 | +@RequiredArgsConstructor |
| 21 | +@RequestMapping("/api/v3/dish") |
| 22 | +public class DishController { |
| 23 | + |
| 24 | + private final DishService dishService; |
| 25 | + |
| 26 | + @GetMapping |
| 27 | + public ApplicationResponse<List<DishResponse>> getDishAll() { |
| 28 | + return ApplicationResponse.ok(dishService.getDishAll()); |
| 29 | + } |
| 30 | + |
| 31 | + @PostMapping |
| 32 | + public ApplicationResponse<String> createDish( |
| 33 | + @RequestBody DishRequest request |
| 34 | + ) { |
| 35 | + return ApplicationResponse.ok(dishService.createDish(request)); |
| 36 | + } |
| 37 | + |
| 38 | + @PostMapping("/restaurant") |
| 39 | + public ApplicationResponse<String> createRestaurant( |
| 40 | + @RequestBody RestaurantRequest request |
| 41 | + ) { |
| 42 | + return ApplicationResponse.ok(dishService.createRestaurant(request)); |
| 43 | + } |
| 44 | + |
| 45 | + @PutMapping("/love") |
| 46 | + public ApplicationResponse<Integer> calculateLoveCount( |
| 47 | + @RequestBody LoveRequest request |
| 48 | + ) { |
| 49 | + return ApplicationResponse.ok(dishService.calculateLoveCount(request)); |
| 50 | + } |
| 51 | + @PutMapping("/hate") |
| 52 | + public ApplicationResponse<Integer> calculateHateCount( |
| 53 | + @RequestBody HateRequest request |
| 54 | + ) { |
| 55 | + return ApplicationResponse.ok(dishService.calculateHateCount(request)); |
| 56 | + } |
| 57 | +} |
0 commit comments