From cf877959e01aec52680c273e7f1f3e8d174faa2f Mon Sep 17 00:00:00 2001 From: Jeongmin39 Date: Tue, 8 Oct 2024 19:03:12 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=EC=9E=91=ED=92=88=EB=AA=85=20?= =?UTF-8?q?=EA=B2=80=EC=83=89=20=EC=BF=BC=EB=A6=AC=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EA=B3=B5=EB=B0=B1=20=EB=B0=8F=20=ED=8A=B9=EC=88=98=EB=AC=B8?= =?UTF-8?q?=EC=9E=90=20=EC=B2=98=EB=A6=AC=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spot/spotserver/api/spot/repository/WorkRepository.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/spot/spotserver/api/spot/repository/WorkRepository.java b/src/main/java/com/spot/spotserver/api/spot/repository/WorkRepository.java index a50db56..3608da3 100644 --- a/src/main/java/com/spot/spotserver/api/spot/repository/WorkRepository.java +++ b/src/main/java/com/spot/spotserver/api/spot/repository/WorkRepository.java @@ -2,9 +2,12 @@ import com.spot.spotserver.api.spot.domain.Work; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import java.util.List; public interface WorkRepository extends JpaRepository { - List findByNameContainingIgnoreCase(String workName); + @Query("SELECT w FROM Work w WHERE REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(w.name, ' ', ''), '!', ''), '?', ''), ',', ''), '-', ''), ':', '') " + + "LIKE CONCAT('%', REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(:workName, ' ', ''), '!', ''), '?', ''), ',', ''), '-', ''), ':', ''), '%')") + List searchWorksByName(String workName); } From 378d448e1687c5f40748dabb9cc7848843e0acca Mon Sep 17 00:00:00 2001 From: Jeongmin39 Date: Tue, 8 Oct 2024 19:04:13 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=EC=9E=85=EB=A0=A5=EB=90=9C=20?= =?UTF-8?q?=EA=B2=80=EC=83=89=EC=96=B4=EC=9D=98=20=EA=B3=B5=EB=B0=B1=20?= =?UTF-8?q?=EB=B0=8F=20=ED=8A=B9=EC=88=98=EB=AC=B8=EC=9E=90=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/spot/spotserver/api/spot/service/SpotService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/spot/spotserver/api/spot/service/SpotService.java b/src/main/java/com/spot/spotserver/api/spot/service/SpotService.java index 063f35f..78d3c28 100644 --- a/src/main/java/com/spot/spotserver/api/spot/service/SpotService.java +++ b/src/main/java/com/spot/spotserver/api/spot/service/SpotService.java @@ -246,7 +246,9 @@ public List getTop5Spots(User user) { } public List searchSpotsByWorkName(String workName, User user) { - List works = workRepository.findByNameContainingIgnoreCase(workName); + String trimmedWorkName = workName.trim().replaceAll("[!?,:-]", ""); + + List works = workRepository.searchWorksByName(trimmedWorkName); if (works.isEmpty()) { return new ArrayList<>(); }