use of wooteco.prolog.studylog.domain.StudylogDocument in project prolog by woowacourse.
the class StudylogDocumentService method findBySearchKeyword.
@Override
public StudylogDocumentResponse findBySearchKeyword(String keyword, List<Long> tags, List<Long> missions, List<Long> levels, List<String> usernames, LocalDate start, LocalDate end, Pageable pageable) {
final Query query = StudylogDocumentQueryBuilder.makeQuery(preprocess(keyword), tags, missions, levels, usernames, start, end, pageable);
// Query 결과를 ES에서 조회한다.
final SearchHits<StudylogDocument> searchHits = elasticsearchRestTemplate.search(query, StudylogDocument.class, IndexCoordinates.of("studylog-document"));
// 조회된 SearchHits를 페이징할 수 있는 SearchPage로 변경한다.
final SearchPage<StudylogDocument> searchPages = SearchHitSupport.searchPageFor(searchHits, query.getPageable());
final List<Long> studylogIds = searchPages.stream().map(searchPage -> searchPage.getContent().getId()).collect(toList());
return StudylogDocumentResponse.of(studylogIds, searchPages.getTotalElements(), searchPages.getTotalPages(), searchPages.getNumber());
}
use of wooteco.prolog.studylog.domain.StudylogDocument in project prolog by woowacourse.
the class FakeStudylogDocumentRepository method saveAll.
@Override
public <S extends StudylogDocument> Iterable<S> saveAll(Iterable<S> inputStudylogDocuments) {
List<StudylogDocument> studylogDocumentsWithId = new ArrayList<>();
for (StudylogDocument studylogDocument : inputStudylogDocuments) {
STUDYLOG_DOCUMENTS.add(studylogDocument);
STUDYLOG_DOCUMENTS.add(studylogDocument);
}
return (Iterable<S>) studylogDocumentsWithId;
}
use of wooteco.prolog.studylog.domain.StudylogDocument in project prolog by woowacourse.
the class StudylogServiceTest method insert.
@DisplayName("스터디로그를 삽입한다. - 삽입 시 studylogDocument도 삽입된다.")
@Test
void insert() {
// given
List<StudylogResponse> studylogResponses = insertStudylogs(member1, studylog1);
Long id = studylogResponses.get(0).getId();
// when
StudylogDocument studylogDocument = studylogDocumentService.findById(id);
// then
assertAll(() -> assertThat(studylogDocument.getId()).isEqualTo(id), () -> assertThat(studylogDocument.getTitle()).isEqualTo(studylog1.getTitle()), () -> assertThat(studylogDocument.getContent()).isEqualTo(studylog1.getContent()));
}
use of wooteco.prolog.studylog.domain.StudylogDocument in project prolog by woowacourse.
the class StudylogServiceTest method update.
@DisplayName("스터디로그를 수정한다 - 수정 시 studylogDocument도 수정된다.")
@Test
void update() {
// given
List<StudylogResponse> studylogResponses = insertStudylogs(member1, studylog1);
Long id = studylogResponses.get(0).getId();
StudylogRequest updateStudylogRequest = new StudylogRequest("updateTitle", "updateContent", 2L, toTagRequests(tags));
studylogService.updateStudylog(member1.getId(), id, updateStudylogRequest);
// when
StudylogDocument studylogDocument = studylogDocumentService.findById(id);
// then
assertAll(() -> assertThat(studylogDocument.getId()).isEqualTo(id), () -> assertThat(studylogDocument.getTitle()).isEqualTo(updateStudylogRequest.getTitle()), () -> assertThat(studylogDocument.getContent()).isEqualTo(updateStudylogRequest.getContent()));
}
Aggregations