Skip to content

Commit 73b9838

Browse files
author
Jose Manuel De Pablo Cobo
committed
API new method for get all orders
1 parent 66c4579 commit 73b9838

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

backend/src/main/java/com/youdemy/controller/OrderPRestController.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.youdemy.controller;
22

3+
import java.util.ArrayList;
34
import java.util.Optional;
45

56
import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +12,8 @@
1112
import com.youdemy.model.OrderP;
1213
import com.youdemy.service.OrderPService;
1314

15+
import antlr.collections.List;
16+
1417
@RestController
1518
@RequestMapping("/api/orders")
1619
public class OrderPRestController {
@@ -30,6 +33,15 @@ public ResponseEntity<OrderP> getOrder(@PathVariable long id) {
3033
}
3134
}
3235

36+
37+
@GetMapping("/")
38+
public ArrayList<OrderP> getOrders() {
39+
40+
ArrayList<OrderP> orders = (ArrayList<OrderP>) orderService.findAll();
41+
42+
return orders;
43+
}
44+
3345
@PostMapping("/")
3446
@ResponseStatus(HttpStatus.CREATED)
3547
public OrderP createBook(@RequestBody OrderP order) {

0 commit comments

Comments
 (0)