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 @@ -7,12 +7,13 @@
import java.util.List;

public record GetChallengeGroupMemberTodayTodoHistoryApiResponseV2(
boolean isMine,
int currentTodoHistoryToReadIndex,
List<TodoData> todos
) {
public static GetChallengeGroupMemberTodayTodoHistoryApiResponseV2 from(final FindTargetMemberTodayTodoHistoriesDto dto) {
final List<TodoData> todos = dto.todoHistories().stream().map(TodoData::from).toList();
return new GetChallengeGroupMemberTodayTodoHistoryApiResponseV2(dto.currentTodoHistoryToReadIndex(), todos);
return new GetChallengeGroupMemberTodayTodoHistoryApiResponseV2(dto.isMine(), dto.currentTodoHistoryToReadIndex(), todos);
}

public record TodoData(
Expand All @@ -28,8 +29,7 @@ public record TodoData(
String certificationMediaUrl,
boolean isRead,
@JsonInclude(JsonInclude.Include.NON_NULL)
String reviewFeedback,
boolean isMine
String reviewFeedback
) {
public static TodoData from(final TodoHistoryDto dto) {
return new TodoData(
Expand All @@ -42,8 +42,7 @@ public static TodoData from(final TodoHistoryDto dto) {
dto.certificationContent(),
dto.certificationMediaUrl(),
dto.isRead(),
dto.reviewFeedback(),
dto.isMine()
dto.reviewFeedback()
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
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 @@ -61,8 +60,4 @@ 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 @@ -67,7 +67,7 @@ public FindTargetMemberTodayTodoHistoriesDto findAllTodayTodoHistories(
.toList();
int currentTodoHistoryToReadIndex = calculateCurrentTodoHistoryToReadIndex(todoHistoryDtos);

return new FindTargetMemberTodayTodoHistoriesDto(currentTodoHistoryToReadIndex, todoHistoryDtos);
return new FindTargetMemberTodayTodoHistoriesDto(targetMember.equals(viewer), currentTodoHistoryToReadIndex, todoHistoryDtos);
}

private ChallengeGroup getChallengeGroup(final Long challengeGroupId) {
Expand Down Expand Up @@ -103,8 +103,7 @@ private TodoHistoryDto convertDtoFromHistory(final DailyTodoHistory history, fin
dailyTodoCertification.getContent(),
dailyTodoCertification.getMediaUrl(),
isHistoryRead,
dailyTodoCertification.findReviewFeedback().orElse(null),
history.isMine(viewer)))
dailyTodoCertification.findReviewFeedback().orElse(null)))
.orElse(new TodoHistoryDto(
history.getId(),
dailyTodo.getId(),
Expand All @@ -115,8 +114,7 @@ private TodoHistoryDto convertDtoFromHistory(final DailyTodoHistory history, fin
null,
null,
isHistoryRead,
null,
history.isMine(viewer)));
null));
}

private boolean checkMemberReadDailyTodoHistory(final Member member, final DailyTodoHistory dailyTodoHistory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

import java.util.List;

public record FindTargetMemberTodayTodoHistoriesDto(int currentTodoHistoryToReadIndex, List<TodoHistoryDto> todoHistories) {
public record FindTargetMemberTodayTodoHistoriesDto(boolean isMine, int currentTodoHistoryToReadIndex, List<TodoHistoryDto> todoHistories) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ public record TodoHistoryDto(
String certificationContent,
String certificationMediaUrl,
boolean isRead,
String reviewFeedback,
boolean isMine
String reviewFeedback
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,15 @@ void getMyDailyTodosWithCertificationInputDateAndTodoStatusV1() throws Exception
@Test
void getChallengeGroupMemberTodayTodoHistoryV1() throws Exception {
final FindTargetMemberTodayTodoHistoriesDto serviceMockResponse = new FindTargetMemberTodayTodoHistoriesDto(
false,
3,
List.of(
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)
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, "치킨 부럽다ㅠㅠ 심술나서 노인정!")
)
);
given(dailyTodoHistoryService.findAllTodayTodoHistories(any(), any(), any()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,15 @@ void getMyDailyTodosWithCertificationInputDateAndTodoStatusV2() throws Exception
@Test
void getChallengeGroupMemberTodayTodoHistoryV2() throws Exception {
final FindTargetMemberTodayTodoHistoriesDto serviceMockResponse = new FindTargetMemberTodayTodoHistoriesDto(
false,
3,
List.of(
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)
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, "치킨 부럽다ㅠㅠ 심술나서 노인정!")
)
);
given(dailyTodoHistoryService.findAllTodayTodoHistories(any(), any(), any()))
Expand All @@ -221,6 +222,9 @@ void getChallengeGroupMemberTodayTodoHistoryV2() throws Exception {
fieldWithPath("message")
.description("응답 메시지")
.type(JsonFieldType.STRING),
fieldWithPath("data.isMine")
.description("본인이 작성한 투두의 히스토리인지 여부")
.type(JsonFieldType.BOOLEAN),
fieldWithPath("data.currentTodoHistoryToReadIndex")
.description("현재 읽어야하는 투두 순서 (0부터 시작)")
.type(JsonFieldType.NUMBER),
Expand Down Expand Up @@ -259,9 +263,6 @@ void getChallengeGroupMemberTodayTodoHistoryV2() throws Exception {
fieldWithPath("data.todos[].reviewFeedback")
.description("데일리 투두 인증 검사 피드백")
.optional()
.type(JsonFieldType.STRING),
fieldWithPath("data.todos[].isMine")
.description("본인이 작성한 투두의 히스토리인지 여부")
.type(JsonFieldType.BOOLEAN))));
.type(JsonFieldType.STRING))));
}
}
Loading