This commit is contained in:
j-weissen 2023-11-26 18:04:24 +01:00
parent 2a44ada1be
commit 61bdf1e048
4 changed files with 6 additions and 4 deletions

View file

@ -4,7 +4,7 @@ import java.util.Date;
import java.util.List;
public record CartEventResponseDto(
int id,
Long id,
String name,
Date from,
Date to,

View file

@ -13,7 +13,7 @@ import java.util.List;
public class Cart {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private Long id;
@OneToMany(mappedBy = "cart")
@JoinColumn(nullable = false)

View file

@ -9,5 +9,5 @@ import java.util.List;
public interface CartEntryRepository extends JpaRepository<CartEntry, Integer> {
@Query("SELECT ce FROM CartEntry ce WHERE ce.cart.id = :cartId AND ce.category.event.id = :eventId")
List<CartEntry> getByCartAndEvent(@Param("cartId") Integer cartId, @Param("eventId") Integer eventId);
List<CartEntry> getByCartAndEvent(@Param("cartId") Long cartId, @Param("eventId") Long eventId);
}

View file

@ -20,7 +20,9 @@ public class CartService {
}
public List<CartEventResponseDto> toDto(Cart cart) {
List<Event> distinctEvents = cart.getCartEntries().stream().map(entry -> entry.getCategory().getEvent()).distinct().toList();
List<Event> distinctEvents = cart.getCartEntries().stream().map(
entry -> entry.getCategory().getEvent()
).distinct().toList();
return distinctEvents.stream().map(event ->
new CartEventResponseDto(
event.getId(),