-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathDepositController.java
More file actions
52 lines (42 loc) · 2.02 KB
/
DepositController.java
File metadata and controls
52 lines (42 loc) · 2.02 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
package io.zipcoder.controller;
import io.zipcoder.domain.Deposit;
import io.zipcoder.service.interfaces.DepositService;
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 DepositController {
private DepositService depositService;
public DepositController(DepositService depositService) {
this.depositService = depositService;
}
@RequestMapping(value = "/accounts/{accountId}/deposits", method = GET)
public ResponseEntity<Iterable<Deposit>> getAllDepositsByAccountId(@PathVariable("accountId") Long accountId) {
return depositService.getAllDepositsByAccountId(accountId);
}
@RequestMapping(value = "/deposits/{depositId}", method = GET)
public ResponseEntity<Deposit> getDepositById(@PathVariable("depositId") Long depositId) {
return depositService.getDepositById(depositId);
}
@RequestMapping(value = "/accounts/{accountId}/deposits", method = POST)
public ResponseEntity<Deposit> createDeposit(@RequestBody Deposit deposit, @PathVariable("accountId") Long accountId) {
return depositService.createDeposit(deposit, accountId);
}
@RequestMapping(value = "/deposits/{depositId}", method = PUT)
public ResponseEntity<Deposit> updateDeposit(@RequestBody Deposit deposit, @PathVariable("depositId") Long depositId) {
return depositService.updateDeposit(deposit, depositId);
}
@RequestMapping(value = "/deposits/{depositId}", method = DELETE)
public ResponseEntity deleteDepositById(@PathVariable("depositId") Long depositId) {
return depositService.deleteDepositById(depositId);
}
}