diff --git a/src/main/java/com/example/spot/service/studypost/StudyPostQueryServiceImpl.java b/src/main/java/com/example/spot/service/studypost/StudyPostQueryServiceImpl.java index 0ee04353..647a9bb3 100644 --- a/src/main/java/com/example/spot/service/studypost/StudyPostQueryServiceImpl.java +++ b/src/main/java/com/example/spot/service/studypost/StudyPostQueryServiceImpl.java @@ -128,8 +128,8 @@ public StudyPostResDTO.PostDetailDTO getPost(Long studyId, Long postId) { Integer commentNum = studyPostCommentRepository.findAllByStudyPostId(postId).size(); boolean isLiked = studyLikedPostRepository.existsByMemberIdAndStudyPostId(memberId, studyPost.getId()); - - return StudyPostResDTO.PostDetailDTO.toDTO(studyPost, commentNum, isLiked); + boolean isWriter = studyPost.getMember().getId().equals(memberId); + return StudyPostResDTO.PostDetailDTO.toDTO(studyPost, commentNum, isLiked, isWriter); } /* ----------------------------- 스터디 게시글 댓글 관련 API ------------------------------------- */ diff --git a/src/main/java/com/example/spot/web/dto/memberstudy/response/StudyPostResDTO.java b/src/main/java/com/example/spot/web/dto/memberstudy/response/StudyPostResDTO.java index 1d891068..f6ec2274 100644 --- a/src/main/java/com/example/spot/web/dto/memberstudy/response/StudyPostResDTO.java +++ b/src/main/java/com/example/spot/web/dto/memberstudy/response/StudyPostResDTO.java @@ -99,9 +99,10 @@ public static class PostDetailDTO { private final Integer hitNum; private final Integer commentNum; private final Boolean isLiked; + private final Boolean isWriter; private final List studyPostImages; - public static PostDetailDTO toDTO(StudyPost studyPost, Integer commentNum, boolean isLiked) { + public static PostDetailDTO toDTO(StudyPost studyPost, Integer commentNum, boolean isLiked, boolean isWriter) { return PostDetailDTO.builder() .member(PostMemberDTO.toDTO(studyPost.getMember())) .postId(studyPost.getId()) @@ -114,6 +115,7 @@ public static PostDetailDTO toDTO(StudyPost studyPost, Integer commentNum, boole .hitNum(studyPost.getHitNum()) .commentNum(commentNum) .isLiked(isLiked) + .isWriter(isWriter) .studyPostImages(studyPost.getImages().stream() .map(ImageDTO::toDTO) .toList())