Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package space.space_spring.domain.discord.adapter.in.discord;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion;
import net.dv8tion.jda.api.events.message.MessageUpdateEvent;
Expand All @@ -18,6 +19,7 @@
import java.util.Optional;
@Component
@RequiredArgsConstructor
@Slf4j
public class MessageUpdateEventListener extends ListenerAdapter {
private final DiscordUtil discordUtil;
private final LoadBoardCachePort loadBoardCachePort;
Expand Down Expand Up @@ -48,7 +50,7 @@ public void onMessageUpdate(MessageUpdateEvent event){
//log.info("not in cache. ignore");
return;
}

//log.info("edit message discord id:"+event.getMessageId().toString());
if(isComment(event)){
//Todo map comment update command
//Todo update comment UseCase call
Expand All @@ -57,6 +59,7 @@ public void onMessageUpdate(MessageUpdateEvent event){
.content(event.getMessage().getContentRaw())
.build();
updateCommentUseCase.updateCommentFromDiscord(command);
return;
}

//Todo map post update command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ public class ResponseOfReadPostDetail {

private Boolean isLiked;

private Boolean isPostOwner;

private List<ResponseOfCommentDetail> responseOfCommentDetails;

@Builder
private ResponseOfReadPostDetail(String creatorName, String creatorProfileImageUrl, String createdAt, String lastModifiedAt,
String title, String content, List<String> attachmentUrls, int likeCount, Boolean isLiked,
List<ResponseOfCommentDetail> responseOfCommentDetails) {
Boolean isPostOwner, List<ResponseOfCommentDetail> responseOfCommentDetails) {
this.creatorName = creatorName;
this.creatorProfileImageUrl = creatorProfileImageUrl;
this.createdAt = createdAt;
Expand All @@ -42,6 +44,7 @@ private ResponseOfReadPostDetail(String creatorName, String creatorProfileImageU
this.attachmentUrls = attachmentUrls;
this.likeCount = likeCount;
this.isLiked = isLiked;
this.isPostOwner = isPostOwner;
this.responseOfCommentDetails = responseOfCommentDetails;
}

Expand All @@ -56,6 +59,7 @@ public static ResponseOfReadPostDetail of(ResultOfReadPostDetail result) {
.attachmentUrls(result.getAttachmentUrls())
.likeCount(result.getLikeCount())
.isLiked(result.getIsLiked())
.isPostOwner(result.getIsPostOwner())
.responseOfCommentDetails(
result.getInfoOfCommentDetails().stream()
.map(ResponseOfCommentDetail::of)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.web.bind.annotation.RestController;
import space.space_spring.domain.post.application.port.in.readPostList.ListOfPostSummary;
import space.space_spring.domain.post.application.port.in.readPostList.ReadPostListUseCase;
import space.space_spring.global.argumentResolver.jwtLogin.JwtLoginAuth;
import space.space_spring.global.common.response.BaseResponse;


Expand All @@ -29,13 +30,14 @@ public class ReadPostListController {
""")
@GetMapping("/space/{spaceId}/board/{boardId}/post")
public BaseResponse<ResponseOfReadPostList> readPostList(
@JwtLoginAuth Long spaceMemberId,
@PathVariable Long spaceId,
@PathVariable Long boardId,
@RequestParam(required = false) Long tagId,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "20") int size) {
Pageable pageable = PageRequest.of(page, size, Sort.by("postBase.createdAt").descending());
ListOfPostSummary postSummaries = readPostListUseCase.readPostList(boardId, tagId, pageable);
ListOfPostSummary postSummaries = readPostListUseCase.readPostList(spaceMemberId, boardId, tagId, pageable);
return new BaseResponse<>(ResponseOfReadPostList.of(postSummaries));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ public class ResponseOfPostSummary {

private String postImageUrl;

private ResponseOfPostSummary(Long postId, String title, String content, int likeCount, int commentCount, String createdAt, String creatorNickname, String postImageUrl){
private Boolean isPostOwner;

private ResponseOfPostSummary(Long postId, String title, String content, int likeCount, int commentCount,
String createdAt, String creatorNickname, String postImageUrl, Boolean isPostOwner){
this.postId = postId;
this.title = title;
this.content = content;
Expand All @@ -32,6 +35,7 @@ private ResponseOfPostSummary(Long postId, String title, String content, int lik
this.createdAt = createdAt;
this.creatorNickname = creatorNickname;
this.postImageUrl = postImageUrl;
this.isPostOwner = isPostOwner;
}

public static ResponseOfPostSummary of(PostSummary summaryOfPost) {
Expand All @@ -43,7 +47,8 @@ public static ResponseOfPostSummary of(PostSummary summaryOfPost) {
summaryOfPost.getCommentCount(),
ConvertCreatedDate.setCreatedDate(summaryOfPost.getCreatedAt()),
summaryOfPost.getCreatorNickname(),
summaryOfPost.getPostImageUrl()
summaryOfPost.getPostImageUrl(),
summaryOfPost.getIsPostOwner()
);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package space.space_spring.domain.post.adapter.out.persistence.post;

import com.querydsl.core.group.GroupBy;
import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.jpa.JPAExpressions;
Expand Down Expand Up @@ -75,7 +74,12 @@ public PostDetailView loadPostDetail(Long postId, Long spaceMemberId) {
.and(postLike.spaceMember.id.eq(spaceMemberId))
.and(postLike.isLiked.eq(true))
.and(postLike.status.eq(BaseStatusType.ACTIVE)))
.exists()
.exists(),
// 스페이스 멤버가 해당 게시글 작성자인지
Expressions.booleanTemplate(
"CASE WHEN {0} = {1} THEN true ELSE false END",
postCreator.id,
spaceMemberId)
))
.from(post)
.leftJoin(post.postBase, postBase)
Expand Down Expand Up @@ -106,6 +110,7 @@ public PostDetailView loadPostDetail(Long postId, Long spaceMemberId) {
.attachmentUrls(attachmentUrls)
.likeCount(detail.getLikeCount())
.isLiked(detail.getIsLiked())
.isPostOwner(detail.getIsPostOwner())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ public class ResultOfReadPostDetail {

private Boolean isLiked;

private Boolean isPostOwner;

private List<InfoOfCommentDetail> infoOfCommentDetails;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ public class PostSummary {

private String postImageUrl;

private PostSummary(Long postId, String title, Content content, int likeCount, int commentCount, LocalDateTime createdAt, String creatorNickname, String postImageUrl) {
private Boolean isPostOwner;

private PostSummary(Long postId, String title, Content content, int likeCount, int commentCount,
LocalDateTime createdAt, String creatorNickname, String postImageUrl, Boolean isPostOwner) {
this.postId = postId;
this.title = title;
this.content = content;
Expand All @@ -33,9 +36,11 @@ private PostSummary(Long postId, String title, Content content, int likeCount, i
this.createdAt = createdAt;
this.creatorNickname = creatorNickname;
this.postImageUrl = postImageUrl;
this.isPostOwner = isPostOwner;
}

public static PostSummary of(Long postId, String title, Content content, int likeCount, int commentCount, LocalDateTime createdAt, String creatorNickname, String postImageUrl) {
return new PostSummary(postId, title, content, likeCount, commentCount, createdAt, creatorNickname, postImageUrl);
public static PostSummary of(Long postId, String title, Content content, int likeCount, int commentCount,
LocalDateTime createdAt, String creatorNickname, String postImageUrl, Boolean isPostOwner) {
return new PostSummary(postId, title, content, likeCount, commentCount, createdAt, creatorNickname, postImageUrl, isPostOwner);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

public interface ReadPostListUseCase {

ListOfPostSummary readPostList(Long boardId, Long tagId, Pageable pageable);
ListOfPostSummary readPostList(Long spaceMemberId, Long boardId, Long tagId, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ public class PostDetailView {

private Boolean isLiked;

private Boolean isPostOwner;

// Querydsl에서 사용할 생성자
public PostDetailView(String creatorName, String creatorProfileImageUrl,
LocalDateTime createdAt, LocalDateTime lastModifiedAt,
String title, String content, List<String> attachmentUrls,
Long likeCount, Boolean isLiked) {
Long likeCount, Boolean isLiked, Boolean isPostOwner) {
this.creatorName = creatorName;
this.creatorProfileImageUrl = creatorProfileImageUrl;
this.createdAt = createdAt;
Expand All @@ -42,5 +44,6 @@ public PostDetailView(String creatorName, String creatorProfileImageUrl,
this.attachmentUrls = attachmentUrls;
this.likeCount = likeCount;
this.isLiked = isLiked;
this.isPostOwner = isPostOwner;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public ResultOfReadPostDetail readPostDetail(ReadPostDetailCommand command) {
.attachmentUrls(postDetailView.getAttachmentUrls())
.likeCount(postDetailView.getLikeCount().intValue())
.isLiked(postDetailView.getIsLiked())
.isPostOwner(postDetailView.getIsPostOwner())
.infoOfCommentDetails(mapToInfoOfCommentDetails(processedCommentDetailViews))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.util.List;
import java.util.Map;
import java.util.Objects;

import static space.space_spring.global.common.response.status.BaseExceptionResponseStatus.TAG_IS_REQUIRED_FOR_THIS_BOARD;

Expand All @@ -40,7 +41,7 @@ public class ReadPostListService implements ReadPostListUseCase {
private final LoadSpaceMemberInfoPort loadSpaceMemberInfoPort;

@Override
public ListOfPostSummary readPostList(Long boardId, Long tagId, Pageable pageable) {
public ListOfPostSummary readPostList(Long spaceMemberId, Long boardId, Long tagId, Pageable pageable) {
// 1. Board 조회
Board board = loadBoardPort.loadById(boardId);

Expand Down Expand Up @@ -83,7 +84,8 @@ public ListOfPostSummary readPostList(Long boardId, Long tagId, Pageable pageabl
commentCounts.getOrDefault(post.getId(), NaturalNumber.of(0)).getNumber(),
post.getBaseInfo().getCreatedAt(),
creatorNicknames.getOrDefault(post.getPostCreatorId(), "알 수 없음"),
thumbnailImages.getOrDefault(post.getId(), null)
thumbnailImages.getOrDefault(post.getId(), null),
post.getPostCreatorId().equals(spaceMemberId)
)).toList();

// 9. ListOfPostSummary 생성
Expand Down
Loading