From 60e9907229c2079d8dc6c2787bc3a4e7008cd0b8 Mon Sep 17 00:00:00 2001 From: jihyun Date: Thu, 1 May 2025 04:40:00 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[=20feat=20]=20:=20=EC=9D=B4=EB=A9=94?= =?UTF-8?q?=EC=9D=BC=20=EC=9D=B8=EC=A6=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../booktree/user/service/UserService.java | 16 +++++++--- .../src/app/components/CommentsSection.tsx | 31 +++++++++++++++++-- .../src/app/post/[postId]/detail/get/page.tsx | 1 + 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/com/example/booktree/user/service/UserService.java b/backend/src/main/java/com/example/booktree/user/service/UserService.java index 093831ea..a614a7fe 100644 --- a/backend/src/main/java/com/example/booktree/user/service/UserService.java +++ b/backend/src/main/java/com/example/booktree/user/service/UserService.java @@ -4,6 +4,8 @@ import com.example.booktree.category.entity.Category; import com.example.booktree.category.repository.CategoryRepository; import com.example.booktree.comment.repository.CommentRepository; +import com.example.booktree.email.entity.EmailMessage; +import com.example.booktree.email.service.EmailService; import com.example.booktree.exception.BusinessLogicException; import com.example.booktree.exception.ExceptionCode; import com.example.booktree.follow.repository.FollowRepository; @@ -60,6 +62,7 @@ public class UserService { private final PasswordEncoder passwordEncoder; + private final EmailService emailService; private final TokenService tokenService; private final ImageService imageService; private static final String USER_IMAGE= DEFAULT_USER_IMAGE; @@ -139,16 +142,19 @@ public User findUserByEmail(String email){ } - //임시 비밀번호 발급 - 이메일로 비밀번호 - public String findPasswordByEmail(String email){ - + public void findPasswordByEmail(String email){ + EmailMessage emailMessage = EmailMessage.builder() + .to(email) + .subject("[BookTree] 임시 비밀번호 발급") + .build(); User user = findUserByEmail(email); String randomPassword = CreateRandomNumber.randomNumber(); user.setPassword(passwordEncoder.encode(randomPassword)); userRepository.save(user); - return randomPassword; - } + emailService.sendMail(emailMessage, "password",randomPassword); + + } //임시 비밀번호 발급 - 이메일, 핸드폰으로 비밀번호 public String findPasswordByEmailAndPhone(UserPasswordRequestDto.FindPwByEmailAndPhone findPwByEmailAndPhone){ diff --git a/frontend/src/app/components/CommentsSection.tsx b/frontend/src/app/components/CommentsSection.tsx index 4ee2b9e3..866ba1a1 100644 --- a/frontend/src/app/components/CommentsSection.tsx +++ b/frontend/src/app/components/CommentsSection.tsx @@ -334,10 +334,35 @@ export function CommentsSection({ postId }: { postId: number }) { }, [activeCommentId, activeReplyPopoverId]) // ─── 프로필 이미지 불러오기 ──────────────────────────────────── + // useEffect(() => { + // if (!comments.length) return + // const ids = Array.from( + // new Set([...comments.map((c) => c.userId), ...comments.flatMap((c) => c.replies.map((r) => r.userId))]), + // ) + // async function fetchUserImages() { + // const map: Record = {} + // await Promise.all( + // ids.map(async (id) => { + // try { + // const res = await fetch(`${API}/api/v1/users/get/profile/${id}`) + // if (!res.ok) return + // const { imageUrl } = await res.json() + // map[id] = imageUrl + // } catch {} + // }), + // ) + // setUserImages(map) + // } + // fetchUserImages() + // }, [comments]) + useEffect(() => { - if (!comments.length) return + if (!rawComments.length) return const ids = Array.from( - new Set([...comments.map((c) => c.userId), ...comments.flatMap((c) => c.replies.map((r) => r.userId))]), + new Set([ + ...rawComments.map((c) => c.userId), + ...rawComments.flatMap((c) => c.replies.map((r) => r.userId)), + ]), ) async function fetchUserImages() { const map: Record = {} @@ -354,7 +379,7 @@ export function CommentsSection({ postId }: { postId: number }) { setUserImages(map) } fetchUserImages() - }, [comments]) + }, [rawComments]) // ─── 렌더링 ──────────────────────────────────────────────────── return ( diff --git a/frontend/src/app/post/[postId]/detail/get/page.tsx b/frontend/src/app/post/[postId]/detail/get/page.tsx index 313fe8ed..0b9b5a9e 100644 --- a/frontend/src/app/post/[postId]/detail/get/page.tsx +++ b/frontend/src/app/post/[postId]/detail/get/page.tsx @@ -223,6 +223,7 @@ export default function DetailPage() { }, [postId]) useEffect(() => { + if (!post?.causerId) return const fetchUserProfile = async () => { if (!post?.causerId) return // post.causerId가 없으면 요청하지 않음 From 8a9199cdb23949eb7663261b71f320bce7d6de79 Mon Sep 17 00:00:00 2001 From: jihyun Date: Thu, 1 May 2025 04:43:49 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[=20feat=20]=20:=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EC=95=88=ED=95=A8=20=EB=8B=A4=EC=8B=9C=20=EB=90=98=EB=8F=8C?= =?UTF-8?q?=EB=A6=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/app/post/[postId]/detail/get/page.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/app/post/[postId]/detail/get/page.tsx b/frontend/src/app/post/[postId]/detail/get/page.tsx index 0b9b5a9e..313fe8ed 100644 --- a/frontend/src/app/post/[postId]/detail/get/page.tsx +++ b/frontend/src/app/post/[postId]/detail/get/page.tsx @@ -223,7 +223,6 @@ export default function DetailPage() { }, [postId]) useEffect(() => { - if (!post?.causerId) return const fetchUserProfile = async () => { if (!post?.causerId) return // post.causerId가 없으면 요청하지 않음