Class AccountController

java.lang.Object
org.training.account.service.controller.AccountController

@RestController @RequestMapping("/accounts") public class AccountController extends Object
  • Constructor Details

    • AccountController

      public AccountController()
  • Method Details

    • createAccount

      @PostMapping public org.springframework.http.ResponseEntity<Response> createAccount(@RequestBody AccountDto accountDto)
      Create an account using the provided accountDto
      Parameters:
      accountDto - The account details
      Returns:
      The response entity with the created account and HTTP status code
    • updateAccountStatus

      @PatchMapping public org.springframework.http.ResponseEntity<Response> updateAccountStatus(@RequestParam String accountNumber, @RequestBody AccountStatusUpdate accountStatusUpdate)
      Update the status of an account.
      Parameters:
      accountNumber - The account number of the account to update.
      accountStatusUpdate - The account status update containing the new status.
      Returns:
      The response entity with the updated account status.
    • readByAccountNumber

      @GetMapping public org.springframework.http.ResponseEntity<AccountDto> readByAccountNumber(@RequestParam String accountNumber)
      Retrieves an account by its account number.
      Parameters:
      accountNumber - The account number to search for.
      Returns:
      The account DTO if found, or a 404 response if not found.
    • updateAccount

      @PutMapping public org.springframework.http.ResponseEntity<Response> updateAccount(@RequestParam String accountNumber, @RequestBody AccountDto accountDto)
      Updates an account with the given account number.
      Parameters:
      accountNumber - The account number of the account to be updated.
      accountDto - The updated account information.
      Returns:
      The response entity with the updated account information.
    • accountBalance

      @GetMapping("/balance") public org.springframework.http.ResponseEntity<String> accountBalance(@RequestParam String accountNumber)
      Retrieves the balance of the specified account.
      Parameters:
      accountNumber - The account number
      Returns:
      The account balance
    • getTransactionsFromAccountId

      @GetMapping("/{accountId}/transactions") public org.springframework.http.ResponseEntity<List<TransactionResponse>> getTransactionsFromAccountId(@PathVariable String accountId)
      Retrieve the list of transactions for a given account ID.
      Parameters:
      accountId - The ID of the account.
      Returns:
      A ResponseEntity object containing a list of TransactionResponse objects.
    • closeAccount

      @PutMapping("/closure") public org.springframework.http.ResponseEntity<Response> closeAccount(@RequestParam String accountNumber)
      Closes an account.
      Parameters:
      accountNumber - The account number of the account to be closed.
      Returns:
      The response entity with the result of closing the account.
    • readAccountByUserId

      @GetMapping("/{userId}") public org.springframework.http.ResponseEntity<AccountDto> readAccountByUserId(@PathVariable Long userId)
      Retrieves the account for a given user ID.
      Parameters:
      userId - the ID of the user
      Returns:
      the account of the user