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));
}
Aggregations