-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: release token expire length (#314) * 뒤로가기 시 필터와 페이지네이션 유지 (#308) * feature: url path params for history * feature: url path params for history * refactor: filter 중복 함수 훅으로 변경 * fix: 필요하지 않은 props 삭제 * fix: makeFilters 에러처리 추가 * refactor: makeFilters 함수 리팩토링 Co-authored-by: dudtjr913 <64782636+dudtjr913@users.noreply.github.com> * fix: ProfilePage에서 글 목록 안 나타나는 현상 수정 (#380) * fix: requestGetPosts 사용방식 통일 * fix: tag 많을 시 스크롤 추가 * 학습로그 검색 기능 버그 수정 및 전반적 기능 변경 (#382) * fix: StudylogDocumentRepository 응답값 Page로 변경 * feat: StudylogDocument 관리 필드 추가 * feat: SearchDocument에 필드 추가 후 로직 뼈대 잡기 * feat: sample 쿼리 추가 및 studylog-document로 재수정 * feat: TODO 추가 및 일부 수정 * etc: TODO 추가 * feat: StudylogDocumentQueryBuilder 추가 * QueryBuilder 및 SearchPage로 Paging 응답은 잘 받아오지만, 역시나 StudylogRepository 조회 문제로 인해 페이징이 되지 않음. * local 환경에서 QueryBuilder를 어떤 식으로 동작하게 해야할 지 고민해야함. * etc: DataLoader 동기화 메서드 추가 * feat: Paging 기능 추가 * feat: local용 FakeStudylogDocumentService 생성 * feat: StudylogDocumentService의 응답을 DTO로 변경 * refactor: FakeStudylogDocumentService 패키지 이동 * feat: FakeStudylogDocumentRepository#findBySearchKeyword 구현 * fix: flyway test 및 local 환경에서 작동하지 않도록 수정 * fix: StudylogDocumentQueryBuilder에서 tagIds만 Filter 적용하고, 나머지는 Bool 쿼리 적용하도록 수정 * 학습로그 목록 조회 시 필요한 쿼리 스트링 변경 (#381) * fix: 첫 페이지는 쿼리 스트링을 제거한다 fix: 사이즈와 정렬은 쿼리 스트링에서 제거한다 fix: 필터를 제거했을 때 첫 페이지로 이동한다 fix: 프로필>포스트usernames를 쿼리스트링에서 제거한다. * fix: 메인 페이지 적용 * fix: 키워드가 없을 때 발생하는 에러 수정 (#384) * fix: 포스트에 포함된 태그만 노출 * fix: 필터 및 페이징이 정상동작하지 않는 이슈 해결 (#387) 연관 이슈 - 2 > 1 페이지 이동 x - 마지막 필터 취소 시 취소되지 않음 * fix: 머지 이슈 해결 Co-authored-by: dudtjr913 <64782636+dudtjr913@users.noreply.github.com> Co-authored-by: HyuuunjuKim <43339385+HyuuunjuKim@users.noreply.github.com> Co-authored-by: 서민정 <seominjeong.dev@gmail.com> Co-authored-by: sunhpark42 <67677561+sunhpark42@users.noreply.github.com>
- Loading branch information
1 parent
07785f4
commit 57c47d0
Showing
33 changed files
with
668 additions
and
370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...nd/src/main/java/wooteco/prolog/studylog/application/AbstractStudylogDocumentService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package wooteco.prolog.studylog.application; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import wooteco.prolog.studylog.domain.Studylog; | ||
import wooteco.prolog.studylog.domain.StudylogDocument; | ||
import wooteco.prolog.studylog.domain.repository.StudylogDocumentRepository; | ||
import wooteco.prolog.studylog.domain.repository.StudylogRepository; | ||
import wooteco.prolog.studylog.exception.StudylogDocumentNotFoundException; | ||
|
||
public abstract class AbstractStudylogDocumentService implements DocumentService { | ||
|
||
private static final String EMPTY = " "; | ||
|
||
protected final StudylogDocumentRepository studylogDocumentRepository; | ||
protected final StudylogRepository studylogRepository; | ||
|
||
public AbstractStudylogDocumentService(StudylogDocumentRepository studylogDocumentRepository, | ||
StudylogRepository studylogRepository) { | ||
this.studylogDocumentRepository = studylogDocumentRepository; | ||
this.studylogRepository = studylogRepository; | ||
} | ||
|
||
@Override | ||
public void save(StudylogDocument studylogDocument) { | ||
studylogDocumentRepository.save(studylogDocument); | ||
} | ||
|
||
@Override | ||
public StudylogDocument findById(Long id) { | ||
return studylogDocumentRepository.findById(id) | ||
.orElseThrow(StudylogDocumentNotFoundException::new); | ||
} | ||
|
||
@Override | ||
public void delete(StudylogDocument studylogDocument) { | ||
studylogDocumentRepository.delete(studylogDocument); | ||
} | ||
|
||
@Override | ||
public void deleteAll() { | ||
studylogDocumentRepository.deleteAll(); | ||
} | ||
|
||
@Override | ||
public void sync() { | ||
// sync between es and db | ||
studylogDocumentRepository.deleteAll(); | ||
|
||
List<Studylog> studylogs = studylogRepository.findAll(); | ||
studylogDocumentRepository.saveAll( | ||
studylogs.stream() | ||
.map(Studylog::toStudylogDocument) | ||
.collect(Collectors.toList()) | ||
); | ||
} | ||
|
||
@Override | ||
public void update(StudylogDocument studylogDocument) { | ||
studylogDocumentRepository.save(studylogDocument); | ||
} | ||
|
||
protected List<String> preprocess(String searchKeyword) { | ||
String[] split = searchKeyword.split(EMPTY); | ||
List<String> results = new ArrayList<>(); | ||
Collections.addAll(results, split); | ||
if (split.length == 1) { | ||
return results; | ||
} | ||
results.add(searchKeyword); // 기존 검색어도 리스트에 포함한다. | ||
return results; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
backend/src/main/java/wooteco/prolog/studylog/application/DocumentService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package wooteco.prolog.studylog.application; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
import org.springframework.data.domain.Pageable; | ||
import wooteco.prolog.studylog.application.dto.StudylogDocumentResponse; | ||
import wooteco.prolog.studylog.domain.StudylogDocument; | ||
|
||
public interface DocumentService { | ||
|
||
void save(StudylogDocument toStudylogDocument); | ||
|
||
StudylogDocument findById(Long id); | ||
|
||
void delete(StudylogDocument studylogDocument); | ||
|
||
void deleteAll(); | ||
|
||
void sync(); | ||
|
||
void update(StudylogDocument studylogDocument); | ||
|
||
StudylogDocumentResponse findBySearchKeyword( | ||
String keyword, | ||
List<Long> tags, | ||
List<Long> missions, | ||
List<Long> levels, | ||
List<String> usernames, | ||
LocalDate start, | ||
LocalDate end, | ||
Pageable pageable | ||
); | ||
} |
65 changes: 65 additions & 0 deletions
65
backend/src/main/java/wooteco/prolog/studylog/application/FakeStudylogDocumentService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package wooteco.prolog.studylog.application; | ||
|
||
import java.time.LocalDate; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.stream.Collectors; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.domain.Specification; | ||
import org.springframework.stereotype.Service; | ||
import wooteco.prolog.common.BaseEntity; | ||
import wooteco.prolog.studylog.application.dto.StudylogDocumentResponse; | ||
import wooteco.prolog.studylog.domain.Studylog; | ||
import wooteco.prolog.studylog.domain.repository.StudylogDocumentRepository; | ||
import wooteco.prolog.studylog.domain.repository.StudylogRepository; | ||
import wooteco.prolog.studylog.domain.repository.StudylogSpecification; | ||
|
||
@Profile({"local", "test"}) | ||
@Service | ||
public class FakeStudylogDocumentService extends AbstractStudylogDocumentService { | ||
|
||
public FakeStudylogDocumentService( | ||
StudylogDocumentRepository studylogDocumentRepository, | ||
StudylogRepository studylogRepository) { | ||
super(studylogDocumentRepository, studylogRepository); | ||
} | ||
|
||
@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 Page<Studylog> studylogs = studylogRepository.findAll( | ||
makeSpecifications(keyword, tags, missions, levels, usernames, start, end), pageable); | ||
|
||
final List<Long> studylogIds = studylogs.stream() | ||
.map(BaseEntity::getId) | ||
.collect(Collectors.toList()); | ||
|
||
return StudylogDocumentResponse.of(studylogIds, | ||
studylogs.getTotalElements(), | ||
studylogs.getTotalPages(), | ||
studylogs.getNumber()); | ||
} | ||
|
||
private Specification<Studylog> makeSpecifications(String keyword, List<Long> tags, List<Long> missions, | ||
List<Long> levels, List<String> usernames, | ||
LocalDate start, LocalDate end | ||
) { | ||
List<String> keywords = new ArrayList<>(); | ||
if (Objects.nonNull(keyword)) { | ||
keywords = preprocess(keyword); | ||
} | ||
|
||
return StudylogSpecification.likeKeyword("title", keywords) | ||
.or(StudylogSpecification.likeKeyword("content", keywords)) | ||
.and(StudylogSpecification.findByLevelIn(levels) | ||
.and(StudylogSpecification.equalIn("mission", missions)) | ||
.and(StudylogSpecification.findByTagIn(tags)) | ||
.and(StudylogSpecification.findByUsernameIn(usernames)) | ||
.and(StudylogSpecification.findBetweenDate(start, end)) | ||
.and(StudylogSpecification.distinct(true))); | ||
} | ||
} |
Oops, something went wrong.