awawa
This commit is contained in:
parent
2a44ada1be
commit
61bdf1e048
4 changed files with 6 additions and 4 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
Reference in a new issue