blob: 19f85395b7b6bca9c9714dcb47335d56dbb23c1c (
plain)
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
|
package com.example.spring.bank.account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/account")
public class AccountController {
@Autowired
private AccountManager accountManager;
@GetMapping("/{accountNumber}")
public Account getAccount(@PathVariable Long accountNumber) {
// TODO: Check null returns.
Account account = accountManager.findByAccountNumber(accountNumber).get();
return account;
}
@PostMapping("/")
public Account createAccount(Account account) {
return accountManager.create(account);
}
}
|