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
Expand Up @@ -11,4 +11,5 @@ public record CommentListResponse(
@Schema(description = "댓글 내용", example = "이 옷 정보 알려주세요!") String content,
@Schema(description = "대댓글 존재 여부", example = "false") boolean replied,
@Schema(description = "총 대댓글 개수", example = "0") long replyCount,
@Schema(description = "내가 작성한 댓글인가?", example = "false") boolean isMine) {}
@Schema(description = "내가 작성한 댓글인가?", example = "false") boolean isMine,
@Schema(description = "댓글 삭제 가능 여부", example = "false") boolean canDelete) {}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public record ReplyListResponse(
@Schema(description = "댓글 작성자 이미지 주소", example = "https://s3.amazonaws.com/example.jpg")
String profileImageUrl,
@Schema(description = "댓글 내용", example = "이 옷 정보 알려주세요!") String content,
@Schema(description = "내가 작성한 대댓글인가?", example = "false") boolean isMine) {}
@Schema(description = "내가 작성한 대댓글인가?", example = "false") boolean isMine,
@Schema(description = "댓글 삭제 가능 여부", example = "false") boolean canDelete) {}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ public Slice<CommentListResponse> findAllParentCommentByHistoryId(
comment.content,
Expressions.constant(false),
Expressions.constant(0L),
member.id.eq(currentMemberId)))
member.id.eq(currentMemberId),
member.id
.eq(currentMemberId)
.or(history.member.id.eq(currentMemberId))))
.from(comment)
.join(comment.member, member)
.where(
Expand Down Expand Up @@ -107,7 +110,8 @@ public Slice<CommentListResponse> findAllParentCommentByHistoryId(
c.content(),
replyCountMap.getOrDefault(c.commentId(), 0L) > 0,
replyCountMap.getOrDefault(c.commentId(), 0L),
c.isMine()))
c.isMine(),
c.canDelete()))
.toList();

