-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
@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); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
연락처 상세 -> 관심주제 부분 API 구성완료하였습니다.
프론트쪽 공수가 더 많이 들 것 같아 우선 구성하였습니다
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; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네이밍 변경할까요?
NewsPaginationQueryCondition condition = | ||
new NewsPaginationQueryCondition(size, tagIds, cursorId); | ||
return newsRepository.findAllByTagIdWithCursor(condition); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존 코드 삭제 했던 부분 다시 롤백시켰습니다
public class TagSpecificNewsListFactory { | ||
|
||
private final TagReader tagReader; | ||
|
||
public List<TagSpecificNews> build( | ||
List<Long> tagIds, CursorPaginationResult<News> selectedTagsNewsList) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
공통적으로 많이 사용할 것 같아 Factory로 분리하였습니다
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; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
커서기반 페이지네이션 공통모듈입니다
📍 작업 배경 #
📝 작업 내용 #
💬 코멘트 #