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 @@ -28,7 +28,8 @@ public record TodoData(
String certificationMediaUrl,
boolean isRead,
@JsonInclude(JsonInclude.Include.NON_NULL)
String reviewFeedback
String reviewFeedback,
boolean isMine
) {
public static TodoData from(final TodoHistoryDto dto) {
return new TodoData(
Expand All @@ -41,7 +42,8 @@ public static TodoData from(final TodoHistoryDto dto) {
dto.certificationContent(),
dto.certificationMediaUrl(),
dto.isRead(),
dto.reviewFeedback()
dto.reviewFeedback(),
dto.isMine()
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import lombok.ToString;
import site.dogether.common.audit.entity.BaseEntity;
import site.dogether.dailytodo.entity.DailyTodo;
import site.dogether.member.entity.Member;

import java.time.LocalDateTime;
import java.util.List;
Expand Down Expand Up @@ -60,4 +61,8 @@ public DailyTodoHistory(
public void updateEventTime() {
this.eventTime = LocalDateTime.now();
}

public boolean isMine(final Member target) {
return dailyTodo.isWriter(target);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ private TodoHistoryDto convertDtoFromHistory(final DailyTodoHistory history, fin
dailyTodoCertification.getContent(),
dailyTodoCertification.getMediaUrl(),
isHistoryRead,
dailyTodoCertification.findReviewFeedback().orElse(null)))
dailyTodoCertification.findReviewFeedback().orElse(null),
history.isMine(viewer)))
.orElse(new TodoHistoryDto(
history.getId(),
dailyTodo.getId(),
Expand All @@ -114,7 +115,8 @@ private TodoHistoryDto convertDtoFromHistory(final DailyTodoHistory history, fin
null,
null,
isHistoryRead,
null));
null,
history.isMine(viewer)));
}

private boolean checkMemberReadDailyTodoHistory(final Member member, final DailyTodoHistory dailyTodoHistory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public record TodoHistoryDto(
String certificationContent,
String certificationMediaUrl,
boolean isRead,
String reviewFeedback
String reviewFeedback,
boolean isMine
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,20 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
import static org.springframework.restdocs.request.RequestDocumentation.*;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
import static org.springframework.restdocs.request.RequestDocumentation.queryParameters;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static site.dogether.dailytodo.entity.DailyTodoStatus.CERTIFY_COMPLETED;
import static site.dogether.dailytodo.entity.DailyTodoStatus.CERTIFY_PENDING;
import static site.dogether.dailytodocertification.entity.DailyTodoCertificationReviewStatus.*;
import static site.dogether.dailytodocertification.entity.DailyTodoCertificationReviewStatus.APPROVE;
import static site.dogether.dailytodocertification.entity.DailyTodoCertificationReviewStatus.REJECT;
import static site.dogether.dailytodocertification.entity.DailyTodoCertificationReviewStatus.REVIEW_PENDING;

@DisplayName("데일리 투두 V1 API 문서화 테스트")
public class DailyTodoControllerV1DocsTest extends RestDocsSupport {
Expand Down Expand Up @@ -254,12 +260,12 @@ void getChallengeGroupMemberTodayTodoHistoryV1() throws Exception {
final FindTargetMemberTodayTodoHistoriesDto serviceMockResponse = new FindTargetMemberTodayTodoHistoriesDto(
3,
List.of(
new TodoHistoryDto(1L, 1L, "치킨 먹기", CERTIFY_PENDING.name(), true, true, null, null, true, null),
new TodoHistoryDto(2L, 2L, "재홍님 갈구기", CERTIFY_PENDING.name(), true, true, null, null, true, null),
new TodoHistoryDto(3L, 3L, "치킨 먹기", REVIEW_PENDING.name(), true, true, "개꿀맛 치킨 냠냠", "https://치킨.png", true, null),
new TodoHistoryDto(4L, 4L, "재홍님 갈구기", REVIEW_PENDING.name(), true, true, "아 재홍님 그거 그렇게 하는거 아닌데", "https://갈굼1.png", false, null),
new TodoHistoryDto(5L, 5L, "재홍님 갈구기", APPROVE.name(), true, true, "아 재홍님 그거 그렇게 하는거 아닌데", "https://갈굼1.png", false, "재홍님 갈구기 너무 재밌어요"),
new TodoHistoryDto(6L, 6L, "치킨 먹기", REJECT.name(), true, true, "개꿀맛 치킨 냠냠", "https://치킨.png", false, "치킨 부럽다ㅠㅠ 심술나서 노인정!")
new TodoHistoryDto(1L, 1L, "치킨 먹기", CERTIFY_PENDING.name(), true, true, null, null, true, null, false),
new TodoHistoryDto(2L, 2L, "재홍님 갈구기", CERTIFY_PENDING.name(), true, true, null, null, true, null, false),
new TodoHistoryDto(3L, 3L, "치킨 먹기", REVIEW_PENDING.name(), true, true, "개꿀맛 치킨 냠냠", "https://치킨.png", true, null, false),
new TodoHistoryDto(4L, 4L, "재홍님 갈구기", REVIEW_PENDING.name(), true, true, "아 재홍님 그거 그렇게 하는거 아닌데", "https://갈굼1.png", false, null, false),
new TodoHistoryDto(5L, 5L, "재홍님 갈구기", APPROVE.name(), true, true, "아 재홍님 그거 그렇게 하는거 아닌데", "https://갈굼1.png", false, "재홍님 갈구기 너무 재밌어요", false),
new TodoHistoryDto(6L, 6L, "치킨 먹기", REJECT.name(), true, true, "개꿀맛 치킨 냠냠", "https://치킨.png", false, "치킨 부럽다ㅠㅠ 심술나서 노인정!", false)
)
);
given(dailyTodoHistoryService.findAllTodayTodoHistories(any(), any(), any()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ void getChallengeGroupMemberTodayTodoHistoryV2() throws Exception {
final FindTargetMemberTodayTodoHistoriesDto serviceMockResponse = new FindTargetMemberTodayTodoHistoriesDto(
3,
List.of(
new TodoHistoryDto(1L, 1L, "치킨 먹기", CERTIFY_PENDING.name(), true, false, null, null, true, null),
new TodoHistoryDto(2L, 2L, "재홍님 갈구기", CERTIFY_PENDING.name(), true, false, null, null, true, null),
new TodoHistoryDto(3L, 3L, "치킨 먹기", REVIEW_PENDING.name(), false, true, "개꿀맛 치킨 냠냠", "https://치킨.png", true, null),
new TodoHistoryDto(4L, 4L, "재홍님 갈구기", REVIEW_PENDING.name(), false, false, "아 재홍님 그거 그렇게 하는거 아닌데", "https://갈굼1.png", false, null),
new TodoHistoryDto(5L, 5L, "재홍님 갈구기", APPROVE.name(), false, false, "아 재홍님 그거 그렇게 하는거 아닌데", "https://갈굼1.png", false, "재홍님 갈구기 너무 재밌어요"),
new TodoHistoryDto(6L, 6L, "치킨 먹기", REJECT.name(), false, false, "개꿀맛 치킨 냠냠", "https://치킨.png", false, "치킨 부럽다ㅠㅠ 심술나서 노인정!")
new TodoHistoryDto(1L, 1L, "치킨 먹기", CERTIFY_PENDING.name(), true, false, null, null, true, null, false),
new TodoHistoryDto(2L, 2L, "재홍님 갈구기", CERTIFY_PENDING.name(), true, false, null, null, true, null, false),
new TodoHistoryDto(3L, 3L, "치킨 먹기", REVIEW_PENDING.name(), false, true, "개꿀맛 치킨 냠냠", "https://치킨.png", true, null, false),
new TodoHistoryDto(4L, 4L, "재홍님 갈구기", REVIEW_PENDING.name(), false, false, "아 재홍님 그거 그렇게 하는거 아닌데", "https://갈굼1.png", false, null, false),
new TodoHistoryDto(5L, 5L, "재홍님 갈구기", APPROVE.name(), false, false, "아 재홍님 그거 그렇게 하는거 아닌데", "https://갈굼1.png", false, "재홍님 갈구기 너무 재밌어요", false),
new TodoHistoryDto(6L, 6L, "치킨 먹기", REJECT.name(), false, false, "개꿀맛 치킨 냠냠", "https://치킨.png", false, "치킨 부럽다ㅠㅠ 심술나서 노인정!", false)
)
);
given(dailyTodoHistoryService.findAllTodayTodoHistories(any(), any(), any()))
Expand Down Expand Up @@ -259,6 +259,9 @@ void getChallengeGroupMemberTodayTodoHistoryV2() throws Exception {
fieldWithPath("data.todos[].reviewFeedback")
.description("데일리 투두 인증 검사 피드백")
.optional()
.type(JsonFieldType.STRING))));
.type(JsonFieldType.STRING),
fieldWithPath("data.todos[].isMine")
.description("본인이 작성한 투두의 히스토리인지 여부")
.type(JsonFieldType.BOOLEAN))));
}
}
Loading