Class CustomerCommandRestController

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

@RestController @RequestMapping("/commands/customers") public class CustomerCommandRestController extends Object
REST controller for handling customer-related commands.

This controller provides endpoints for creating, updating, and deleting customers. It uses the Command Gateway to send corresponding commands to the system.

  • Constructor Details

    • CustomerCommandRestController

      public CustomerCommandRestController(org.axonframework.commandhandling.gateway.CommandGateway commandGateway)
      Constructs a new instance of CustomerCommandRestController.
      Parameters:
      commandGateway - The command gateway used to send commands to the system.
  • Method Details

    • create

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

      @PutMapping("/update/{id}") public CompletableFuture<String> update(@PathVariable String id, @RequestBody @NotNull @NotNull CustomerRequestDTO dto)
      Endpoint for updating an existing customer.
      Parameters:
      id - The unique identifier of the customer to update.
      dto - The data transfer object containing updated customer information.
      Returns:
      A CompletableFuture representing the completion of the command.
    • delete

      @DeleteMapping("/delete/{id}") public CompletableFuture<String> delete(@PathVariable String id)
      Endpoint for deleting a customer.
      Parameters:
      id - The unique identifier of the customer to delete.
      Returns:
      A CompletableFuture representing the completion of the command.
    • exceptionHandler

      @ExceptionHandler(java.lang.Exception.class) public org.springframework.http.ResponseEntity<String> exceptionHandler(@NotNull @NotNull Exception exception)
      Exception handler for handling exceptions thrown within this controller.
      Parameters:
      exception - The exception to handle.
      Returns:
      A ResponseEntity with an error message and HTTP status code.