@@ -44,6 +44,7 @@ public enum MessageCode {
|
||||
RESOURCE_NOT_FOUND(4, "Resource not found"),
|
||||
INTERNAL_ERROR(4, "Internal server error"),
|
||||
COMPANY_NOT_FOUND(4, "Company not found"),
|
||||
PAYMENT_NOT_FOUND(4, "Payment not found"),
|
||||
COMPANY_ALREADY_EXISTS(2, "Company already exists"),
|
||||
USER_LIMIT_IS_OVER(2, "Over user limits"),
|
||||
ERROR_TARIFF_INFO(2, "Erorr with tariff info"),
|
||||
|
||||
@@ -9,9 +9,11 @@ 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.exception.PaymentNotFoundException;
|
||||
import ru.soune.nocopy.service.payment.PaymentService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@@ -33,11 +35,15 @@ public class PaymentHandler implements RequestHandler{
|
||||
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)));
|
||||
|
||||
try {
|
||||
Payment payment = paymentService.paymentInfo(paymentRequest.getPaymentUuid());
|
||||
return new BaseResponse(request.getMsgId(), MessageCode.SUCCESS.getCode(),
|
||||
MessageCode.SUCCESS.getDescription(), new PaymentResponse(List.of(payment)));
|
||||
} catch (PaymentNotFoundException e) {
|
||||
return new BaseResponse(request.getMsgId(), MessageCode.PAYMENT_NOT_FOUND.getCode(),
|
||||
MessageCode.PAYMENT_NOT_FOUND.getDescription(), Map.of("paymentUuid",
|
||||
paymentRequest.getPaymentUuid()));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user