diff --git a/src/main/java/site/dogether/dailytodo/controller/v2/dto/response/GetChallengeGroupMemberTodayTodoHistoryApiResponseV2.java b/src/main/java/site/dogether/dailytodo/controller/v2/dto/response/GetChallengeGroupMemberTodayTodoHistoryApiResponseV2.java index f7505282..e3794923 100644 --- a/src/main/java/site/dogether/dailytodo/controller/v2/dto/response/GetChallengeGroupMemberTodayTodoHistoryApiResponseV2.java +++ b/src/main/java/site/dogether/dailytodo/controller/v2/dto/response/GetChallengeGroupMemberTodayTodoHistoryApiResponseV2.java @@ -7,12 +7,13 @@ import java.util.List; public record GetChallengeGroupMemberTodayTodoHistoryApiResponseV2( + boolean isMine, int currentTodoHistoryToReadIndex, List todos ) { public static GetChallengeGroupMemberTodayTodoHistoryApiResponseV2 from(final FindTargetMemberTodayTodoHistoriesDto dto) { final List 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( @@ -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( @@ -42,8 +42,7 @@ public static TodoData from(final TodoHistoryDto dto) { dto.certificationContent(), dto.certificationMediaUrl(), dto.isRead(), - dto.reviewFeedback(), - dto.isMine() + dto.reviewFeedback() ); } } diff --git a/src/main/java/site/dogether/dailytodohistory/entity/DailyTodoHistory.java b/src/main/java/site/dogether/dailytodohistory/entity/DailyTodoHistory.java index e27f77f0..e4a5980a 100644 --- a/src/main/java/site/dogether/dailytodohistory/entity/DailyTodoHistory.java +++ b/src/main/java/site/dogether/dailytodohistory/entity/DailyTodoHistory.java @@ -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; @@ -61,8 +60,4 @@ public DailyTodoHistory( public void updateEventTime() { this.eventTime = LocalDateTime.now(); } - - public boolean isMine(final Member target) { - return dailyTodo.isWriter(target); - } } diff --git a/src/main/java/site/dogether/dailytodohistory/service/DailyTodoHistoryService.java b/src/main/java/site/dogether/dailytodohistory/service/DailyTodoHistoryService.java index d89625f1..36914a4e 100644 --- a/src/main/java/site/dogether/dailytodohistory/service/DailyTodoHistoryService.java +++ b/src/main/java/site/dogether/dailytodohistory/service/DailyTodoHistoryService.java @@ -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) { @@ -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(), @@ -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) { diff --git a/src/main/java/site/dogether/dailytodohistory/service/dto/FindTargetMemberTodayTodoHistoriesDto.java b/src/main/java/site/dogether/dailytodohistory/service/dto/FindTargetMemberTodayTodoHistoriesDto.java index cfd1e23c..12100417 100644 --- a/src/main/java/site/dogether/dailytodohistory/service/dto/FindTargetMemberTodayTodoHistoriesDto.java +++ b/src/main/java/site/dogether/dailytodohistory/service/dto/FindTargetMemberTodayTodoHistoriesDto.java @@ -2,5 +2,5 @@ import java.util.List; -public record FindTargetMemberTodayTodoHistoriesDto(int currentTodoHistoryToReadIndex, List todoHistories) { +public record FindTargetMemberTodayTodoHistoriesDto(boolean isMine, int currentTodoHistoryToReadIndex, List todoHistories) { } diff --git a/src/main/java/site/dogether/dailytodohistory/service/dto/TodoHistoryDto.java b/src/main/java/site/dogether/dailytodohistory/service/dto/TodoHistoryDto.java index 9f98c438..cef2e616 100644 --- a/src/main/java/site/dogether/dailytodohistory/service/dto/TodoHistoryDto.java +++ b/src/main/java/site/dogether/dailytodohistory/service/dto/TodoHistoryDto.java @@ -10,6 +10,5 @@ public record TodoHistoryDto( String certificationContent, String certificationMediaUrl, boolean isRead, - String reviewFeedback, - boolean isMine + String reviewFeedback ) {} diff --git a/src/test/java/site/dogether/docs/dailytodo/v1/DailyTodoControllerV1DocsTest.java b/src/test/java/site/dogether/docs/dailytodo/v1/DailyTodoControllerV1DocsTest.java index 03282908..f12a7201 100644 --- a/src/test/java/site/dogether/docs/dailytodo/v1/DailyTodoControllerV1DocsTest.java +++ b/src/test/java/site/dogether/docs/dailytodo/v1/DailyTodoControllerV1DocsTest.java @@ -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())) diff --git a/src/test/java/site/dogether/docs/dailytodo/v2/DailyTodoControllerV2DocsTest.java b/src/test/java/site/dogether/docs/dailytodo/v2/DailyTodoControllerV2DocsTest.java index a9d6ea90..0f47275c 100644 --- a/src/test/java/site/dogether/docs/dailytodo/v2/DailyTodoControllerV2DocsTest.java +++ b/src/test/java/site/dogether/docs/dailytodo/v2/DailyTodoControllerV2DocsTest.java @@ -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())) @@ -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), @@ -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)))); } }