use of wooteco.prolog.studylog.exception.StudylogNotFoundException in project prolog by woowacourse.
the class ReportAssembler method of.
private StudylogResponse of(ReportedStudylog reportedStudylog) {
List<StudylogAbilityResponse> abilityResponses = reportedStudylog.getAbilities().stream().map(this::of).collect(toList());
Studylog studylog = studylogRepository.findById(reportedStudylog.getStudylogId()).orElseThrow(StudylogNotFoundException::new);
return new StudylogResponse(studylog.getId(), studylog.getCreatedAt(), studylog.getUpdatedAt(), studylog.getTitle(), abilityResponses);
}
use of wooteco.prolog.studylog.exception.StudylogNotFoundException in project prolog by woowacourse.
the class StudylogLikeService method unlikeStudylog.
@Transactional
public StudylogLikeResponse unlikeStudylog(Long memberId, Long studylogId, boolean isMember) {
validIfMember(isMember);
Studylog studylog = studylogRepository.findById(studylogId).orElseThrow(StudylogNotFoundException::new);
Member member = memberService.findById(memberId);
studylog.unlike(member.getId());
return new StudylogLikeResponse(false, studylog.getLikeCount());
}
use of wooteco.prolog.studylog.exception.StudylogNotFoundException in project prolog by woowacourse.
the class StudylogLikeService method likeStudylog.
@Transactional
public StudylogLikeResponse likeStudylog(Long memberId, Long studylogId, boolean isMember) {
validIfMember(isMember);
Studylog studylog = studylogRepository.findById(studylogId).orElseThrow(StudylogNotFoundException::new);
Member member = memberService.findById(memberId);
studylog.like(member.getId());
return new StudylogLikeResponse(true, studylog.getLikeCount());
}
use of wooteco.prolog.studylog.exception.StudylogNotFoundException in project prolog by woowacourse.
the class StudylogScrapService method registerScrap.
@Transactional
public MemberScrapResponse registerScrap(Long memberId, Long studylogId) {
if (studylogScrapRepository.countByMemberIdAndScrapStudylogId(memberId, studylogId) > 0) {
throw new StudylogScrapAlreadyRegisteredException();
}
Studylog studylog = studylogRepository.findById(studylogId).orElseThrow(StudylogNotFoundException::new);
Member member = memberRepository.findById(memberId).orElseThrow(MemberNotFoundException::new);
StudylogScrap studylogScrap = new StudylogScrap(member, studylog);
studylogScrapRepository.save(studylogScrap);
return MemberScrapResponse.of(studylogScrap);
}
use of wooteco.prolog.studylog.exception.StudylogNotFoundException in project prolog by woowacourse.
the class StudylogService method insertStudylogRead.
private void insertStudylogRead(Long id, Long memberId) {
Member readMember = memberService.findById(memberId);
Studylog readStudylog = studylogRepository.findById(id).orElseThrow(StudylogNotFoundException::new);
studylogReadRepository.save(new StudylogRead(readMember, readStudylog));
}
Aggregations