Package api.mpba.rastvdmy.controller
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 Summary
ConstructorDescriptionCardController
(CardMapper cardMapper, CardService cardService) Constructor for CardController. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity
<CardResponse> addAccountCard
(String bankName, UUID accountId, jakarta.servlet.http.HttpServletRequest request) Adds a new card to a specific bank account.org.springframework.http.ResponseEntity
<CardResponse> getAccountCardById
(String bankName, UUID accountId, UUID cardId, String type, jakarta.servlet.http.HttpServletRequest request) Retrieves a specific card by its ID.org.springframework.http.ResponseEntity
<List<CardResponse>> getAccountCards
(String bankName, UUID accountId, jakarta.servlet.http.HttpServletRequest request) Retrieves all cards associated with a specific bank account.org.springframework.http.ResponseEntity
<Void> removeAccountCard
(String bankName, UUID accountId, UUID cardId, jakarta.servlet.http.HttpServletRequest request) Removes a card from a specific bank account.
-
Constructor Details
-
CardController
Constructor for CardController.- Parameters:
cardMapper
- TheCardMapper
to be used.cardService
- TheCardService
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 ofCardResponse
.
-
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 requestedCardResponse
.
-
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 createdCardResponse
. - 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.
-