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/dto/main/MainPagePostResponseDto.java b/src/main/java/com/example/FixLog/dto/main/MainPagePostResponseDto.java index 41755cd..e7b8adc 100644 --- a/src/main/java/com/example/FixLog/dto/main/MainPagePostResponseDto.java +++ b/src/main/java/com/example/FixLog/dto/main/MainPagePostResponseDto.java @@ -9,6 +9,7 @@ @Getter @AllArgsConstructor public class MainPagePostResponseDto { + private Long postId; private String postTitle; private String coverImage; private List tags; diff --git a/src/main/java/com/example/FixLog/mock/PostMockDataInitializer.java b/src/main/java/com/example/FixLog/mock/PostMockDataInitializer.java index d361cc9..212de45 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++) { @@ -66,7 +66,7 @@ public void run(String... args) { Post post = Post.builder() .userId(member) .postTitle("테스트 업그레이드 " + (i + 2)) - .coverImage("https://cdn.example.com/images/test" + (i + 2) + ".jpg") + .coverImage("https://fixlog-bucket.s3.ap-northeast-2.amazonaws.com/default/profile.png" + (i + 2) + ".jpg") .problem("이 게시물은 문제 설명이 200자를 넘도록 작성되었습니다. 문제 발생 상황, 재현 과정, 로그, 화면 캡처 등 다양한 정보가 포함될 수 있습니다. 이 텍스트는 말줄임표가 잘 붙는지 확인하기 위한 용도로 작성되었으며, 검색 결과에서는 200자까지만 보여야 합니다. 이후 내용은 생략될 수 있습니다. 추가 텍스트를 더 붙입니다. 더 붙입니다. 더 붙입니다.") .errorMessage("이건 에러다 keyword 포함") .environment("환경 정보") 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/java/com/example/FixLog/service/MainPageService.java b/src/main/java/com/example/FixLog/service/MainPageService.java index 9c8ff00..66d58f2 100644 --- a/src/main/java/com/example/FixLog/service/MainPageService.java +++ b/src/main/java/com/example/FixLog/service/MainPageService.java @@ -73,6 +73,7 @@ public MainPageResponseDto mainPageView(int sort, int size){ List postList = posts.stream() .map(post -> new MainPagePostResponseDto( + post.getPostId(), post.getPostTitle(), getDefaultCover(post.getCoverImage()), post.getPostTags().stream() @@ -115,6 +116,7 @@ public MainPageResponseDto mainPageFullView(int sort, int page, int size){ List postList = postPage.stream() .map(post -> new MainPagePostResponseDto( + post.getPostId(), post.getPostTitle(), getDefaultCover(post.getCoverImage()), post.getPostTags().stream() diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index b07a7a4..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] #####