diff --git a/src/main/java/cat/udl/eps/softarch/myroutes/domain/Coordinate.java b/src/main/java/cat/udl/eps/softarch/myroutes/domain/Coordinate.java index 43521a4..cff83c9 100644 --- a/src/main/java/cat/udl/eps/softarch/myroutes/domain/Coordinate.java +++ b/src/main/java/cat/udl/eps/softarch/myroutes/domain/Coordinate.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonIdentityReference; +import com.fasterxml.jackson.annotation.JsonProperty; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; @@ -12,6 +13,8 @@ import lombok.Data; import lombok.EqualsAndHashCode; +import java.time.ZonedDateTime; + @EqualsAndHashCode(callSuper = true) @Entity @Data @@ -30,4 +33,9 @@ public class Coordinate extends UriEntity { @JsonIdentityReference(alwaysAsId = true) private RouteVersion routeVersion; + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + @GeneratedValue() + @NotNull + private ZonedDateTime creationDate = ZonedDateTime.now(); + } diff --git a/src/main/java/cat/udl/eps/softarch/myroutes/repository/CoordinateRepository.java b/src/main/java/cat/udl/eps/softarch/myroutes/repository/CoordinateRepository.java index f48e1d3..709bcd8 100644 --- a/src/main/java/cat/udl/eps/softarch/myroutes/repository/CoordinateRepository.java +++ b/src/main/java/cat/udl/eps/softarch/myroutes/repository/CoordinateRepository.java @@ -1,6 +1,7 @@ package cat.udl.eps.softarch.myroutes.repository; import cat.udl.eps.softarch.myroutes.domain.Coordinate; +import cat.udl.eps.softarch.myroutes.domain.RouteVersion; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.query.Param; @@ -10,5 +11,7 @@ @RepositoryRestResource public interface CoordinateRepository extends CrudRepository, PagingAndSortingRepository { - // public boolean findCoordinateByRouteVersion(@Param("routeVersion") RouteVersion routeVersion); + List findByRouteVersion(@Param("routeVersion") RouteVersion routeVersion); + List findByCoordinate(@Param("coordinate") String coordinate); + }