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); + } +}