Skip to content

Commit

Permalink
Feat: 식음료 옵션 확인 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
marinesnow34 committed Nov 15, 2023
1 parent e318137 commit d1d39b1
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<FoodyDetailRes> 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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit d1d39b1

Please sign in to comment.