diff --git a/src/main/java/com/example/helloworldmvc/converter/CommunityConverter.java b/src/main/java/com/example/helloworldmvc/converter/CommunityConverter.java index 8a2fc06..72b4e87 100644 --- a/src/main/java/com/example/helloworldmvc/converter/CommunityConverter.java +++ b/src/main/java/com/example/helloworldmvc/converter/CommunityConverter.java @@ -51,7 +51,7 @@ public static CommunityResponseDTO.PostDTO toPostDTO(Community community, Long c .build(); } - public static CommunityResponseDTO.PostDetailDTO toPostDetailDTO(Community community, Page commentList){ + public static CommunityResponseDTO.PostDetailDTO toPostDetailDTO(Community community, Page commentList, Boolean isOwner){ List list = new ArrayList(); if(!community.getFileList().isEmpty()){ community.getFileList().stream().forEach(file -> { @@ -64,6 +64,7 @@ public static CommunityResponseDTO.PostDetailDTO toPostDetailDTO(Community commu .content(community.getContent()) .communityWriterEmail(community.getUser().getEmail()) .created_at(community.getCreatedAt()) + .isOwner(isOwner) .fileList(list) .commentDTOList(comments) .build(); diff --git a/src/main/java/com/example/helloworldmvc/service/CommunityServiceImpl.java b/src/main/java/com/example/helloworldmvc/service/CommunityServiceImpl.java index 62924c0..5eb62d1 100644 --- a/src/main/java/com/example/helloworldmvc/service/CommunityServiceImpl.java +++ b/src/main/java/com/example/helloworldmvc/service/CommunityServiceImpl.java @@ -65,7 +65,11 @@ public CommunityResponseDTO.PostDetailDTO getCommunityDetail(String userId, Long int end = Math.min((start + pageRequest.getPageSize()), commentList.size()); List subList = commentList.subList(start, end); Page commentPage = new PageImpl<>(subList, pageRequest, commentList.size()); - return CommunityConverter.toPostDetailDTO(community, commentPage); + boolean isOwner = false; + if(community.getUser().getEmail().equals(user.getEmail())) { + isOwner = true; + } + return CommunityConverter.toPostDetailDTO(community, commentPage, isOwner); } @Override diff --git a/src/main/java/com/example/helloworldmvc/web/dto/CommunityResponseDTO.java b/src/main/java/com/example/helloworldmvc/web/dto/CommunityResponseDTO.java index f6c68c1..9016524 100644 --- a/src/main/java/com/example/helloworldmvc/web/dto/CommunityResponseDTO.java +++ b/src/main/java/com/example/helloworldmvc/web/dto/CommunityResponseDTO.java @@ -49,6 +49,7 @@ public static class PostDetailDTO{ LocalDateTime created_at; List fileList; List commentDTOList; + Boolean isOwner; } @Builder