From 0961627ee15246c548da51738001467bec188e3a Mon Sep 17 00:00:00 2001 From: gustavofg1pontes Date: Sun, 6 Oct 2024 23:28:59 -0300 Subject: [PATCH] debug --- .../config/app/MercadoPagoConfiguration.java | 6 ------ .../event/sale/ticket/TicketSaleGateway.java | 16 ++++++++++++++-- .../ticket/persistence/TicketSaleRepository.java | 4 +++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/infrastructure/src/main/java/br/com/ifsp/tickets/infra/config/app/MercadoPagoConfiguration.java b/infrastructure/src/main/java/br/com/ifsp/tickets/infra/config/app/MercadoPagoConfiguration.java index 7b0180e..c9f81c1 100644 --- a/infrastructure/src/main/java/br/com/ifsp/tickets/infra/config/app/MercadoPagoConfiguration.java +++ b/infrastructure/src/main/java/br/com/ifsp/tickets/infra/config/app/MercadoPagoConfiguration.java @@ -27,10 +27,4 @@ public class MercadoPagoConfiguration { public void initialize() { MercadoPagoConfig.setAccessToken(mercadoPagoAccessToken); } - - @Bean - public PaymentService paymentService() { - System.out.println("AAAAAAAAAAAAAAAAAAAA: " + this.mercadoPagoAccessToken); - return PaymentServiceFactory.create(ticketGateway, ticketSaleGateway, paymentGateway); - } } diff --git a/infrastructure/src/main/java/br/com/ifsp/tickets/infra/contexts/event/sale/ticket/TicketSaleGateway.java b/infrastructure/src/main/java/br/com/ifsp/tickets/infra/contexts/event/sale/ticket/TicketSaleGateway.java index 1b606d8..d636fde 100644 --- a/infrastructure/src/main/java/br/com/ifsp/tickets/infra/contexts/event/sale/ticket/TicketSaleGateway.java +++ b/infrastructure/src/main/java/br/com/ifsp/tickets/infra/contexts/event/sale/ticket/TicketSaleGateway.java @@ -34,9 +34,21 @@ public Optional findById(TicketSaleID id) { @Override public Pagination findAllByEventID(EventID id, SearchQuery sq) { - return null; - } + final PageRequest request = PageRequest.of( + sq.page(), + sq.perPage(), + Sort.by(Sort.Direction.fromString(sq.direction()), sq.sort()) + ); + + final Page page = this.repository.findAllByEventId(id.getValue(), request).map(TicketSaleJpaEntity::toAggregate); + return Pagination.of( + page.getNumber(), + page.getSize(), + page.getTotalElements(), + page.getContent() + ); + } @Override public TicketSale update(TicketSale ticketSale) { diff --git a/infrastructure/src/main/java/br/com/ifsp/tickets/infra/contexts/event/sale/ticket/persistence/TicketSaleRepository.java b/infrastructure/src/main/java/br/com/ifsp/tickets/infra/contexts/event/sale/ticket/persistence/TicketSaleRepository.java index 20836fd..28a2029 100644 --- a/infrastructure/src/main/java/br/com/ifsp/tickets/infra/contexts/event/sale/ticket/persistence/TicketSaleRepository.java +++ b/infrastructure/src/main/java/br/com/ifsp/tickets/infra/contexts/event/sale/ticket/persistence/TicketSaleRepository.java @@ -1,9 +1,11 @@ package br.com.ifsp.tickets.infra.contexts.event.sale.ticket.persistence; - +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import java.util.UUID; public interface TicketSaleRepository extends JpaRepository { + Page findAllByEventId(UUID eventID, Pageable pageable); }