-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathBillController.java
More file actions
53 lines (39 loc) · 1.83 KB
/
BillController.java
File metadata and controls
53 lines (39 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package io.zipcoder.controller;
import io.zipcoder.domain.Bill;
import io.zipcoder.service.BillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
public class BillController {
@Autowired
private BillService billService;
public BillController() {}
public BillController(BillService billService) {
this.billService = billService;
}
@RequestMapping(value="/accounts/{accountId}/bills", method= RequestMethod.GET)
public ResponseEntity<Iterable<Bill>> getAllBillsForAccount(@PathVariable("accountId") Long accountId) {
return billService.getAllBillsForAccount(accountId);
}
@RequestMapping(value="/bills/{billId}", method= RequestMethod.GET)
public ResponseEntity<Bill> getBillById(@PathVariable("billId") Long billId) {
return billService.getBillById(billId);
}
@RequestMapping(value="/customers/{customerId}/bills", method= RequestMethod.GET)
public ResponseEntity<Iterable<Bill>> getAllBillsForCustomer(@PathVariable Long customerId) {
return billService.getAllBillsForCustomer();
}
@RequestMapping(value="/accounts/{accountId}/bills", method = RequestMethod.POST)
public ResponseEntity<?> createBill(@PathVariable Long accountId, @RequestBody Bill bill) {
return billService.createBill(bill);
}
@RequestMapping(value = "/bills/{billId}", method = RequestMethod.PUT)
public ResponseEntity<?> updateBill(@PathVariable Long billId, @RequestBody Bill bill) {
return billService.updateBill(bill);
}
@RequestMapping(value = "/bills/{billId}", method = RequestMethod.DELETE)
public ResponseEntity<?> deleteBill(@PathVariable Long billId) {
return billService.deleteBill(billId);
}
}