From a890498f12a7148bf2734a68e3cc21ccedb0134b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B5=AC=ED=99=98=EC=A4=80/=EB=AA=A8=EA=B1=B4?= Date: Wed, 10 Jul 2024 17:23:22 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20Feat:=20Invitation=20accept=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=ED=95=98=EB=93=9C=EC=BD=94=EB=94=A9=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/invitation/business/InvitationMapper.java | 2 ++ .../api/invitation/business/InvitationService.java | 7 +++++-- .../invitation/implement/InvitationQueryAdapter.java | 6 ++++++ .../presentation/dto/InvitationResponseDTO.java | 1 + .../server/global/entity/Invitation/Invitation.java | 1 + .../exception/ThrowClass/InvitationException.java | 10 ++++++++++ 6 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 src/main/java/treehouse/server/global/exception/ThrowClass/InvitationException.java diff --git a/src/main/java/treehouse/server/api/invitation/business/InvitationMapper.java b/src/main/java/treehouse/server/api/invitation/business/InvitationMapper.java index 970222a..252841b 100644 --- a/src/main/java/treehouse/server/api/invitation/business/InvitationMapper.java +++ b/src/main/java/treehouse/server/api/invitation/business/InvitationMapper.java @@ -23,6 +23,7 @@ public class InvitationMapper { public static InvitationResponseDTO.getInvitation toGetInvitation (Invitation invitation, List treeMemberProfileImages) { return InvitationResponseDTO.getInvitation.builder() .invitationId(invitation.getId()) + .treehouseId(invitation.getTreeHouse().getId()) .treehouseName(invitation.getTreeHouse().getName()) .senderName(invitation.getSender().getName()) .senderProfileImageUrl(invitation.getSender().getProfileImageUrl()) @@ -63,6 +64,7 @@ public static Invitation toInvitation(String phoneNumber, Member sender, User re .phone(phoneNumber) .expiredAt(sevenDaysLater) .status(InvitationStatus.PENDING) + .treeHouse(treeHouse) .build(); } diff --git a/src/main/java/treehouse/server/api/invitation/business/InvitationService.java b/src/main/java/treehouse/server/api/invitation/business/InvitationService.java index 57f80c2..11fb296 100644 --- a/src/main/java/treehouse/server/api/invitation/business/InvitationService.java +++ b/src/main/java/treehouse/server/api/invitation/business/InvitationService.java @@ -15,6 +15,8 @@ import treehouse.server.global.entity.User.User; import treehouse.server.global.entity.member.Member; import treehouse.server.global.entity.treeHouse.TreeHouse; +import treehouse.server.global.exception.GlobalErrorCode; +import treehouse.server.global.exception.ThrowClass.InvitationException; import treehouse.server.global.exception.ThrowClass.UserException; import java.util.List; @@ -64,7 +66,6 @@ public InvitationResponseDTO.myInvitationInfo getMyInvitationInfo(User user){ @Transactional public InvitationResponseDTO.createInvitation createInvitation(User user, InvitationRequestDTO.createInvitation request){ - // 트리 찾기 TreeHouse treehouse = treehouseQueryAdapter.getTreehouseById(request.getTreehouseId()); // 초대 멤버 찾기 @@ -92,8 +93,10 @@ public InvitationResponseDTO.createInvitation createInvitation(User user, Invita public InvitationResponseDTO.invitationAccept decisionInvitation(User user, InvitationRequestDTO.invitationAcceptDecision request){ // 해당 User 에게 온 초대장인지 검증하는 로직 추가 Long treehouseId = 0L; + Invitation invitation = invitationQueryAdapter.findById(request.getInvitationId()); + if (request.isAcceptDecision()==true) { - treehouseId = 1L; // treehouse 관련 로직 개발 후, invitation.getTreeHouse.getId() 등으로 바꾸기 + treehouseId = invitation.getTreeHouse().getId(); // treehouse 관련 로직 개발 후, invitation.getTreeHouse.getId() 등으로 바꾸기 } return InvitationMapper.toInvitationResult(treehouseId); } diff --git a/src/main/java/treehouse/server/api/invitation/implement/InvitationQueryAdapter.java b/src/main/java/treehouse/server/api/invitation/implement/InvitationQueryAdapter.java index 1532b24..9387b9b 100644 --- a/src/main/java/treehouse/server/api/invitation/implement/InvitationQueryAdapter.java +++ b/src/main/java/treehouse/server/api/invitation/implement/InvitationQueryAdapter.java @@ -8,6 +8,7 @@ import treehouse.server.global.entity.Invitation.Invitation; import treehouse.server.global.entity.User.User; import treehouse.server.global.exception.GlobalErrorCode; +import treehouse.server.global.exception.ThrowClass.InvitationException; import treehouse.server.global.exception.ThrowClass.UserException; import java.util.List; @@ -26,4 +27,9 @@ public List findAllByPhone(String phone) { public Boolean existByPhoneNumber(String phoneNumber) { return invitationRepository.existsByPhone(phoneNumber); } + + public Invitation findById(Long invitationId) { + return invitationRepository.findById(invitationId) + .orElseThrow(() -> new InvitationException(GlobalErrorCode.INVITATION_NOT_FOUND)); + } } diff --git a/src/main/java/treehouse/server/api/invitation/presentation/dto/InvitationResponseDTO.java b/src/main/java/treehouse/server/api/invitation/presentation/dto/InvitationResponseDTO.java index a973a18..108786c 100644 --- a/src/main/java/treehouse/server/api/invitation/presentation/dto/InvitationResponseDTO.java +++ b/src/main/java/treehouse/server/api/invitation/presentation/dto/InvitationResponseDTO.java @@ -13,6 +13,7 @@ public class InvitationResponseDTO { @AllArgsConstructor public static class getInvitation { private Long invitationId; + private Long treehouseId; private String treehouseName; private String senderName; private String senderProfileImageUrl; diff --git a/src/main/java/treehouse/server/global/entity/Invitation/Invitation.java b/src/main/java/treehouse/server/global/entity/Invitation/Invitation.java index 6e5fea5..cca3b28 100644 --- a/src/main/java/treehouse/server/global/entity/Invitation/Invitation.java +++ b/src/main/java/treehouse/server/global/entity/Invitation/Invitation.java @@ -23,6 +23,7 @@ public class Invitation extends BaseDateTimeEntity { private String phone; @Setter + @Enumerated(EnumType.STRING) private InvitationStatus status; private LocalDateTime expiredAt; //초대장 만료일자 diff --git a/src/main/java/treehouse/server/global/exception/ThrowClass/InvitationException.java b/src/main/java/treehouse/server/global/exception/ThrowClass/InvitationException.java new file mode 100644 index 0000000..b484d0d --- /dev/null +++ b/src/main/java/treehouse/server/global/exception/ThrowClass/InvitationException.java @@ -0,0 +1,10 @@ +package treehouse.server.global.exception.ThrowClass; + +import treehouse.server.global.exception.BaseErrorCode; + +public class InvitationException extends GeneralException{ + + public InvitationException(BaseErrorCode errorCode) { + super(errorCode); + } +} From 13a5d293f8daeafbeaa8bf6365cdb26a8f139c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B5=AC=ED=99=98=EC=A4=80/=EB=AA=A8=EA=B1=B4?= Date: Wed, 10 Jul 2024 18:02:54 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9C=A8=20Feat:=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=EA=B8=80/=EB=8C=93=EA=B8=80=20=EC=9E=91=EC=84=B1=EC=9E=90=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EB=8D=B0=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=EC=97=90=EC=84=9C=20Branch=20=EC=A7=80=EC=88=98=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/api/comment/business/CommentMapper.java | 9 +++++---- .../api/comment/business/CommentService.java | 9 +++++++-- .../server/api/member/business/MemberMapper.java | 10 +++++----- .../server/api/post/business/PostMapper.java | 9 +++++---- .../server/api/post/business/PostService.java | 14 +++++++++++--- 5 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/main/java/treehouse/server/api/comment/business/CommentMapper.java b/src/main/java/treehouse/server/api/comment/business/CommentMapper.java index 975928a..b760d37 100644 --- a/src/main/java/treehouse/server/api/comment/business/CommentMapper.java +++ b/src/main/java/treehouse/server/api/comment/business/CommentMapper.java @@ -4,6 +4,7 @@ import treehouse.server.api.member.business.MemberMapper; import treehouse.server.api.reaction.presentation.dto.ReactionResponseDTO; import treehouse.server.global.common.util.TimeFormatter; +import treehouse.server.global.entity.branch.Branch; import treehouse.server.global.entity.comment.Comment; import treehouse.server.global.entity.comment.CommentType; import treehouse.server.global.entity.member.Member; @@ -14,7 +15,7 @@ public class CommentMapper { - public static CommentResponseDTO.CommentInfoDto toCommentInfoDto(Comment comment, ReactionResponseDTO.getReactionList reactionList, + public static CommentResponseDTO.CommentInfoDto toCommentInfoDto(Member member, List branches, Comment comment, ReactionResponseDTO.getReactionList reactionList, List replyInfoDtoList) { return CommentResponseDTO.CommentInfoDto.builder() .commentedAt(TimeFormatter.format(comment.getCreatedAt())) @@ -22,18 +23,18 @@ public static CommentResponseDTO.CommentInfoDto toCommentInfoDto(Comment comment .context(comment.getContent()) .reactionList(reactionList) .replyList(replyInfoDtoList) - .memberProfile(MemberMapper.toGetWriterProfile(comment.getWriter())) + .memberProfile(MemberMapper.toGetWriterProfile(member, comment.getWriter(), branches)) .build(); } - public static CommentResponseDTO.ReplyInfoDto toReplyInfoDto(Comment comment, ReactionResponseDTO.getReactionList reactionList) { + public static CommentResponseDTO.ReplyInfoDto toReplyInfoDto(Member member, List branches, Comment comment, ReactionResponseDTO.getReactionList reactionList) { return CommentResponseDTO.ReplyInfoDto.builder() .commentedAt(TimeFormatter.format(comment.getCreatedAt())) .commentId(comment.getId()) .context(comment.getContent()) .reactionList(reactionList) - .memberProfile(MemberMapper.toGetWriterProfile(comment.getWriter())) + .memberProfile(MemberMapper.toGetWriterProfile(member, comment.getWriter(), branches)) .build(); } diff --git a/src/main/java/treehouse/server/api/comment/business/CommentService.java b/src/main/java/treehouse/server/api/comment/business/CommentService.java index 1ad8cd7..7229b8e 100644 --- a/src/main/java/treehouse/server/api/comment/business/CommentService.java +++ b/src/main/java/treehouse/server/api/comment/business/CommentService.java @@ -7,6 +7,7 @@ import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import treehouse.server.api.branch.implementation.BranchQueryAdapter; import treehouse.server.api.comment.implementation.CommentCommandAdapter; import treehouse.server.api.comment.implementation.CommentQueryAdapter; import treehouse.server.api.comment.presentation.dto.CommentRequestDTO; @@ -23,6 +24,7 @@ import treehouse.server.api.treehouse.implementation.TreehouseQueryAdapter; import treehouse.server.api.user.implement.UserQueryAdapter; import treehouse.server.global.entity.User.User; +import treehouse.server.global.entity.branch.Branch; import treehouse.server.global.entity.comment.Comment; import treehouse.server.global.entity.comment.CommentType; import treehouse.server.global.entity.member.Member; @@ -59,6 +61,8 @@ public class CommentService { private final ReactionCommandAdapter reactionCommandAdapter; private final ReactionQueryAdapter reactionQueryAdapter; + private final BranchQueryAdapter branchQueryAdapter; + public void reportComment(User user, CommentRequestDTO.reportComment request, Long treehouseId, Long postId, Long commentId){ @@ -86,6 +90,7 @@ public CommentResponseDTO.CommentListDto getCommentResponseList(User user, Long TreeHouse treehouse = treehouseQueryAdapter.getTreehouseById(treehouseId); Member member = memberQueryAdapter.findByUserAndTreehouse(user, treehouse); + List branches = branchQueryAdapter.findAllByTreeHouse(treehouse); Pageable pageable = PageRequest.of(page, 10, Sort.by(Sort.Direction.DESC, "createdAt")); // List commentListByPostId = commentQueryAdapter.getCommentListByPostId(postId, pageable); @@ -134,11 +139,11 @@ public CommentResponseDTO.CommentListDto getCommentResponseList(User user, Long )); ReactionResponseDTO.getReactionList replyReactionDtoList = ReactionMapper.toGetReactionList(replyReactionMap); - return CommentMapper.toReplyInfoDto(reply, replyReactionDtoList); + return CommentMapper.toReplyInfoDto(member, branches, reply, replyReactionDtoList); }) .collect(Collectors.toList()); - return CommentMapper.toCommentInfoDto(comment, reactionDtoList,replyInfoDtoList); + return CommentMapper.toCommentInfoDto(member, branches, comment, reactionDtoList,replyInfoDtoList); }) .collect(Collectors.toList()); diff --git a/src/main/java/treehouse/server/api/member/business/MemberMapper.java b/src/main/java/treehouse/server/api/member/business/MemberMapper.java index c914ecb..43e6bf7 100644 --- a/src/main/java/treehouse/server/api/member/business/MemberMapper.java +++ b/src/main/java/treehouse/server/api/member/business/MemberMapper.java @@ -38,12 +38,12 @@ public static MemberResponseDTO.registerMember toRegister(Member member) { .build(); } - public static MemberResponseDTO.getWriterProfile toGetWriterProfile(Member member) { + public static MemberResponseDTO.getWriterProfile toGetWriterProfile(Member member, Member writer, List branches) { return MemberResponseDTO.getWriterProfile.builder() - .memberId(member.getId()) - .memberName(member.getName()) - .memberProfileImageUrl(member.getProfileImageUrl()) - .memberBranch(3) // Branch 기능 개발 이후 변경 예정 + .memberId(writer.getId()) + .memberName(writer.getName()) + .memberProfileImageUrl(writer.getProfileImageUrl()) + .memberBranch(BranchUtil.calculateBranchDegree(branches, member.getId(), writer.getId())) .build(); } diff --git a/src/main/java/treehouse/server/api/post/business/PostMapper.java b/src/main/java/treehouse/server/api/post/business/PostMapper.java index b565b4a..b03aabb 100644 --- a/src/main/java/treehouse/server/api/post/business/PostMapper.java +++ b/src/main/java/treehouse/server/api/post/business/PostMapper.java @@ -7,6 +7,7 @@ import treehouse.server.api.member.business.MemberMapper; import treehouse.server.api.reaction.presentation.dto.ReactionResponseDTO; import treehouse.server.global.common.util.TimeFormatter; +import treehouse.server.global.entity.branch.Branch; import treehouse.server.global.entity.member.Member; import treehouse.server.global.entity.post.Post; import treehouse.server.global.entity.post.PostImage; @@ -19,9 +20,9 @@ @NoArgsConstructor(access = AccessLevel.PRIVATE) public class PostMapper { - public static PostResponseDTO.getPostDetails toGetPostDetails(Post post, List postImageUrlList, ReactionResponseDTO.getReactionList reactionList) { + public static PostResponseDTO.getPostDetails toGetPostDetails(Member member, List branches, Post post, List postImageUrlList, ReactionResponseDTO.getReactionList reactionList) { return PostResponseDTO.getPostDetails.builder() - .memberProfile(MemberMapper.toGetWriterProfile(post.getWriter())) + .memberProfile(MemberMapper.toGetWriterProfile(member, post.getWriter(), branches)) .postId(post.getId()) .context(post.getContent()) .pictureUrlList(postImageUrlList) @@ -42,9 +43,9 @@ public static PostResponseDTO.getOnlyPostDetail toGetOnlyPostDetails(Post post, .build(); } - public static PostResponseDTO.getMemberPostList toGetMemberPostList(Member targetMember, List onlyPostDetailList) { + public static PostResponseDTO.getMemberPostList toGetMemberPostList(Member member, Member targetMember, List onlyPostDetailList, List branches) { return PostResponseDTO.getMemberPostList.builder() - .memberProfile(MemberMapper.toGetWriterProfile(targetMember)) + .memberProfile(MemberMapper.toGetWriterProfile(member, targetMember, branches)) .postList(onlyPostDetailList) .build(); } diff --git a/src/main/java/treehouse/server/api/post/business/PostService.java b/src/main/java/treehouse/server/api/post/business/PostService.java index dec842f..27cd099 100644 --- a/src/main/java/treehouse/server/api/post/business/PostService.java +++ b/src/main/java/treehouse/server/api/post/business/PostService.java @@ -9,6 +9,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Transactional; +import treehouse.server.api.branch.implementation.BranchQueryAdapter; import treehouse.server.api.member.implementation.MemberQueryAdapter; import treehouse.server.api.post.implement.PostCommandAdapter; import treehouse.server.api.post.implement.PostImageCommandAdapter; @@ -25,6 +26,7 @@ import treehouse.server.api.treehouse.implementation.TreehouseQueryAdapter; import treehouse.server.global.constants.Consts; import treehouse.server.global.entity.User.User; +import treehouse.server.global.entity.branch.Branch; import treehouse.server.global.entity.member.Member; import treehouse.server.global.entity.post.Post; import treehouse.server.global.entity.post.PostImage; @@ -65,6 +67,9 @@ public class PostService { private final ReactionQueryAdapter reactionQueryAdapter; private final ReportQueryAdapter reportQueryAdapter; + + private final BranchQueryAdapter branchQueryAdapter; + /** * 게시글 상세조회 * @@ -100,7 +105,8 @@ public PostResponseDTO.getPostDetails getPostDetails(User user, Long postId, Lon ReactionResponseDTO.getReactionList reactionDtoList = ReactionMapper.toGetReactionList(reactionMap); - return PostMapper.toGetPostDetails(post, postImageUrlList, reactionDtoList); + List branches = branchQueryAdapter.findAllByTreeHouse(treehouse); // 트리하우스 내 모든 브랜치 조회 + return PostMapper.toGetPostDetails(member, branches, post, postImageUrlList, reactionDtoList); } public PostResponseDTO.createPostResult createPost(User user, PostRequestDTO.createPost request, Long treehouseId) { @@ -142,6 +148,7 @@ public List getPosts (User user, Long treehouseI TreeHouse treehouse = treehouseQueryAdapter.getTreehouseById(treehouseId); Member member = memberQueryAdapter.findByUserAndTreehouse(user, treehouse); + List branches = branchQueryAdapter.findAllByTreeHouse(treehouse); Pageable pageable = PageRequest.of(page, 10, Sort.by(Sort.Direction.DESC, "createdAt")); List postList = postQueryAdapter.findAllByTreehouse(treehouse, pageable); @@ -170,7 +177,7 @@ public List getPosts (User user, Long treehouseI )); ReactionResponseDTO.getReactionList reactionDtoList = ReactionMapper.toGetReactionList(reactionMap); - return PostMapper.toGetPostDetails(post, postImageUrlList, reactionDtoList); + return PostMapper.toGetPostDetails(member, branches, post, postImageUrlList, reactionDtoList); }) .collect(Collectors.toList()); @@ -183,6 +190,7 @@ public PostResponseDTO.getMemberPostList getMemberPosts(User user, Long targetMe TreeHouse treehouse = treehouseQueryAdapter.getTreehouseById(treehouseId); Member member = memberQueryAdapter.findByUserAndTreehouse(user, treehouse); Member targetMember = memberQueryAdapter.findById(targetMemberId); + List branches = branchQueryAdapter.findAllByTreeHouse(treehouse); List postListByMember = postQueryAdapter.findAllByTreeHouseAndWriter(treehouse, targetMember, pageable); @@ -211,7 +219,7 @@ public PostResponseDTO.getMemberPostList getMemberPosts(User user, Long targetMe }) .collect(Collectors.toList()); - return PostMapper.toGetMemberPostList(targetMember, postDtoList); + return PostMapper.toGetMemberPostList(member, targetMember, postDtoList, branches); } From ff16f04139055760b7c8bf704832328695820736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B5=AC=ED=99=98=EC=A4=80/=EB=AA=A8=EA=B1=B4?= Date: Tue, 16 Jul 2024 09:59:26 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E2=9C=A8=20Feat:=20=ED=8A=B8=EB=A6=AC?= =?UTF-8?q?=ED=95=98=EC=9A=B0=EC=8A=A4=20=EC=A0=95=EB=B3=B4=EB=A5=BC=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=ED=95=98=EB=8A=94=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/treehouse/business/TreehouseMapper.java | 9 +++++++++ .../api/treehouse/business/TreehouseService.java | 7 +++++++ .../api/treehouse/presentation/TreehouseApi.java | 13 +++++++++---- .../presentation/dto/TreehouseResponseDTO.java | 12 ++++++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/main/java/treehouse/server/api/treehouse/business/TreehouseMapper.java b/src/main/java/treehouse/server/api/treehouse/business/TreehouseMapper.java index fcaea35..d3c9355 100644 --- a/src/main/java/treehouse/server/api/treehouse/business/TreehouseMapper.java +++ b/src/main/java/treehouse/server/api/treehouse/business/TreehouseMapper.java @@ -20,4 +20,13 @@ public static TreehouseResponseDTO.createTreehouse toCreateTreehouse(TreeHouse t .treehouseId(treehouse.getId()) .build(); } + + public static TreehouseResponseDTO.getTreehouseDetails toGetTreehouseDetails(TreeHouse treehouse) { + return TreehouseResponseDTO.getTreehouseDetails.builder() + .treehouseId(treehouse.getId()) + .treehouseName(treehouse.getName()) + .treehouseSize(treehouse.getMemberList().size()) + .treehouseImageUrl(null) //TODO: 이미지 URL 설정 + .build(); + } } diff --git a/src/main/java/treehouse/server/api/treehouse/business/TreehouseService.java b/src/main/java/treehouse/server/api/treehouse/business/TreehouseService.java index fa3ca36..4684310 100644 --- a/src/main/java/treehouse/server/api/treehouse/business/TreehouseService.java +++ b/src/main/java/treehouse/server/api/treehouse/business/TreehouseService.java @@ -6,6 +6,7 @@ import org.springframework.transaction.annotation.Transactional; import treehouse.server.api.member.implementation.MemberQueryAdapter; import treehouse.server.api.treehouse.implementation.TreehouseCommandAdapter; +import treehouse.server.api.treehouse.implementation.TreehouseQueryAdapter; import treehouse.server.api.treehouse.presentation.dto.TreehouseRequestDTO; import treehouse.server.api.treehouse.presentation.dto.TreehouseResponseDTO; import treehouse.server.global.entity.treeHouse.TreeHouse; @@ -17,6 +18,7 @@ public class TreehouseService { private final TreehouseCommandAdapter treehouseCommandAdapter; + private final TreehouseQueryAdapter treehouseQueryAdapter; private final MemberQueryAdapter memberQueryAdapter; @@ -28,5 +30,10 @@ public TreehouseResponseDTO.createTreehouse createTreehouse(TreehouseRequestDTO. return TreehouseMapper.toCreateTreehouse(savedTreehouse); } + public TreehouseResponseDTO.getTreehouseDetails getTreehouseDetails(Long treehouseId) { + TreeHouse treehouse = treehouseQueryAdapter.getTreehouseById(treehouseId); + return TreehouseMapper.toGetTreehouseDetails(treehouse); + } + } diff --git a/src/main/java/treehouse/server/api/treehouse/presentation/TreehouseApi.java b/src/main/java/treehouse/server/api/treehouse/presentation/TreehouseApi.java index c0ea22e..536ac88 100644 --- a/src/main/java/treehouse/server/api/treehouse/presentation/TreehouseApi.java +++ b/src/main/java/treehouse/server/api/treehouse/presentation/TreehouseApi.java @@ -5,10 +5,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import treehouse.server.api.treehouse.business.TreehouseService; import treehouse.server.api.treehouse.presentation.dto.TreehouseRequestDTO; import treehouse.server.api.treehouse.presentation.dto.TreehouseResponseDTO; @@ -31,4 +28,12 @@ public CommonResponse createTreehouse( ) { return CommonResponse.onSuccess(treehouseService.createTreehouse(request)); } + + @GetMapping("/{treehouseId}") + @Operation(summary = "트리하우스 조회 🔑", description = "트리하우스 정보를 조회합니다.") + public CommonResponse getTreehouseDetails( + @PathVariable Long treehouseId + ) { + return CommonResponse.onSuccess(treehouseService.getTreehouseDetails(treehouseId)); + } } diff --git a/src/main/java/treehouse/server/api/treehouse/presentation/dto/TreehouseResponseDTO.java b/src/main/java/treehouse/server/api/treehouse/presentation/dto/TreehouseResponseDTO.java index a916f93..f60888a 100644 --- a/src/main/java/treehouse/server/api/treehouse/presentation/dto/TreehouseResponseDTO.java +++ b/src/main/java/treehouse/server/api/treehouse/presentation/dto/TreehouseResponseDTO.java @@ -13,4 +13,16 @@ public static class createTreehouse { private Long treehouseId; } + + @Builder + @Getter + @NoArgsConstructor + @AllArgsConstructor + public static class getTreehouseDetails { + + private Long treehouseId; + private String treehouseName; + private Integer treehouseSize; + private String treehouseImageUrl; + } }