-
Notifications
You must be signed in to change notification settings - Fork 40
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
529b95f
commit 91d6ddf
Showing
9 changed files
with
143 additions
and
5 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
be/kiosk/src/main/java/team/five/kiosk/controller/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,28 @@ | ||
package team.five.kiosk.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import team.five.kiosk.dto.RequestOrder; | ||
import team.five.kiosk.global.ApiResponse; | ||
import team.five.kiosk.service.OrderService; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1") | ||
@RestController | ||
public class OrderController { | ||
|
||
private final OrderService orderService; | ||
|
||
@PostMapping("/orders") | ||
public ResponseEntity<ApiResponse<Long>> order(@RequestBody RequestOrder requestOrder) { | ||
final Long orderId = orderService.order(requestOrder); | ||
|
||
return ResponseEntity.status(HttpStatus.CREATED) | ||
.body(ApiResponse.success("201", orderId)); | ||
} | ||
} |
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,15 @@ | ||
package team.five.kiosk.domain; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public class Order { | ||
private Long id; | ||
|
||
private Long payment_id; | ||
|
||
private int totalCost; | ||
|
||
private int inputCost; | ||
|
||
private LocalDateTime orderAt; | ||
} |
25 changes: 25 additions & 0 deletions
25
be/kiosk/src/main/java/team/five/kiosk/domain/OrderDetail.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,25 @@ | ||
package team.five.kiosk.domain; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class OrderDetail { | ||
private Long id; | ||
|
||
private Long productId; | ||
|
||
private Long orderId; | ||
|
||
private String size; | ||
|
||
private String temperature; | ||
|
||
private int count; | ||
|
||
public OrderDetail(Long productId, String size, String temperature, int count) { | ||
this.productId = productId; | ||
this.size = size; | ||
this.temperature = temperature; | ||
this.count = count; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
be/kiosk/src/main/java/team/five/kiosk/dto/RequestOrder.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,20 @@ | ||
package team.five.kiosk.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class RequestOrder { | ||
private String payment; | ||
|
||
private int totalPrice; | ||
|
||
@JsonIgnore(value = false) | ||
private int inputPrice; | ||
|
||
private List<RequestOrderProduct> orderProducts; | ||
} |
16 changes: 16 additions & 0 deletions
16
be/kiosk/src/main/java/team/five/kiosk/dto/RequestOrderProduct.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,16 @@ | ||
package team.five.kiosk.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class RequestOrderProduct { | ||
private Long productId; | ||
|
||
private int count; | ||
|
||
private String size; | ||
|
||
private String temperature; | ||
} |
7 changes: 7 additions & 0 deletions
7
be/kiosk/src/main/java/team/five/kiosk/repository/OrderRepository.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 team.five.kiosk.repository; | ||
|
||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public class OrderRepository { | ||
} |
24 changes: 24 additions & 0 deletions
24
be/kiosk/src/main/java/team/five/kiosk/service/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,24 @@ | ||
package team.five.kiosk.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import team.five.kiosk.dto.RequestOrder; | ||
import team.five.kiosk.repository.OrderRepository; | ||
|
||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor | ||
@Service | ||
public class OrderService { | ||
|
||
private final OrderRepository orderRepository; | ||
|
||
@Transactional | ||
public Long order(RequestOrder requestOrder) { | ||
// 결제 수단(payment) 조회 | ||
// order 저장 | ||
// orderProducts 저장 | ||
|
||
return 1L; | ||
} | ||
} |
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
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