Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/main/java/com/example/FixLog/domain/post/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/example/FixLog/domain/tag/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@Getter
@AllArgsConstructor
public class MainPagePostResponseDto {
private Long postId;
private String postTitle;
private String coverImage;
private List<String> tags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ public void run(String... args) {
.collect(Collectors.toMap(Tag::getTagName, tag -> tag));

List<String[]> 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++) {
String[] tags = config.get(i);
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("환경 정보")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ public Page<SearchPostDto> searchByKeywordAndTags(String keyword, List<String> t

// 2. 태그 조건 (AND 조건)
if (tags != null && !tags.isEmpty()) {
List<String> sanitizedTags = tags.stream()
.filter(tag -> tag != null && !tag.trim().isEmpty()) // null/빈값 제거
.map(String::trim) // 공백 제거
.toList();

NumberExpression<Long> count = postTag.tagId.tagId.count();

JPQLQuery<Long> 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));
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/example/FixLog/service/MainPageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public MainPageResponseDto mainPageView(int sort, int size){

List<MainPagePostResponseDto> postList = posts.stream()
.map(post -> new MainPagePostResponseDto(
post.getPostId(),
post.getPostTitle(),
getDefaultCover(post.getCoverImage()),
post.getPostTags().stream()
Expand Down Expand Up @@ -115,6 +116,7 @@ public MainPageResponseDto mainPageFullView(int sort, int page, int size){

List<MainPagePostResponseDto> postList = postPage.stream()
.map(post -> new MainPagePostResponseDto(
post.getPostId(),
post.getPostTitle(),
getDefaultCover(post.getCoverImage()),
post.getPostTags().stream()
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spring.application.name=FixLog
## JWT
#jwt.secret=${JWT_KEY}
#
## Spring Security 디버깅 로그
## Spring Security
#logging.level.org.springframework.security=DEBUG

##### [PROD] #####
Expand Down