From d1d39b1780907356f9c4d355a8466c72814cb05f Mon Sep 17 00:00:00 2001 From: marinesnow34 Date: Wed, 15 Nov 2023 18:25:31 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EC=8B=9D=EC=9D=8C=EB=A3=8C=20=EC=98=B5?= =?UTF-8?q?=EC=85=98=20=ED=99=95=EC=9D=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/order/OrderController.java | 29 +++++++++++++++++++ .../readyverydemo/src/order/OrderService.java | 7 +++++ .../src/order/OrderServiceImpl.java | 27 +++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java new file mode 100644 index 0000000..a54332f --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java @@ -0,0 +1,29 @@ +package com.readyvery.readyverydemo.src.order; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.readyvery.readyverydemo.src.order.dto.FoodyDetailRes; + +import lombok.RequiredArgsConstructor; + +@RestController +@RequestMapping("/api/v1/order") +@RequiredArgsConstructor +public class OrderController { + private final OrderService orderService; + + @GetMapping("/{storeId}") + public ResponseEntity getFoody( + @PathVariable("storeId") Long storeId, + @RequestParam("foody_id") Long foodyId, + @RequestParam("inout") Long inout) { + FoodyDetailRes foodyDetailRes = orderService.getFoody(storeId, foodyId, inout); + return new ResponseEntity<>(foodyDetailRes, HttpStatus.OK); + } +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java new file mode 100644 index 0000000..e19215c --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java @@ -0,0 +1,7 @@ +package com.readyvery.readyverydemo.src.order; + +import com.readyvery.readyverydemo.src.order.dto.FoodyDetailRes; + +public interface OrderService { + FoodyDetailRes getFoody(Long storeId, Long foodyId, Long inout); +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java new file mode 100644 index 0000000..a234c6f --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -0,0 +1,27 @@ +package com.readyvery.readyverydemo.src.order; + +import org.springframework.stereotype.Service; + +import com.readyvery.readyverydemo.domain.Foodie; +import com.readyvery.readyverydemo.domain.repository.FoodieRepository; +import com.readyvery.readyverydemo.global.exception.BusinessLogicException; +import com.readyvery.readyverydemo.global.exception.ExceptionCode; +import com.readyvery.readyverydemo.src.order.dto.FoodyDetailRes; +import com.readyvery.readyverydemo.src.order.dto.OrderMapper; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class OrderServiceImpl implements OrderService { + private final FoodieRepository foodieRepository; + private final OrderMapper orderMapper; + + @Override + public FoodyDetailRes getFoody(Long storeId, Long foodyId, Long inout) { + Foodie foodie = foodieRepository.findById(foodyId).orElseThrow( + () -> new BusinessLogicException(ExceptionCode.FOODY_NOT_FOUND) + ); + return orderMapper.foodieToFoodyDetailRes(foodie, inout); + } +}