Class CardController

java.lang.Object
api.mpba.rastvdmy.controller.CardController

@RestController @PreAuthorize("hasRole(\'ROLE_DEFAULT\')") @RequestMapping(path="/api/v1/{bankName}/{accountId}/cards") public class CardController extends Object
Controller for managing bank account cards.

This controller provides endpoints for users to manage their cards associated with specific bank accounts, including retrieving all cards, adding new cards, getting a card by ID, and removing cards. It uses the CardService for business logic and CardMapper for mapping between request and response objects.

  • Constructor Details

    • CardController

      public CardController(CardMapper cardMapper, CardService cardService)
      Constructor for CardController.
      Parameters:
      cardMapper - The CardMapper to be used.
      cardService - The CardService to be used.
  • Method Details

    • getAccountCards

      @GetMapping(produces="application/json") public org.springframework.http.ResponseEntity<List<CardResponse>> getAccountCards(@PathVariable("bankName") String bankName, @PathVariable("accountId") UUID accountId, jakarta.servlet.http.HttpServletRequest request)
      Retrieves all cards associated with a specific bank account.
      Parameters:
      bankName - The name of the bank.
      accountId - The UUID of the account.
      request - The HTTP servlet request containing user information.
      Returns:
      A ResponseEntity containing a list of CardResponse.
    • getAccountCardById

      @GetMapping(path="/{cardId}", produces="application/json") public org.springframework.http.ResponseEntity<CardResponse> getAccountCardById(@PathVariable("bankName") String bankName, @PathVariable("accountId") UUID accountId, @PathVariable("cardId") UUID cardId, @RequestParam(value="type",defaultValue="non-visible") String type, jakarta.servlet.http.HttpServletRequest request)
      Retrieves a specific card by its ID.
      Parameters:
      bankName - The name of the bank.
      accountId - The UUID of the account.
      cardId - The UUID of the card to retrieve.
      type - The visibility type of the card (default is "non-visible").
      request - The HTTP servlet request containing user information.
      Returns:
      A ResponseEntity containing the requested CardResponse.
    • addAccountCard

      @PostMapping(produces="application/json") public org.springframework.http.ResponseEntity<CardResponse> addAccountCard(@PathVariable("bankName") String bankName, @PathVariable("accountId") UUID accountId, jakarta.servlet.http.HttpServletRequest request) throws Exception
      Adds a new card to a specific bank account.
      Parameters:
      bankName - The name of the bank.
      accountId - The UUID of the account.
      request - The HTTP servlet request containing user information.
      Returns:
      A ResponseEntity containing the created CardResponse.
      Throws:
      Exception - If there is an error while adding the card.
    • removeAccountCard

      @DeleteMapping(path="/{cardId}") public org.springframework.http.ResponseEntity<Void> removeAccountCard(@PathVariable(name="bankName") String bankName, @PathVariable(name="accountId") UUID accountId, @PathVariable(name="cardId") UUID cardId, jakarta.servlet.http.HttpServletRequest request)
      Removes a card from a specific bank account.
      Parameters:
      bankName - The name of the bank.
      accountId - The UUID of the account.
      cardId - The UUID of the card to remove.
      request - The HTTP servlet request containing user information.
      Returns:
      A ResponseEntity with no content.