return new SliceImpl<>(finalResults, PageRequest.of(0, size), hasNext);
Expand All @@ -131,7 +135,10 @@ public Slice<ReplyListResponse> findAllRepliesByCommentId(
member.nickname,
member.profileImageUrl,
comment.content,
member.id.eq(currentMemberId)))
member.id.eq(currentMemberId),
member.id
.eq(currentMemberId)
.or(history.member.id.eq(currentMemberId))))
.from(comment)
.join(comment.member, member)
.where(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ public void deleteComment(Long commentId) {
final Member currentMember = memberUtil.getCurrentMember();
final Comment comment = getCommentById(commentId);

validateCommentOwner(currentMember, comment);
boolean isHistoryOwner =
Objects.equals(comment.getHistory().getMember().getId(), currentMember.getId());
if (!isHistoryOwner) {
validateCommentOwner(currentMember, comment);
}

if (comment.getComment() != null) {
commentRepository.delete(comment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import org.clokey.coordinate.entity.Coordinate;

public record FavoriteCoordinateResponse(
@Schema(description = "코디 ID") Long coordinateId,
@Schema(description = "코디 이미지 url") String imageUrl) {
@Schema(description = "코디 ID", example = "1") Long coordinateId,
@Schema(description = "코디 이미지 url", example = "https://exampe.com") String imageUrl,
@Schema(description = "코디 이름", example = "영화관 데이트") String coordinateName) {
public static FavoriteCoordinateResponse from(Coordinate coordinates) {
return new FavoriteCoordinateResponse(coordinates.getId(), coordinates.getImageUrl());
return new FavoriteCoordinateResponse(
coordinates.getId(), coordinates.getImageUrl(), coordinates.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ class 기록의_댓글_목록_조회_요청_시 {
"testContent1",
false,
0L,
true,
true),
new CommentListResponse(
2L,
Expand All @@ -301,6 +302,7 @@ class 기록의_댓글_목록_조회_요청_시 {
"testContent2",
false,
0L,
true,
true));

given(commentService.getHistoryComments(1L, null, 2, SortDirection.ASC))
Expand All @@ -319,6 +321,7 @@ class 기록의_댓글_목록_조회_요청_시 {
.andExpect(jsonPath("$.code").value("COMMON200"))
.andExpect(jsonPath("$.result.content[0].commentId").value(1))
.andExpect(jsonPath("$.result.content[1].commentId").value(2))
.andExpect(jsonPath("$.result.content[0].canDelete").value(true))
.andExpect(jsonPath("$.result.isLast").value(true));
}

Expand All @@ -335,6 +338,7 @@ class 기록의_댓글_목록_조회_요청_시 {
"testContent2",
false,
0L,
true,
true),
new CommentListResponse(
1L,
Expand All @@ -344,6 +348,7 @@ class 기록의_댓글_목록_조회_요청_시 {
"testContent1",
false,
0L,
true,
true));

given(commentService.getHistoryComments(1L, null, 2, SortDirection.DESC))
Expand Down Expand Up @@ -378,6 +383,7 @@ class 기록의_댓글_목록_조회_요청_시 {
"testContent2",
false,
0L,
true,
true));

given(commentService.getHistoryComments(1L, null, 1, SortDirection.ASC))
Expand Down Expand Up @@ -411,6 +417,7 @@ class 기록의_댓글_목록_조회_요청_시 {
"testContent1",
false,
0L,
true,
true),
new CommentListResponse(
2L,
Expand All @@ -420,6 +427,7 @@ class 기록의_댓글_목록_조회_요청_시 {
"testContent2",
false,
0L,
true,
true));

given(commentService.getHistoryComments(1L, null, 1, SortDirection.ASC))
Expand Down Expand Up @@ -508,9 +516,21 @@ class 댓글의_대댓글_목록_조회_요청_시 {
List<ReplyListResponse> commentReplies =
List.of(
new ReplyListResponse(
1L, 1L, "testNickName", "testProfile", "testContent1", true),
1L,
1L,
"testNickName",
"testProfile",
"testContent1",
true,
true),
new ReplyListResponse(
2L, 1L, "testNickName", "testProfile", "testContent2", true));
2L,
1L,
"testNickName",
"testProfile",
"testContent2",
true,
true));

given(commentService.getCommentReplies(1L, null, 2, SortDirection.ASC))
.willReturn(new SliceResponse<>(commentReplies, true));
Expand All @@ -527,6 +547,7 @@ class 댓글의_대댓글_목록_조회_요청_시 {
.andExpect(jsonPath("$.code").value("COMMON200"))
.andExpect(jsonPath("$.result.content[0].replyId").value(1))
.andExpect(jsonPath("$.result.content[1].replyId").value(2))
.andExpect(jsonPath("$.result.content[0].canDelete").value(true))
.andExpect(jsonPath("$.result.isLast").value(true));
}

Expand All @@ -536,9 +557,21 @@ class 댓글의_대댓글_목록_조회_요청_시 {
List<ReplyListResponse> commentReplies =
List.of(
new ReplyListResponse(
2L, 1L, "testNickName", "testProfile", "testContent2", true),
2L,
1L,
"testNickName",
"testProfile",
"testContent2",
true,
true),
new ReplyListResponse(
1L, 1L, "testNickName", "testProfile", "testContent1", true));
1L,
1L,
"testNickName",
"testProfile",
"testContent1",
true,
true));

given(commentService.getCommentReplies(1L, null, 2, SortDirection.DESC))
.willReturn(new SliceResponse<>(commentReplies, true));
Expand All @@ -564,7 +597,13 @@ class 댓글의_대댓글_목록_조회_요청_시 {
List<ReplyListResponse> commentReplies =
List.of(
new ReplyListResponse(
2L, 1L, "testNickName", "testProfile", "testContent2", true));
2L,
1L,
"testNickName",
"testProfile",
"testContent2",
true,
true));

given(commentService.getCommentReplies(1L, null, 1, SortDirection.ASC))
.willReturn(new SliceResponse<>(commentReplies, true));
Expand All @@ -589,9 +628,21 @@ class 댓글의_대댓글_목록_조회_요청_시 {
List<ReplyListResponse> commentsReplies =
List.of(
new ReplyListResponse(
1L, 1L, "testNickName", "testProfile", "testContent1", true),
1L,
1L,
"testNickName",
"testProfile",
"testContent1",
true,
true),
new ReplyListResponse(
2L, 1L, "testNickName", "testProfile", "testContent2", true));
2L,
1L,
"testNickName",
"testProfile",
"testContent2",
true,
true));

given(commentService.getCommentReplies(1L, null, 2, SortDirection.ASC))
.willReturn(new SliceResponse<>(commentsReplies, false));
Expand Down
Loading