From c2e08e766f3f811814a5daa6bef76af969dc3f16 Mon Sep 17 00:00:00 2001 From: PauMAVA Date: Sat, 18 May 2024 18:49:05 +0200 Subject: [PATCH 1/2] Added missing functions to search cats and dogs by name and chip --- .../udl/eps/softarch/demo/repository/CatRepository.java | 7 +++++++ .../udl/eps/softarch/demo/repository/DogRepository.java | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/CatRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/CatRepository.java index e92592a..8c4c8f4 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/CatRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/CatRepository.java @@ -3,8 +3,15 @@ import cat.udl.eps.softarch.demo.domain.Cat; 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 CatRepository extends CrudRepository, PagingAndSortingRepository { + + List findByName(@Param("name") String name); + List findByChip(@Param("chip") String name); + } diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/DogRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/DogRepository.java index e068275..0495bb2 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/DogRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/DogRepository.java @@ -3,8 +3,15 @@ import cat.udl.eps.softarch.demo.domain.Dog; 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 DogRepository extends CrudRepository, PagingAndSortingRepository { + + List findByName(@Param("name") String name); + List findByChip(@Param("chip") String name); + } From 068bfd3dd42dce2b881f070d827012ab812971d6 Mon Sep 17 00:00:00 2001 From: PauMAVA Date: Sat, 18 May 2024 18:54:54 +0200 Subject: [PATCH 2/2] Change parameter names --- .../cat/udl/eps/softarch/demo/repository/CatRepository.java | 2 +- .../cat/udl/eps/softarch/demo/repository/DogRepository.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/CatRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/CatRepository.java index 8c4c8f4..ad13c46 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/CatRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/CatRepository.java @@ -12,6 +12,6 @@ public interface CatRepository extends CrudRepository, PagingAndSortingRepository { List findByName(@Param("name") String name); - List findByChip(@Param("chip") String name); + List findByChip(@Param("chip") String chip); } diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/DogRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/DogRepository.java index 0495bb2..42d8fbd 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/DogRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/DogRepository.java @@ -12,6 +12,6 @@ public interface DogRepository extends CrudRepository, PagingAndSortingRepository { List findByName(@Param("name") String name); - List findByChip(@Param("chip") String name); + List findByChip(@Param("chip") String chip); }