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;
|
import java.util.List;
|
||||||
|
|
||||||
public record CartEventResponseDto(
|
public record CartEventResponseDto(
|
||||||
int id,
|
Long id,
|
||||||
String name,
|
String name,
|
||||||
Date from,
|
Date from,
|
||||||
Date to,
|
Date to,
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||||
public class Cart {
|
public class Cart {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Integer id;
|
private Long id;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "cart")
|
@OneToMany(mappedBy = "cart")
|
||||||
@JoinColumn(nullable = false)
|
@JoinColumn(nullable = false)
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,5 @@ import java.util.List;
|
||||||
|
|
||||||
public interface CartEntryRepository extends JpaRepository<CartEntry, Integer> {
|
public interface CartEntryRepository extends JpaRepository<CartEntry, Integer> {
|
||||||
@Query("SELECT ce FROM CartEntry ce WHERE ce.cart.id = :cartId AND ce.category.event.id = :eventId")
|
@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) {
|
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 ->
|
return distinctEvents.stream().map(event ->
|
||||||
new CartEventResponseDto(
|
new CartEventResponseDto(
|
||||||
event.getId(),
|
event.getId(),
|
||||||
|
|
|
||||||
Reference in a new issue