diff --git a/src/main/java/FITPET/dev/controller/ComparisonController.java b/src/main/java/FITPET/dev/controller/ComparisonController.java index 56d003e..2d0adcc 100644 --- a/src/main/java/FITPET/dev/controller/ComparisonController.java +++ b/src/main/java/FITPET/dev/controller/ComparisonController.java @@ -69,7 +69,7 @@ public void downloadComparisonPdf(HttpServletResponse servletResponse, @GetMapping("/admin/comparison/search") - @Operation(summary = "견적서 검색 API", description = "전화번호와 펫 이름으로 견적서 검색") + @Operation(summary = "견적서 검색 API", description = "견적서 검색") public ApiResponse searchPetInfos( @RequestParam(name = "content", required = false) String content, @RequestParam(name = "page", required = false, defaultValue = "0") int page diff --git a/src/main/java/FITPET/dev/repository/ComparisonRepository.java b/src/main/java/FITPET/dev/repository/ComparisonRepository.java index aa22b63..bf101e6 100644 --- a/src/main/java/FITPET/dev/repository/ComparisonRepository.java +++ b/src/main/java/FITPET/dev/repository/ComparisonRepository.java @@ -40,16 +40,9 @@ List findByCreatedAtBetweenAndStatus(@Param(value = "startDate") Loc @Query("SELECT c FROM Comparison c " + - "WHERE c.deletedAt IS NULL " + - "AND (:content IS NULL OR " + - "(REPLACE(c.petInfo.phoneNum, '-', '') LIKE %:content% " + - "OR c.petInfo.name LIKE %:content% " + - "OR c.referSite.channel LIKE %:content% " + - "OR c.petInfo.pet.petSpecies LIKE %:content% " + - "OR c.comment LIKE %:content%)) " + - "ORDER BY c.createdAt DESC") - Page searchComparison( - @Param("content") String content, - Pageable pageable); + "WHERE REPLACE(c.petInfo.phoneNum, '-', '') LIKE %?1% " + + "OR c.petInfo.name LIKE %?1%") + Page findAllByPhoneNumOrPetName(String content, Pageable pageable); + } diff --git a/src/main/java/FITPET/dev/service/ComparisonService.java b/src/main/java/FITPET/dev/service/ComparisonService.java index 4cbb481..36480c6 100644 --- a/src/main/java/FITPET/dev/service/ComparisonService.java +++ b/src/main/java/FITPET/dev/service/ComparisonService.java @@ -212,8 +212,7 @@ public ComparisonResponse.ComparisonPageDto searchComparisons(String content, in // '-' 제거 String changedContent = content != null ? content.replaceAll("-", "") : null; - - Page comparisonPage = comparisonRepository.searchComparison(changedContent, pageable); + Page comparisonPage = comparisonRepository.findAllByPhoneNumOrPetName(changedContent, pageable); return ComparisonConverter.toComparisonPageDto(comparisonPage); }