-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathWithdrawalController.java
More file actions
53 lines (42 loc) · 2.17 KB
/
WithdrawalController.java
File metadata and controls
53 lines (42 loc) · 2.17 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.Withdrawal;
import io.zipcoder.service.interfaces.WithdrawalService;
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 WithdrawalController {
private WithdrawalService withdrawalService;
public WithdrawalController(WithdrawalService withdrawalService) {
this.withdrawalService = withdrawalService;
}
@RequestMapping(value = "/accounts/{accountId}/withdrawals", method = GET)
public ResponseEntity<Iterable<Withdrawal>> getAllWithdrawalsByAccountId(@PathVariable("accountId") Long accountId) {
return withdrawalService.getAllWithdrawalsByAccountId(accountId);
}
@RequestMapping(value = "/withdrawals/{withdrawalId}", method = GET)
public ResponseEntity<Withdrawal> getWithdrawalById(@PathVariable("withdrawalId") Long withdrawalId) {
return withdrawalService.getWithdrawalById(withdrawalId);
}
@RequestMapping(value = "/accounts/{accountId}/withdrawal", method = POST)
public ResponseEntity<Withdrawal> createWithdrawal(@RequestBody Withdrawal withdrawal, @PathVariable("accountId") Long accountId) {
return withdrawalService.createWithdrawal(withdrawal, accountId);
}
@RequestMapping(value = "/withdrawals/{withdrawalId}", method = PUT)
public ResponseEntity<Withdrawal> updateWithdrawal(@RequestBody Withdrawal withdrawal, @PathVariable("withdrawalId") Long withdrawalId) {
return withdrawalService.updateWithdrawal(withdrawal, withdrawalId);
}
@RequestMapping(value = "/withdrawals/{withdrawalId}", method = DELETE)
public ResponseEntity deleteWithdrawalById(@PathVariable("withdrawalId") Long withdrawalId) {
return withdrawalService.deleteWithdrawalById(withdrawalId);
}
}