Search in sources :

Example 1 with StudylogScrapNotExistException

use of wooteco.prolog.studylog.exception.StudylogScrapNotExistException in project prolog by woowacourse.

the class StudylogScrapService method unregisterScrap.

@Transactional
public void unregisterScrap(Long memberId, Long studylogId) {
    StudylogScrap scrap = studylogScrapRepository.findByMemberIdAndStudylogId(memberId, studylogId).orElseThrow(StudylogScrapNotExistException::new);
    studylogScrapRepository.delete(scrap);
}
Also used : StudylogScrapNotExistException(wooteco.prolog.studylog.exception.StudylogScrapNotExistException) StudylogScrap(wooteco.prolog.studylog.domain.StudylogScrap) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with StudylogScrapNotExistException

use of wooteco.prolog.studylog.exception.StudylogScrapNotExistException 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

StudylogScrap (wooteco.prolog.studylog.domain.StudylogScrap)2 StudylogScrapNotExistException (wooteco.prolog.studylog.exception.StudylogScrapNotExistException)2 Transactional (org.springframework.transaction.annotation.Transactional)1 StudylogRead (wooteco.prolog.studylog.domain.StudylogRead)1 StudylogReadNotExistException (wooteco.prolog.studylog.exception.StudylogReadNotExistException)1