use of wooteco.prolog.studylog.exception.StudylogReadNotExistException in project prolog by woowacourse.
the class StudylogService method checkScrapedOrRead.
private void checkScrapedOrRead(Long memberId, Long studylogId) {
if (studylogScrapRepository.existsByMemberIdAndStudylogId(memberId, studylogId)) {
StudylogScrap studylogScrap = studylogScrapRepository.findByMemberIdAndStudylogId(memberId, studylogId).orElseThrow(StudylogScrapNotExistException::new);
studylogScrapRepository.delete(studylogScrap);
}
if (studylogReadRepository.existsByMemberIdAndStudylogId(memberId, studylogId)) {
StudylogRead studylogRead = studylogReadRepository.findByMemberIdAndStudylogId(memberId, studylogId).orElseThrow(StudylogReadNotExistException::new);
studylogReadRepository.delete(studylogRead);
}
}
Aggregations