Skip to content

Commit 3770f04

Browse files
authored
Merge pull request #106 from FixLog/fix#105-search-cw
[FIX] 태그 검색 수정
2 parents d2cd4a8 + 17c2e1f commit 3770f04

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/main/java/com/example/FixLog/repository/post/PostRepositoryImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,19 @@ public Page<SearchPostDto> searchByKeywordAndTags(String keyword, List<String> t
3939

4040
// 2. 태그 조건 (AND 조건)
4141
if (tags != null && !tags.isEmpty()) {
42+
List<String> sanitizedTags = tags.stream()
43+
.filter(tag -> tag != null && !tag.trim().isEmpty()) // null/빈값 제거
44+
.map(String::trim) // 공백 제거
45+
.toList();
46+
4247
NumberExpression<Long> count = postTag.tagId.tagId.count();
4348

4449
JPQLQuery<Long> subQuery = queryFactory
4550
.select(postTag.postId.postId)
4651
.from(postTag)
47-
.where(postTag.tagId.tagName.in(tags))
52+
.where(postTag.tagId.tagName.in(sanitizedTags)) // 이미 소문자면 lower() 생략 가능
4853
.groupBy(postTag.postId.postId)
49-
.having(count.eq((long) tags.size()));
54+
.having(count.eq((long) sanitizedTags.size()));
5055

5156
builder.and(post.postId.in(subQuery));
5257
}

src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spring.application.name=FixLog
2525
## JWT
2626
#jwt.secret=${JWT_KEY}
2727
#
28-
## Spring Security 디버깅 로그
28+
## Spring Security
2929
#logging.level.org.springframework.security=DEBUG
3030

3131
##### [PROD] #####

0 commit comments

Comments
 (0)