|
1 | 1 | package om.order.controller; |
2 | 2 |
|
3 | 3 | import jakarta.validation.Valid; |
4 | | -import lombok.RequiredArgsConstructor; |
5 | | -import lombok.extern.slf4j.Slf4j; |
6 | 4 | import om.order.config.Constants; |
7 | 5 | import om.order.dto.OrderReq; |
8 | 6 | import om.order.dto.OrderResp; |
|
21 | 19 |
|
22 | 20 | //@RequiredArgsConstructor |
23 | 21 | @RestController// @Slf4j |
24 | | -//@RequestMapping(value = "/api/orders",headers = "Accept-Version=v1") // A different scheme of API versioning |
| 22 | +//@RequestMapping(value = "/api/orders",headers = "Accept-Version=v1") // A different scheme of API versioning, available to choose |
25 | 23 | @RequestMapping(value = "/api/v1/orders") |
26 | 24 | public class OrderController { |
27 | 25 | private final OrderService orderService; |
28 | | -public OrderController(OrderService orderService) {this.orderService = orderService;} |
| 26 | + public OrderController(OrderService orderService) {this.orderService = orderService;} |
29 | 27 |
|
30 | | - // @ResponseStatus(HttpStatus.CREATED): the modern way to write Controller Endpoints. |
31 | | - // Older way is depicted in ResponseEntity<List<ProductResp>> ProductController.getAllProducts() endpoint. |
| 28 | + /** @ResponseStatus(HttpStatus.CREATED): the modern way to write Controller Endpoints. |
| 29 | + Older way is depicted in ResponseEntity<List<ProductResp>> ProductController.getAllProducts() endpoint.*/ |
32 | 30 | @PostMapping |
33 | 31 | @ResponseStatus(HttpStatus.CREATED) // 201 |
34 | 32 | public String createOrder(@Valid @RequestBody OrderReq orderReq) { |
35 | 33 | orderService.createOrder(orderReq); |
36 | 34 | //log.debug(Constants.NEW_ORDER_PLACED_MSG); |
37 | | - return Constants.NEW_ORDER_PLACED_MSG; |
| 35 | + return Constants.NEW_ORDER_PLACED__MSG; |
38 | 36 | } |
39 | 37 |
|
40 | 38 | // getOrders() |
|
0 commit comments