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); } }