Search in sources :

Example 1 with StudylogReadNotExistException

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);
    }
}
Also used : StudylogRead(wooteco.prolog.studylog.domain.StudylogRead) StudylogScrapNotExistException(wooteco.prolog.studylog.exception.StudylogScrapNotExistException) StudylogScrap(wooteco.prolog.studylog.domain.StudylogScrap) StudylogReadNotExistException(wooteco.prolog.studylog.exception.StudylogReadNotExistException)

Aggregations

StudylogRead (wooteco.prolog.studylog.domain.StudylogRead)1 StudylogScrap (wooteco.prolog.studylog.domain.StudylogScrap)1 StudylogReadNotExistException (wooteco.prolog.studylog.exception.StudylogReadNotExistException)1 StudylogScrapNotExistException (wooteco.prolog.studylog.exception.StudylogScrapNotExistException)1