Skip to content

Commit

Permalink
fix: dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
oproprioleonardo committed Dec 14, 2024
1 parent d03638a commit c2cd83b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package br.com.ifsp.tickets.infra.config.app;

import br.com.ifsp.tickets.app.financial.product.ProductService;
import br.com.ifsp.tickets.app.financial.product.ProductServiceFactory;
import br.com.ifsp.tickets.domain.administrative.event.IEventGateway;
import br.com.ifsp.tickets.domain.financial.product.ITicketSaleGateway;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@RequiredArgsConstructor(onConstructor_ = @__(@Autowired))
public class ProductConfig {

private final IEventGateway eventGateway;
private final ITicketSaleGateway ticketSaleGateway;

@Bean
public ProductService productService() {
return ProductServiceFactory.create(
eventGateway,
ticketSaleGateway
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.util.Optional;

@Component
Expand All @@ -36,7 +37,7 @@ public Optional<Ticket> findById(TicketID id) {

@Override
public Ticket findByCodeAndNotExpired(TicketCode code) {
return this.repository.findByCodeAndExpiredInBefore(code.getCode(), new java.util.Date())
return this.repository.findByCodeAndExpiredInBefore(code.getCode(), LocalDate.now())
.map(TicketJpaEntity::toAggregate).orElse(null);
}

Expand All @@ -48,7 +49,7 @@ public Pagination<Ticket> findAllByUserID(UserID id, SearchQuery sq) {
Sort.by(Sort.Direction.fromString(sq.direction()), sq.sort())
);

final Page<Ticket> page = this.repository.findAllByUserId(id.getValue(), request).map(TicketJpaEntity::toAggregate);
final Page<Ticket> page = this.repository.findAllByEnrollmentUserID(id.getValue(), request).map(TicketJpaEntity::toAggregate);

return Pagination.of(
page.getNumber(),
Expand All @@ -66,7 +67,7 @@ public Pagination<Ticket> findAllByUserIDAndEventID(UserID userID, EventID event
Sort.by(Sort.Direction.fromString(sq.direction()), sq.sort())
);

final Page<Ticket> page = this.repository.findAllByUserIdAndEventId(userID.getValue(), eventID.getValue(), request)
final Page<Ticket> page = this.repository.findAllByEnrollmentUserIDAndEventId(userID.getValue(), eventID.getValue(), request)
.map(TicketJpaEntity::toAggregate);

return Pagination.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.time.LocalDate;
import java.util.Optional;
import java.util.UUID;

public interface TicketRepository extends JpaRepository<TicketJpaEntity, UUID> {
Optional<TicketJpaEntity> findByCodeAndExpiredInBefore(String code, java.util.Date date);
Page<TicketJpaEntity> findAllByUserId(UUID userId, Pageable pageable);
Page<TicketJpaEntity> findAllByUserIdAndEventId(UUID userId, UUID eventId, Pageable pageable);

Optional<TicketJpaEntity> findByCodeAndExpiredInBefore(String code, LocalDate date);

Page<TicketJpaEntity> findAllByEnrollmentUserID(UUID userId, Pageable pageable);

Page<TicketJpaEntity> findAllByEnrollmentUserIDAndEventId(UUID userId, UUID eventId, Pageable pageable);

}

0 comments on commit c2cd83b

Please sign in to comment.