Search in sources :

Example 1 with StudylogDeleteEvent

use of wooteco.prolog.studylog.event.StudylogDeleteEvent in project prolog by woowacourse.

the class StudylogService method deleteStudylog.

@Transactional
public void deleteStudylog(Long memberId, Long studylogId) {
    final Member foundMember = memberService.findById(memberId);
    Studylog studylog = studylogRepository.findById(studylogId).orElseThrow(StudylogNotFoundException::new);
    studylog.validateBelongTo(memberId);
    final Tags tags = tagService.findByStudylogsAndMember(studylog, foundMember);
    studylogDocumentService.delete(studylog.toStudylogDocument());
    checkScrapedOrRead(memberId, studylogId);
    memberTagService.removeMemberTag(tags, foundMember);
    studylog.delete();
    eventPublisher.publishEvent(new StudylogDeleteEvent(studylogId));
}
Also used : StudylogNotFoundException(wooteco.prolog.studylog.exception.StudylogNotFoundException) StudylogDeleteEvent(wooteco.prolog.studylog.event.StudylogDeleteEvent) LoginMember(wooteco.prolog.login.ui.LoginMember) Member(wooteco.prolog.member.domain.Member) Studylog(wooteco.prolog.studylog.domain.Studylog) Tags(wooteco.prolog.studylog.domain.Tags) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Transactional (org.springframework.transaction.annotation.Transactional)1 LoginMember (wooteco.prolog.login.ui.LoginMember)1 Member (wooteco.prolog.member.domain.Member)1 Studylog (wooteco.prolog.studylog.domain.Studylog)1 Tags (wooteco.prolog.studylog.domain.Tags)1 StudylogDeleteEvent (wooteco.prolog.studylog.event.StudylogDeleteEvent)1 StudylogNotFoundException (wooteco.prolog.studylog.exception.StudylogNotFoundException)1