diff --git a/src/main/java/com/hangeulbada/domain/workbookset/controller/IncorrectAnswerController.java b/src/main/java/com/hangeulbada/domain/workbookset/controller/IncorrectAnswerController.java index cf1e727..ddfb70f 100644 --- a/src/main/java/com/hangeulbada/domain/workbookset/controller/IncorrectAnswerController.java +++ b/src/main/java/com/hangeulbada/domain/workbookset/controller/IncorrectAnswerController.java @@ -4,6 +4,7 @@ import com.hangeulbada.domain.group.dto.IncorrectsGroupDTO; import com.hangeulbada.domain.workbookset.dto.TagCountDto; import com.hangeulbada.domain.workbookset.dto.TagRequestDto; +import com.hangeulbada.domain.workbookset.dto.WorkbookDto; import com.hangeulbada.domain.workbookset.dto.WorkbookIdResponseDto; import com.hangeulbada.domain.workbookset.service.IncorrectAnswerService; import io.swagger.v3.oas.annotations.Operation; @@ -49,4 +50,11 @@ public ResponseEntity createIncorrectsWorkbook(@Valid @Re public ResponseEntity getMyReviewGroup(Principal principal){ return ResponseEntity.ok(incorrectAnswerService.getMyReviewGroup(principal.getName())); } + + @StudentTag + @GetMapping("/group/workbooks") + @Operation(summary = "유저의 모든 오답 문제집", description = "모든 오답 문제집을 조회합니다.") + public ResponseEntity> getMyReviewWorkbooks(Principal principal){ + return ResponseEntity.ok(incorrectAnswerService.getReviewWorkbooks(principal.getName())); + } } \ No newline at end of file diff --git a/src/main/java/com/hangeulbada/domain/workbookset/repository/WorkbookRepository.java b/src/main/java/com/hangeulbada/domain/workbookset/repository/WorkbookRepository.java index 6904de7..1c45716 100644 --- a/src/main/java/com/hangeulbada/domain/workbookset/repository/WorkbookRepository.java +++ b/src/main/java/com/hangeulbada/domain/workbookset/repository/WorkbookRepository.java @@ -7,4 +7,5 @@ public interface WorkbookRepository extends MongoRepository { List findByTeacherId(String teacherId); + List findByIdIn(List ids); } diff --git a/src/main/java/com/hangeulbada/domain/workbookset/service/IncorrectAnswerService.java b/src/main/java/com/hangeulbada/domain/workbookset/service/IncorrectAnswerService.java index 483be92..f0d6d27 100644 --- a/src/main/java/com/hangeulbada/domain/workbookset/service/IncorrectAnswerService.java +++ b/src/main/java/com/hangeulbada/domain/workbookset/service/IncorrectAnswerService.java @@ -3,6 +3,7 @@ import com.hangeulbada.domain.group.dto.IncorrectsGroupDTO; import com.hangeulbada.domain.workbookset.dto.TagCountDto; import com.hangeulbada.domain.workbookset.dto.TagRequestDto; +import com.hangeulbada.domain.workbookset.dto.WorkbookDto; import com.hangeulbada.domain.workbookset.dto.WorkbookIdResponseDto; import com.hangeulbada.domain.workbookset.repository.QuestionIdsDTO; @@ -19,4 +20,6 @@ public interface IncorrectAnswerService { WorkbookIdResponseDto createIncorrectsWorkbook(String studentId, TagRequestDto tagRequestDto); //오답 그룹 리턴 IncorrectsGroupDTO getMyReviewGroup(String studentId); + //모든 오답 문제집 리스트 + List getReviewWorkbooks(String studentId); } diff --git a/src/main/java/com/hangeulbada/domain/workbookset/service/impl/IncorrectAnswerServiceImpl.java b/src/main/java/com/hangeulbada/domain/workbookset/service/impl/IncorrectAnswerServiceImpl.java index 9cd7be9..642637b 100644 --- a/src/main/java/com/hangeulbada/domain/workbookset/service/impl/IncorrectAnswerServiceImpl.java +++ b/src/main/java/com/hangeulbada/domain/workbookset/service/impl/IncorrectAnswerServiceImpl.java @@ -20,6 +20,7 @@ import java.time.LocalDateTime; import java.util.*; +import java.util.stream.Collectors; @Slf4j @Service @@ -105,4 +106,15 @@ public IncorrectsGroupDTO getMyReviewGroup(String studentId) { return groupService.getOrCreateReviewGroup(studentId); } + @Override + public List getReviewWorkbooks(String studentId) { + IncorrectsGroupDTO groupDto = groupService.getOrCreateReviewGroup(studentId); + List workbooks = workbookRepository.findByIdIn(groupDto.getWorkbookIds()); + List workbookDtos = workbooks.stream() + .map(workbook -> mapper.map(workbook, WorkbookDto.class)) // WorkbookDto 생성자 활용 + .collect(Collectors.toList()); + + return workbookDtos; + } + }