Skip to content

Commit

Permalink
feat: 유저의 모든 오답 문제집 조회
Browse files Browse the repository at this point in the history
  • Loading branch information
yoursin0330 committed Nov 27, 2024
1 parent 33da3a9 commit 64912cf
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -49,4 +50,11 @@ public ResponseEntity<WorkbookIdResponseDto> createIncorrectsWorkbook(@Valid @Re
public ResponseEntity<IncorrectsGroupDTO> getMyReviewGroup(Principal principal){
return ResponseEntity.ok(incorrectAnswerService.getMyReviewGroup(principal.getName()));
}

@StudentTag
@GetMapping("/group/workbooks")
@Operation(summary = "유저의 모든 오답 문제집", description = "모든 오답 문제집을 조회합니다.")
public ResponseEntity<List<WorkbookDto>> getMyReviewWorkbooks(Principal principal){
return ResponseEntity.ok(incorrectAnswerService.getReviewWorkbooks(principal.getName()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@

public interface WorkbookRepository extends MongoRepository<Workbook, String> {
List<Workbook> findByTeacherId(String teacherId);
List<Workbook> findByIdIn(List<String> ids);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -19,4 +20,6 @@ public interface IncorrectAnswerService {
WorkbookIdResponseDto createIncorrectsWorkbook(String studentId, TagRequestDto tagRequestDto);
//오답 그룹 리턴
IncorrectsGroupDTO getMyReviewGroup(String studentId);
//모든 오답 문제집 리스트
List<WorkbookDto> getReviewWorkbooks(String studentId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

@Slf4j
@Service
Expand Down Expand Up @@ -105,4 +106,15 @@ public IncorrectsGroupDTO getMyReviewGroup(String studentId) {
return groupService.getOrCreateReviewGroup(studentId);
}

@Override
public List<WorkbookDto> getReviewWorkbooks(String studentId) {
IncorrectsGroupDTO groupDto = groupService.getOrCreateReviewGroup(studentId);
List<Workbook> workbooks = workbookRepository.findByIdIn(groupDto.getWorkbookIds());
List<WorkbookDto> workbookDtos = workbooks.stream()
.map(workbook -> mapper.map(workbook, WorkbookDto.class)) // WorkbookDto 생성자 활용
.collect(Collectors.toList());

return workbookDtos;
}

}

0 comments on commit 64912cf

Please sign in to comment.