diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Shelter.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Shelter.java index 9fd2b1fa..b6673c73 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Shelter.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Shelter.java @@ -1,5 +1,7 @@ package cat.udl.eps.softarch.demo.domain; +import cat.udl.eps.softarch.demo.domain.Location; + import jakarta.persistence.*; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotBlank; @@ -44,4 +46,7 @@ public class Shelter extends UriEntity { private boolean isActive; private Integer rating; + + @OneToOne + public Location locatedAt; } \ No newline at end of file diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterRepository.java new file mode 100644 index 00000000..556b18b0 --- /dev/null +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterRepository.java @@ -0,0 +1,17 @@ +package cat.udl.eps.softarch.demo.repository; + +import cat.udl.eps.softarch.demo.domain.Location; +import cat.udl.eps.softarch.demo.domain.Shelter; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +import java.util.List; + + +@RepositoryRestResource +public interface ShelterRepository extends CrudRepository, PagingAndSortingRepository { + List findByLocatedAt(@Param("location") Location locatedAt); + +} \ No newline at end of file