Skip to content

Commit

Permalink
!hotfix : 견적서 조회 쿼리 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboysj committed Sep 7, 2024
1 parent b28e2c3 commit 1fcd6af
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 4 additions & 11 deletions src/main/java/FITPET/dev/repository/ComparisonRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,9 @@ List<Comparison> 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<Comparison> searchComparison(
@Param("content") String content,
Pageable pageable);
"WHERE REPLACE(c.petInfo.phoneNum, '-', '') LIKE %?1% " +
"OR c.petInfo.name LIKE %?1%")
Page<Comparison> findAllByPhoneNumOrPetName(String content, Pageable pageable);


}
3 changes: 1 addition & 2 deletions src/main/java/FITPET/dev/service/ComparisonService.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ public ComparisonResponse.ComparisonPageDto searchComparisons(String content, in

// '-' 제거
String changedContent = content != null ? content.replaceAll("-", "") : null;

Page<Comparison> comparisonPage = comparisonRepository.searchComparison(changedContent, pageable);
Page<Comparison> comparisonPage = comparisonRepository.findAllByPhoneNumOrPetName(changedContent, pageable);
return ComparisonConverter.toComparisonPageDto(comparisonPage);
}

Expand Down

0 comments on commit 1fcd6af

Please sign in to comment.