Skip to content

Commit

Permalink
feat: 문제 삭제 시 오답 기록 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
yoursin0330 committed Nov 29, 2024
1 parent 6cef6cc commit cb19bd7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hangeulbada.domain.workbookset.repository;
package com.hangeulbada.domain.workbookset.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hangeulbada.domain.workbookset.repository;

import com.hangeulbada.domain.workbookset.dto.QuestionIdsDTO;
import com.hangeulbada.domain.workbookset.entity.IncorrectAnswerTag;
import org.springframework.data.mongodb.repository.Aggregation;
import org.springframework.data.mongodb.repository.MongoRepository;
Expand All @@ -18,4 +19,6 @@ public interface IncorrectAnswerTagRepository extends MongoRepository<IncorrectA
"{$project: {questionIds: 1, _id: 0}}"
})
QuestionIdsDTO findQuestionIdsByStudentIdAndTag(String studentId, String tag);

void deleteAllByQuestionId(String questionId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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;
import com.hangeulbada.domain.workbookset.dto.QuestionIdsDTO;

import java.util.List;

Expand All @@ -22,4 +22,6 @@ public interface IncorrectAnswerService {
IncorrectsGroupDTO getMyReviewGroup(String studentId);
//모든 오답 문제집 리스트
List<WorkbookDto> getReviewWorkbooks(String studentId);

void deleteRecordByQuestionId(String questionId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
import com.hangeulbada.domain.workbookset.entity.Workbook;
import com.hangeulbada.domain.workbookset.exception.NoIncorrectsException;
import com.hangeulbada.domain.workbookset.repository.IncorrectAnswerTagRepository;
import com.hangeulbada.domain.workbookset.repository.QuestionIdsDTO;
import com.hangeulbada.domain.workbookset.dto.QuestionIdsDTO;
import com.hangeulbada.domain.workbookset.repository.WorkbookRepository;
import com.hangeulbada.domain.workbookset.service.IncorrectAnswerService;
import com.hangeulbada.domain.workbookset.service.WorkbookService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.modelmapper.ModelMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.*;
Expand All @@ -37,6 +38,7 @@ public class IncorrectAnswerServiceImpl implements IncorrectAnswerService {
private final WorkbookRepository workbookRepository;
private final GroupService groupService;
private final GroupRepository groupRepository;
private final IncorrectAnswerTagRepository incorrectAnswerTagRepository;

@Override
public List<TagCountDto> countIncorrects(String studentId) {
Expand Down Expand Up @@ -71,6 +73,7 @@ public QuestionIdsDTO getIncorrectsByTag(String studentId, String tagName) {
return questionIdsDTO;
}

@Transactional
@Override
public WorkbookIdResponseDto createIncorrectsWorkbook(String studentId, TagRequestDto tagRequestDto){
// 오답 태그로 이뤄진 문장 가져오기
Expand Down Expand Up @@ -117,4 +120,10 @@ public List<WorkbookDto> getReviewWorkbooks(String studentId) {
return workbookDtos;
}

@Transactional
@Override
public void deleteRecordByQuestionId(String questionId) {
incorrectAnswerTagRepository.deleteAllByQuestionId(questionId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.hangeulbada.domain.workbookset.exception.WorkbookException;
import com.hangeulbada.domain.workbookset.repository.QuestionRepository;
import com.hangeulbada.domain.workbookset.repository.WorkbookRepository;
import com.hangeulbada.domain.workbookset.service.IncorrectAnswerService;
import com.hangeulbada.domain.workbookset.service.QuestionService;
import com.hangeulbada.domain.workbookset.service.WorkbookService;
import lombok.RequiredArgsConstructor;
Expand All @@ -33,6 +34,7 @@ public class QuestionServiceImpl implements QuestionService {
private final TTSService ttsService;
private final ApiService apiService;
private final WorkbookService workbookService;
private final IncorrectAnswerService incorrectAnswerService;

@Override
public List<QuestionResponseDto> getQuestionsByWorkbookId(String workbookId) {
Expand Down Expand Up @@ -70,6 +72,7 @@ public void deleteQuestion(String teacherId, String questionId) {
workbookService.updateWorkbookDifficulty(w.getId());
}
}
incorrectAnswerService.deleteRecordByQuestionId(questionId);
ttsService.deleteFileFromS3(question.getAudioFilePath());
questionRepository.deleteById(questionId);
}
Expand Down

0 comments on commit cb19bd7

Please sign in to comment.