dev add api for payment
Test Workflow / test (push) Successful in 3s

This commit is contained in:
vladp
2026-02-18 18:26:11 +07:00
parent 3d5856d302
commit d7e3afb4dc
8 changed files with 111 additions and 4 deletions
@@ -0,0 +1,45 @@
package ru.soune.nocopy.handler;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import ru.soune.nocopy.dto.BaseRequest;
import ru.soune.nocopy.dto.BaseResponse;
import ru.soune.nocopy.dto.MessageCode;
import ru.soune.nocopy.dto.payment.PaymentRequest;
import ru.soune.nocopy.dto.payment.PaymentResponse;
import ru.soune.nocopy.entity.payment.Payment;
import ru.soune.nocopy.service.payment.PaymentService;
import java.util.List;
@Component
@RequiredArgsConstructor
public class PaymentHandler implements RequestHandler{
private final PaymentService paymentService;
private final ObjectMapper objectMapper;
@Override
public BaseResponse handle(BaseRequest request) throws Exception {
PaymentRequest paymentRequest = objectMapper.convertValue(request.getMessageBody(), PaymentRequest.class);
String action = paymentRequest.getAction();
switch (action) {
case "user_payments":
List<Payment> payments = paymentService.userPayments(paymentRequest.getEmail());
return new BaseResponse(request.getMsgId(), MessageCode.SUCCESS.getCode(),
MessageCode.SUCCESS.getDescription(), new PaymentResponse(payments));
case "payment_info":
Payment payment = paymentService.paymentInfo(paymentRequest.getPaymentUuid());
return new BaseResponse(request.getMsgId(), MessageCode.SUCCESS.getCode(),
MessageCode.SUCCESS.getDescription(), new PaymentResponse(List.of(payment)));
}
return null;
}
}