use of wooteco.prolog.session.domain.Session in project prolog by woowacourse.
the class StudylogService method updateStudylog.
@Transactional
public void updateStudylog(Long memberId, Long studylogId, StudylogRequest studylogRequest) {
Studylog studylog = studylogRepository.findById(studylogId).orElseThrow(StudylogNotFoundException::new);
studylog.validateBelongTo(memberId);
Session session = sessionService.findSessionById(studylogRequest.getSessionId()).orElse(null);
Mission mission = missionService.findMissionById(studylogRequest.getMissionId()).orElse(null);
final Member foundMember = memberService.findById(memberId);
final Tags originalTags = tagService.findByStudylogsAndMember(studylog, foundMember);
Tags newTags = tagService.findOrCreate(studylogRequest.getTags());
studylog.update(studylogRequest.getTitle(), studylogRequest.getContent(), session, mission, newTags);
memberTagService.updateMemberTag(originalTags, newTags, foundMember);
studylogDocumentService.update(studylog.toStudylogDocument());
}
use of wooteco.prolog.session.domain.Session in project prolog by woowacourse.
the class StudylogTest method getPopularScore.
@DisplayName("좋아요와 조회를 기준으로 인기점수를 반환한다.")
@Test
void getPopularScore() {
// given
Member member = new Member("최현구", "현구막", Role.CREW, 1L, "image");
Session session = new Session("세션 1");
Mission mission = new Mission("자동차 미션", session);
Tag tag1 = new Tag("Java");
Tag tag2 = new Tag("Spring");
Studylog studylog = new Studylog(member, "제목", "내용", mission, Arrays.asList(tag1, tag2));
// when, then
assertThat(studylog.getPopularScore()).isEqualTo(0);
studylog.increaseViewCount();
assertThat(studylog.getPopularScore()).isEqualTo(1);
studylog.like(1L);
assertThat(studylog.getPopularScore()).isEqualTo(3 + 1);
}
use of wooteco.prolog.session.domain.Session in project prolog by woowacourse.
the class StudylogScrapRepositoryTest method setUp.
@BeforeEach
void setUp() {
member = memberRepository.save(웨지);
Session session = sessionRepository.save(new Session("세션1"));
Mission mission = missionRepository.save(new Mission("미션", session));
studylog = studylogRepository.save(new Studylog(member, "제목", "내용", mission, Lists.emptyList()));
}
use of wooteco.prolog.session.domain.Session in project prolog by woowacourse.
the class StudylogTagRepositoryTest method findByTagIn.
@DisplayName("Tag 리스트와 매칭되는 StudylogTag 리스트 조회")
@Test
void findByTagIn() {
// given
Member member = memberRepository.save(웨지);
Session session = sessionRepository.save(new Session("세션1"));
Mission mission = missionRepository.save(new Mission("미션", session));
Studylog studylog1 = studylogRepository.save(new Studylog(member, "제목1", "내용1", mission, Lists.emptyList()));
Studylog studylog2 = studylogRepository.save(new Studylog(member, "제목2", "내용2", mission, Lists.emptyList()));
Tag tag1 = tagRepository.save(new Tag("태그1"));
Tag tag2 = tagRepository.save(new Tag("태그2"));
StudylogTag studylogTag1 = studylogTagRepository.save(new StudylogTag(studylog1, tag1));
StudylogTag studylogTag2 = studylogTagRepository.save(new StudylogTag(studylog1, tag2));
StudylogTag studylogTag3 = studylogTagRepository.save(new StudylogTag(studylog2, tag2));
// when
List<StudylogTag> studylogTags = studylogTagRepository.findByTagIn(Arrays.asList(tag1, tag2));
// then
assertThat(studylogTags).usingFieldByFieldElementComparator().containsExactlyInAnyOrder(studylogTag1, studylogTag2, studylogTag3);
}
use of wooteco.prolog.session.domain.Session in project prolog by woowacourse.
the class StudylogService method updateStudylogSession.
@Transactional
public void updateStudylogSession(Long memberId, Long studylogId, StudylogSessionRequest studylogSessionRequest) {
Studylog studylog = studylogRepository.findById(studylogId).orElseThrow(StudylogNotFoundException::new);
studylog.validateBelongTo(memberId);
Session session = sessionService.findSessionById(studylogSessionRequest.getSessionId()).orElse(null);
studylog.updateSession(session);
}
Aggregations