Package api.mpba.rastvdmy.controller
Class PaymentController
java.lang.Object
api.mpba.rastvdmy.controller.PaymentController
@RestController
@PreAuthorize("hasRole(\'ROLE_DEFAULT\')")
@RequestMapping(path="/api/v1/{accountId}/payments")
public class PaymentController
extends Object
Controller for handling payment-related requests.
This controller provides endpoints for retrieving, creating, and managing payments associated with a specific account. It ensures that the user has the appropriate role to access payment operations.
-
Constructor Summary
ConstructorDescriptionPaymentController
(PaymentService paymentService, PaymentMapper paymentMapper) Constructor for the PaymentController. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity
<PaymentResponse> createPayment
(jakarta.servlet.http.HttpServletRequest request, UUID accountId, PaymentParamsRequest paymentParamsRequest) Creates a new payment based on the provided parameters.org.springframework.http.ResponseEntity
<List<PaymentResponse>> getAllPayments
(jakarta.servlet.http.HttpServletRequest request, UUID accountId, String bankName) Retrieves all payments associated with the specified account.org.springframework.http.ResponseEntity
<PaymentResponse> getPaymentById
(jakarta.servlet.http.HttpServletRequest request, String bankName, UUID accountId, UUID paymentId) Retrieves a specific payment by its ID.
-
Constructor Details
-
PaymentController
Constructor for the PaymentController.- Parameters:
paymentService
- The service for payment operations.paymentMapper
- The mapper to convert between Payment and PaymentResponse.
-
-
Method Details
-
getAllPayments
@GetMapping(path="/{bankName}", produces="application/json") public org.springframework.http.ResponseEntity<List<PaymentResponse>> getAllPayments(jakarta.servlet.http.HttpServletRequest request, @PathVariable("accountId") UUID accountId, @PathVariable("bankName") String bankName) Retrieves all payments associated with the specified account.- Parameters:
request
- The HTTP servlet request.accountId
- The UUID of the account.bankName
- The name of the bank.- Returns:
- A response entity containing a list of payment responses.
-
getPaymentById
@GetMapping(path="/{bankName}/{id}", produces="application/json") public org.springframework.http.ResponseEntity<PaymentResponse> getPaymentById(jakarta.servlet.http.HttpServletRequest request, @PathVariable("bankName") String bankName, @PathVariable("accountId") UUID accountId, @PathVariable("id") UUID paymentId) Retrieves a specific payment by its ID.- Parameters:
request
- The HTTP servlet request.bankName
- The name of the bank.accountId
- The UUID of the account.paymentId
- The UUID of the payment.- Returns:
- A response entity containing the payment response.
-
createPayment
@PostMapping(consumes="application/json", produces="application/json") public org.springframework.http.ResponseEntity<PaymentResponse> createPayment(jakarta.servlet.http.HttpServletRequest request, @PathVariable("accountId") UUID accountId, @RequestBody PaymentParamsRequest paymentParamsRequest) throws Exception Creates a new payment based on the provided parameters.- Parameters:
request
- The HTTP servlet request.accountId
- The UUID of the account.paymentParamsRequest
- The request containing payment parameters.- Returns:
- A response entity containing the created payment response.
- Throws:
ApplicationException
- If the payment type is invalid or not specified.Exception
-