-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e318137
commit d1d39b1
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |