use of wooteco.prolog.studylog.application.dto.StudylogLikeResponse 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.application.dto.StudylogLikeResponse 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.application.dto.StudylogLikeResponse in project prolog by woowacourse.
the class StudylogLikeServiceTest method unlike_loginMember_Success.
@DisplayName("로그인한 사용자가 스터디로그를 좋아요 취소 한다 - 성공")
@Test
void unlike_loginMember_Success() {
// given
Long memberId = member.getId();
Long studylogId = this.studylog.getId();
boolean isMember = true;
studylogLikeService.likeStudylog(memberId, studylogId, isMember);
// when
StudylogLikeResponse studylogLikeResponse = studylogLikeService.unlikeStudylog(memberId, studylogId, isMember);
// then
assertThat(studylogLikeResponse.isLiked()).isFalse();
assertThat(studylogLikeResponse.getLikesCount()).isZero();
}
use of wooteco.prolog.studylog.application.dto.StudylogLikeResponse in project prolog by woowacourse.
the class StudylogLikeServiceTest method like_loginMember_Success.
@DisplayName("로그인한 사용자가 스터디로그를 좋아요 한다 - 성공")
@Test
void like_loginMember_Success() {
// given
Long memberId = member.getId();
Long studylogId = this.studylog.getId();
boolean isMember = true;
// when
StudylogLikeResponse studylogLikeResponse = studylogLikeService.likeStudylog(memberId, studylogId, isMember);
// then
assertThat(studylogLikeResponse.isLiked()).isTrue();
assertThat(studylogLikeResponse.getLikesCount()).isOne();
}
Aggregations