Class AccountCommandRestController

java.lang.Object
com.brodygaudel.bank.command.controller.AccountCommandRestController

@RestController @RequestMapping("/commands/accounts") public class AccountCommandRestController extends Object
REST controller for handling account-related commands.

This controller provides endpoints for creating, crediting, debiting, transferring, and updating the status of accounts. It uses the Command Gateway to send corresponding commands to the system.

  • Constructor Details

    • AccountCommandRestController

      public AccountCommandRestController(org.axonframework.commandhandling.gateway.CommandGateway commandGateway, IdGenerator idGenerator)
      Constructs a new instance of AccountCommandRestController.
      Parameters:
      commandGateway - The command gateway used to send commands to the system.
      idGenerator - The ID generator used to generate unique IDs for account creation.
  • Method Details

    • create

      @PostMapping("/create") public CompletableFuture<String> create(@RequestBody @NotNull @NotNull AccountRequestDTO dto)
      Endpoint for creating a new account.
      Parameters:
      dto - The data transfer object containing account information.
      Returns:
      A CompletableFuture representing the completion of the command.
    • credit

      @PostMapping("/credit") public CompletableFuture<String> credit(@RequestBody @NotNull @NotNull CreditAccountRequestDTO dto)
      Endpoint for crediting an account.
      Parameters:
      dto - The data transfer object containing credit information.
      Returns:
      A CompletableFuture representing the completion of the command.
    • debit

      @PostMapping("/debit") public CompletableFuture<String> debit(@RequestBody @NotNull @NotNull DebitAccountRequestDTO dto)
      Endpoint for debiting an account.
      Parameters:
      dto - The data transfer object containing debit information.
      Returns:
      A CompletableFuture representing the completion of the command.
    • transfer

      @PostMapping("/transfer") public List<CompletableFuture<String>> transfer(@RequestBody @NotNull @NotNull TransferRequestDTO dto)
      Endpoint for transferring funds between two accounts.
      Parameters:
      dto - The data transfer object containing transfer information.
      Returns:
      A list of CompletableFutures representing the completion of debit and credit commands.
    • update

      @PostMapping("/update-status") public CompletableFuture<String> update(@RequestBody @NotNull @NotNull AccountStatusUpdatedDTO dto)
      Endpoint for updating the status of an account.
      Parameters:
      dto - The data transfer object containing updated account status information.
      Returns:
      A CompletableFuture representing the completion of the command.