|
1 | | -package com.example.FixLog.mock; |
| 1 | +// package com.example.FixLog.mock; |
2 | 2 |
|
3 | | -import com.example.FixLog.domain.bookmark.Bookmark; |
4 | | -import com.example.FixLog.domain.like.PostLike; |
5 | | -import com.example.FixLog.domain.member.Member; |
6 | | -import com.example.FixLog.domain.post.Post; |
7 | | -import com.example.FixLog.domain.post.PostTag; |
8 | | -import com.example.FixLog.domain.tag.Tag; |
9 | | -import com.example.FixLog.repository.MemberRepository; |
10 | | -import com.example.FixLog.repository.bookmark.BookmarkFolderRepository; |
11 | | -import com.example.FixLog.repository.bookmark.BookmarkRepository; |
12 | | -import com.example.FixLog.repository.like.PostLikeRepository; |
13 | | -import com.example.FixLog.repository.post.PostRepository; |
14 | | -import com.example.FixLog.repository.post.PostTagRepository; |
15 | | -import com.example.FixLog.repository.tag.TagRepository; |
16 | | -import jakarta.transaction.Transactional; |
17 | | -import lombok.RequiredArgsConstructor; |
18 | | -import org.springframework.boot.CommandLineRunner; |
19 | | -import org.springframework.core.annotation.Order; |
20 | | -import org.springframework.stereotype.Component; |
| 3 | +// import com.example.FixLog.domain.bookmark.Bookmark; |
| 4 | +// import com.example.FixLog.domain.like.PostLike; |
| 5 | +// import com.example.FixLog.domain.member.Member; |
| 6 | +// import com.example.FixLog.domain.post.Post; |
| 7 | +// import com.example.FixLog.domain.post.PostTag; |
| 8 | +// import com.example.FixLog.domain.tag.Tag; |
| 9 | +// import com.example.FixLog.repository.MemberRepository; |
| 10 | +// import com.example.FixLog.repository.bookmark.BookmarkFolderRepository; |
| 11 | +// import com.example.FixLog.repository.bookmark.BookmarkRepository; |
| 12 | +// import com.example.FixLog.repository.like.PostLikeRepository; |
| 13 | +// import com.example.FixLog.repository.post.PostRepository; |
| 14 | +// import com.example.FixLog.repository.post.PostTagRepository; |
| 15 | +// import com.example.FixLog.repository.tag.TagRepository; |
| 16 | +// import jakarta.transaction.Transactional; |
| 17 | +// import lombok.RequiredArgsConstructor; |
| 18 | +// import org.springframework.boot.CommandLineRunner; |
| 19 | +// import org.springframework.core.annotation.Order; |
| 20 | +// import org.springframework.stereotype.Component; |
21 | 21 |
|
22 | | -import java.time.LocalDateTime; |
23 | | -import java.util.*; |
24 | | -import java.util.stream.Collectors; |
| 22 | +// import java.time.LocalDateTime; |
| 23 | +// import java.util.*; |
| 24 | +// import java.util.stream.Collectors; |
25 | 25 |
|
26 | 26 |
|
27 | | -@Component |
28 | | -@Order(6) |
29 | | -@RequiredArgsConstructor |
30 | | -public class PostMockDataInitializer implements CommandLineRunner { |
| 27 | +// @Component |
| 28 | +// @Order(6) |
| 29 | +// @RequiredArgsConstructor |
| 30 | +// public class PostMockDataInitializer implements CommandLineRunner { |
31 | 31 |
|
32 | | - private final MemberRepository memberRepository; |
33 | | - private final PostRepository postRepository; |
34 | | - private final TagRepository tagRepository; |
35 | | - private final PostTagRepository postTagRepository; |
36 | | - private final PostLikeRepository postLikeRepository; |
37 | | - private final BookmarkRepository bookmarkRepository; |
38 | | - private final BookmarkFolderRepository bookmarkFolderRepository; |
| 32 | +// private final MemberRepository memberRepository; |
| 33 | +// private final PostRepository postRepository; |
| 34 | +// private final TagRepository tagRepository; |
| 35 | +// private final PostTagRepository postTagRepository; |
| 36 | +// private final PostLikeRepository postLikeRepository; |
| 37 | +// private final BookmarkRepository bookmarkRepository; |
| 38 | +// private final BookmarkFolderRepository bookmarkFolderRepository; |
39 | 39 |
|
40 | | - @Override |
41 | | - @Transactional |
42 | | - public void run(String... args) { |
43 | | - if (postRepository.count() > 8) return; // 기존 1개 외 추가 |
| 40 | +// @Override |
| 41 | +// @Transactional |
| 42 | +// public void run(String... args) { |
| 43 | +// if (postRepository.count() > 8) return; // 기존 1개 외 추가 |
44 | 44 |
|
45 | | - Optional<Member> memberOpt = memberRepository.findByEmail("test2@example.com"); |
46 | | - if (memberOpt.isEmpty()) { |
47 | | - System.out.println("test2@example.com 회원 없음"); |
48 | | - return; |
49 | | - } |
| 45 | +// Optional<Member> memberOpt = memberRepository.findByEmail("test2@example.com"); |
| 46 | +// if (memberOpt.isEmpty()) { |
| 47 | +// System.out.println("test2@example.com 회원 없음"); |
| 48 | +// return; |
| 49 | +// } |
50 | 50 |
|
51 | | - Member member = memberOpt.get(); |
52 | | - Map<String, Tag> tagMap = tagRepository.findAll().stream() |
53 | | - .collect(Collectors.toMap(Tag::getTagName, tag -> tag)); |
| 51 | +// Member member = memberOpt.get(); |
| 52 | +// Map<String, Tag> tagMap = tagRepository.findAll().stream() |
| 53 | +// .collect(Collectors.toMap(Tag::getTagName, tag -> tag)); |
54 | 54 |
|
55 | | - List<String[]> config = List.of( |
56 | | - new String[]{"backend", "spring-boot", "java", "null-pointer-exception", "500-error"}, |
57 | | - new String[]{"frontend", "react", "javascript", "undefined-property", "state-missing"}, |
58 | | - new String[]{"machine-learning", "keras", "python", "out-of-memory", "http-error"}, |
59 | | - new String[]{"backend", "node.js", "json", "cors-error", "404-error"}, |
60 | | - new String[]{"frontend", "next.js", "css", "style-break", "render-loop"}, |
61 | | - new String[]{"machine-learning", "scikit-learn", "r", "class-not-found", "permission-error"} |
62 | | - ); |
| 55 | +// List<String[]> config = List.of( |
| 56 | +// new String[]{"backend", "spring-boot", "java", "null-pointer-exception", "500-error"}, |
| 57 | +// new String[]{"frontend", "react", "javascript", "undefined-property", "state-missing"}, |
| 58 | +// new String[]{"machine-learning", "keras", "python", "out-of-memory", "http-error"}, |
| 59 | +// new String[]{"backend", "node.js", "json", "cors-error", "404-error"}, |
| 60 | +// new String[]{"frontend", "next.js", "css", "style-break", "render-loop"}, |
| 61 | +// new String[]{"machine-learning", "scikit-learn", "r", "class-not-found", "permission-error"} |
| 62 | +// ); |
63 | 63 |
|
64 | | - for (int i = 0; i < config.size(); i++) { |
65 | | - String[] tags = config.get(i); |
66 | | - Post post = Post.builder() |
67 | | - .userId(member) |
68 | | - .postTitle("테스트 업그레이드 " + (i + 2)) |
69 | | - .coverImage("https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaultImage.png" + (i + 2) + ".jpg") |
70 | | - .problem("이 게시물은 문제 설명이 200자를 넘도록 작성되었습니다. 문제 발생 상황, 재현 과정, 로그, 화면 캡처 등 다양한 정보가 포함될 수 있습니다. 이 텍스트는 말줄임표가 잘 붙는지 확인하기 위한 용도로 작성되었으며, 검색 결과에서는 200자까지만 보여야 합니다. 이후 내용은 생략될 수 있습니다. 추가 텍스트를 더 붙입니다. 더 붙입니다. 더 붙입니다.") |
71 | | - .errorMessage("이건 에러다 keyword 포함") |
72 | | - .environment("환경 정보") |
73 | | - .reproduceCode("재현 코드") |
74 | | - .solutionCode("해결 코드") |
75 | | - .causeAnalysis("원인 분석") |
76 | | - .referenceLink("https://example.com") |
77 | | - .extraContent("추가 설명") |
78 | | - .createdAt(LocalDateTime.now()) |
79 | | - .editedAt(LocalDateTime.now()) |
80 | | - .build(); |
81 | | - postRepository.save(post); |
| 64 | +// for (int i = 0; i < config.size(); i++) { |
| 65 | +// String[] tags = config.get(i); |
| 66 | +// Post post = Post.builder() |
| 67 | +// .userId(member) |
| 68 | +// .postTitle("테스트 업그레이드 " + (i + 2)) |
| 69 | +// .coverImage("https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaultImage.png" + (i + 2) + ".jpg") |
| 70 | +// .problem("이 게시물은 문제 설명이 200자를 넘도록 작성되었습니다. 문제 발생 상황, 재현 과정, 로그, 화면 캡처 등 다양한 정보가 포함될 수 있습니다. 이 텍스트는 말줄임표가 잘 붙는지 확인하기 위한 용도로 작성되었으며, 검색 결과에서는 200자까지만 보여야 합니다. 이후 내용은 생략될 수 있습니다. 추가 텍스트를 더 붙입니다. 더 붙입니다. 더 붙입니다.") |
| 71 | +// .errorMessage("이건 에러다 keyword 포함") |
| 72 | +// .environment("환경 정보") |
| 73 | +// .reproduceCode("재현 코드") |
| 74 | +// .solutionCode("해결 코드") |
| 75 | +// .causeAnalysis("원인 분석") |
| 76 | +// .referenceLink("https://example.com") |
| 77 | +// .extraContent("추가 설명") |
| 78 | +// .createdAt(LocalDateTime.now()) |
| 79 | +// .editedAt(LocalDateTime.now()) |
| 80 | +// .build(); |
| 81 | +// postRepository.save(post); |
82 | 82 |
|
83 | | - List<PostTag> postTags = Arrays.stream(tags) |
84 | | - .map(tagMap::get) |
85 | | - .filter(Objects::nonNull) |
86 | | - .map(tag -> new PostTag(post, tag)) |
87 | | - .toList(); |
88 | | - postTagRepository.saveAll(postTags); |
| 83 | +// List<PostTag> postTags = Arrays.stream(tags) |
| 84 | +// .map(tagMap::get) |
| 85 | +// .filter(Objects::nonNull) |
| 86 | +// .map(tag -> new PostTag(post, tag)) |
| 87 | +// .toList(); |
| 88 | +// postTagRepository.saveAll(postTags); |
89 | 89 |
|
90 | | - postLikeRepository.save(new PostLike(member, post)); |
| 90 | +// postLikeRepository.save(new PostLike(member, post)); |
91 | 91 |
|
92 | | - bookmarkFolderRepository.findFirstByUserId(member).ifPresent(folder -> { |
93 | | - Bookmark bookmark = new Bookmark(folder, post); |
94 | | - bookmarkRepository.save(bookmark); |
95 | | - }); |
96 | | - } |
| 92 | +// bookmarkFolderRepository.findFirstByUserId(member).ifPresent(folder -> { |
| 93 | +// Bookmark bookmark = new Bookmark(folder, post); |
| 94 | +// bookmarkRepository.save(bookmark); |
| 95 | +// }); |
| 96 | +// } |
97 | 97 |
|
98 | | - System.out.println("test2@example.com 사용자의 게시물 6개 + 태그/좋아요/북마크 생성 완료"); |
99 | | - } |
100 | | -} |
| 98 | +// System.out.println("test2@example.com 사용자의 게시물 6개 + 태그/좋아요/북마크 생성 완료"); |
| 99 | +// } |
| 100 | +// } |
0 commit comments