Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LINKER-X] fix: Pagination 공통화, 연락처 관심사 기반 뉴스 가져오기 #74

Merged
merged 2 commits into from
Feb 18, 2024

Conversation

ktj1997
Copy link
Contributor

@ktj1997 ktj1997 commented Feb 18, 2024

📍 작업 배경 #

  • issue : #

📝 작업 내용 #

💬 코멘트 #

Comment on lines +123 to +139
@GetMapping("/{contactId}/interest/news")
@Operation(summary = "연락처 관심사 기반 뉴스 가져오기")
public ApiResponse<GetContactInterestNewsResponse.Recommendations> getContactInterestRelatedNews(
@PathVariable Long contactId,
@RequestParam(defaultValue = "20") int size,
@AuthenticatedUserContext AuthenticatedUserContextHolder userContextHolder) {
List<TagSpecificNews> tagSpecificNewsList =
searchService.searchContactInterestRelatedNews(contactId, userContextHolder.getId(), size);

GetContactInterestNewsResponse.Recommendations recommendations =
new GetContactInterestNewsResponse.Recommendations(
tagSpecificNewsList.stream()
.map(GetContactInterestNewsResponse.Recommendation::fromTagSpecificNews)
.toList());
return ApiResponse.success(recommendations);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

연락처 상세 -> 관심주제 부분 API 구성완료하였습니다.
프론트쪽 공수가 더 많이 들 것 같아 우선 구성하였습니다

Comment on lines +19 to +26
public class ContactSearchService {

private final NewsReader newsReader;
private final ContactsReader contactsReader;
private final ContactInterestReader contactInterestReader;
private final ContactsBookmarkReader contactsBookmarkReader;
private final ScheduleParticipantReader scheduleParticipantReader;
private final TagSpecificNewsListFactory tagSpecificNewsListFactory;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존 ContactsService가 비대해지는 것 같아 Service분리하였습니다

@@ -16,34 +11,8 @@
public class ContactsService {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네이밍 변경할까요?

Comment on lines +23 to 26
NewsPaginationQueryCondition condition =
new NewsPaginationQueryCondition(size, tagIds, cursorId);
return newsRepository.findAllByTagIdWithCursor(condition);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존 코드 삭제 했던 부분 다시 롤백시켰습니다

Comment on lines +14 to +19
public class TagSpecificNewsListFactory {

private final TagReader tagReader;

public List<TagSpecificNews> build(
List<Long> tagIds, CursorPaginationResult<News> selectedTagsNewsList) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

공통적으로 많이 사용할 것 같아 Factory로 분리하였습니다

Comment on lines 6 to 12
public class CursorPaginationTemplate {
public static <T extends CursorExtractable> CursorPaginationResult<T> execute(
int size, Function<Integer, List<T>> query) {
List<T> data = query.apply(size + 1);
Long cursor, int size, BiFunction<Long, Integer, List<T>> query) {
List<T> data = query.apply(cursor, size + 1);
boolean hasNext = data.size() == size + 1;
Long nextCursor = hasNext ? data.get(size).getId() : null;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

커서기반 페이지네이션 공통모듈입니다

@ktj1997 ktj1997 merged commit 017bf7b into dev Feb 18, 2024
1 check passed
@9keyyyy 9keyyyy deleted the FIRM-X/contacts-related-news branch February 20, 2024 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant