-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathWithdrawalController.java
More file actions
45 lines (35 loc) · 1.88 KB
/
WithdrawalController.java
File metadata and controls
45 lines (35 loc) · 1.88 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
package io.zipcoder.controller;
import io.zipcoder.domain.Withdrawal;
import io.zipcoder.service.WithdrawalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
public class WithdrawalController {
@Autowired
private WithdrawalService withdrawalService;
public WithdrawalController(WithdrawalService withdrawalService) {
this.withdrawalService = withdrawalService;
}
@RequestMapping(value="accounts/{acountId}/withdrawals", method = RequestMethod.GET)
public ResponseEntity<?> getWithdrawalsByAccount(@PathVariable("accountId") Long accountId) {
return withdrawalService.getWithdrawalsByAccount(accountId);
}
@RequestMapping(value="/withdrawals/{withdrawalId}", method = RequestMethod.GET)
public ResponseEntity<?> getWithdrawal(@PathVariable("withdrawalId") Long withdrawalId) {
return withdrawalService.getWithdrawal(withdrawalId);
}
@RequestMapping(value="/accounts/{accountId}/withdrawals", method = RequestMethod.POST)
public ResponseEntity<?> createWithdrawal(@PathVariable("accountId") Long accountId, @RequestBody Withdrawal withdrawal) {
return withdrawalService.createWithdrawal(withdrawal, accountId);
}
@RequestMapping(value="/withdrawals/{withdrawalId}" , method = RequestMethod.PUT)
public ResponseEntity<?> updateWithdrawal(@PathVariable("withdrawalId") Long withdrawalId, @RequestBody Withdrawal withdrawal) {
return withdrawalService.updateWithdrawal(withdrawal, withdrawalId);
}
@RequestMapping(value="/withdrawals/{withdrawalId}", method = RequestMethod.DELETE)
public ResponseEntity<?> deleteWithdrawal(@PathVariable("withdrawalId") Long withdrawalId) {
return withdrawalService.deleteWithdrawal(withdrawalId);
}
}