-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathBillController.java
More file actions
57 lines (46 loc) · 2.11 KB
/
BillController.java
File metadata and controls
57 lines (46 loc) · 2.11 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
54
55
56
57
package io.zipcoder.controller;
import io.zipcoder.domain.Bill;
import io.zipcoder.service.interfaces.BillService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static org.springframework.web.bind.annotation.RequestMethod.*;
/**
* project: zcwbank
* package: io.zipcoder.controller
* author: https://github.com/vvmk
* date: 4/9/18
*/
@RestController
public class BillController {
private BillService billService;
public BillController(BillService billService) {
this.billService = billService;
}
@RequestMapping(value = "/accounts/{accountId}/bills", method = GET)
public ResponseEntity<Iterable<Bill>> getBillsByAccountId(@PathVariable("accountId") Long accountId) {
return billService.getBillsByAccountId(accountId);
}
@RequestMapping(value = "/bills/{billId}", method = GET)
public ResponseEntity<Bill> getBillById(@PathVariable("billId") Long billId) {
return billService.getBillById(billId);
}
@RequestMapping(value = "/customers/{customerId}/bills", method = GET)
public ResponseEntity<Iterable<Bill>> getBillsByCustomerId(@PathVariable("customerId") Long customerId) {
return billService.getBillsByCustomerId(customerId);
}
@RequestMapping(value = "/accounts/{accountId}/bills", method = POST)
public ResponseEntity<Bill> createBill(@RequestBody Bill bill, @PathVariable("accountId") Long accountId) {
return billService.createBill(bill, accountId);
}
@RequestMapping(value = "/bills/{billId}", method = PUT)
public ResponseEntity<Bill> updateBill(@RequestBody Bill bill, @PathVariable("billId") Long billId) {
return billService.updateBill(bill, billId);
}
@RequestMapping(value = "/bills/{billId}", method = DELETE)
public ResponseEntity deleteBillById(@PathVariable("billId") Long billId) {
return billService.deleteBillById(billId);
}
}