diff --git a/src/main/java/com/example/FixLog/domain/post/Post.java b/src/main/java/com/example/FixLog/domain/post/Post.java index e0db596..b5ba702 100644 --- a/src/main/java/com/example/FixLog/domain/post/Post.java +++ b/src/main/java/com/example/FixLog/domain/post/Post.java @@ -33,32 +33,35 @@ public class Post { private String coverImage; @Lob // 텍스트가 길어질 수 있는 필드에 사용 - @Column(nullable = false) + @Column(columnDefinition = "TEXT", nullable = false) private String problem; @Lob - @Column(nullable = false) + @Column(columnDefinition = "TEXT", nullable = false) private String errorMessage; @Lob - @Column(nullable = false) + @Column(columnDefinition = "TEXT", nullable = false) private String environment; @Lob - @Column(nullable = false) + @Column(columnDefinition = "TEXT", nullable = false) private String reproduceCode; @Lob - @Column(nullable = false) + @Column(columnDefinition = "TEXT", nullable = false) private String solutionCode; @Lob + @Column(columnDefinition = "TEXT") private String causeAnalysis; @Lob + @Column(columnDefinition = "TEXT") private String referenceLink; @Lob + @Column(columnDefinition = "TEXT") private String extraContent; @Column(nullable = false) diff --git a/src/main/java/com/example/FixLog/domain/tag/Tag.java b/src/main/java/com/example/FixLog/domain/tag/Tag.java index c4297d4..31f290c 100644 --- a/src/main/java/com/example/FixLog/domain/tag/Tag.java +++ b/src/main/java/com/example/FixLog/domain/tag/Tag.java @@ -18,7 +18,7 @@ public class Tag { @Enumerated(EnumType.STRING) private TagCategory tagCategory; - @Column(length = 20, nullable = false) + @Column(length = 50, nullable = false) private String tagName; private String tagInfo; diff --git a/src/main/java/com/example/FixLog/mock/PostMockDataInitializer.java b/src/main/java/com/example/FixLog/mock/PostMockDataInitializer.java index d361cc9..1c602be 100644 --- a/src/main/java/com/example/FixLog/mock/PostMockDataInitializer.java +++ b/src/main/java/com/example/FixLog/mock/PostMockDataInitializer.java @@ -53,12 +53,12 @@ public void run(String... args) { .collect(Collectors.toMap(Tag::getTagName, tag -> tag)); List config = List.of( - new String[]{"백엔드", "스프링부트", "자바", "NullPointerException", "500 Internal Server Error"}, - new String[]{"프론트엔드", "리액트", "자바스크립트", "Cannot read property of undefined", "상태(state) 업데이트 누락"}, - new String[]{"머신러닝", "케라스", "파이썬", "OutOfMemoryError", "HTTP 에러"}, - new String[]{"백엔드", "노드", "JSON", "CORS 정책 오류", "404 Not Found"}, - new String[]{"프론트엔드", "넥스트", "CSS", "스타일 깨짐", "렌더링 무한 루프"}, - new String[]{"머신러닝", "사이킷런", "R", "ClassNotFoundException", "Permission Error"} + new String[]{"backend", "spring-boot", "java", "null-pointer-exception", "500-error"}, + new String[]{"frontend", "react", "javascript", "undefined-property", "state-missing"}, + new String[]{"machine-learning", "keras", "python", "out-of-memory", "http-error"}, + new String[]{"backend", "node.js", "json", "cors-error", "404-error"}, + new String[]{"frontend", "next.js", "css", "style-break", "render-loop"}, + new String[]{"machine-learning", "scikit-learn", "r", "class-not-found", "permission-error"} ); for (int i = 0; i < config.size(); i++) { diff --git a/src/main/java/com/example/FixLog/repository/post/PostRepositoryImpl.java b/src/main/java/com/example/FixLog/repository/post/PostRepositoryImpl.java index e8aedad..8b6dd28 100644 --- a/src/main/java/com/example/FixLog/repository/post/PostRepositoryImpl.java +++ b/src/main/java/com/example/FixLog/repository/post/PostRepositoryImpl.java @@ -39,14 +39,19 @@ public Page searchByKeywordAndTags(String keyword, List t // 2. 태그 조건 (AND 조건) if (tags != null && !tags.isEmpty()) { + List sanitizedTags = tags.stream() + .filter(tag -> tag != null && !tag.trim().isEmpty()) // null/빈값 제거 + .map(String::trim) // 공백 제거 + .toList(); + NumberExpression count = postTag.tagId.tagId.count(); JPQLQuery subQuery = queryFactory .select(postTag.postId.postId) .from(postTag) - .where(postTag.tagId.tagName.in(tags)) + .where(postTag.tagId.tagName.in(sanitizedTags)) // 이미 소문자면 lower() 생략 가능 .groupBy(postTag.postId.postId) - .having(count.eq((long) tags.size())); + .having(count.eq((long) sanitizedTags.size())); builder.and(post.postId.in(subQuery)); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 471b627..b63eb06 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -25,7 +25,7 @@ spring.application.name=FixLog ## JWT #jwt.secret=${JWT_KEY} # -## Spring Security 디버깅 로그 +## Spring Security #logging.level.org.springframework.security=DEBUG ##### [PROD] ##### @@ -50,4 +50,5 @@ jwt.secret=${JWT_KEY} logging.level.root=INFO logging.level.com.example.FixLog=DEBUG +logging.level.org.springframework.web.servlet.DispatcherServlet=DEBUG logging.file.name=logs/app.log