Skip to content

Commit

Permalink
Feat : 무한스크롤 위치기반 학원 데이터 서비스 dto 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
byeolhaha committed Dec 1, 2023
1 parent bd79ab7 commit f07be95
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.guzzing.studayserver.domain.academy.service.dto.param;

public record AcademiesByLocationWithScrollParam (
Double baseLatitude,
Double baseLongitude,
Long memberId,
int pageNumber
) {

public static AcademiesByLocationWithScrollParam of(
Double baseLatitude,
Double baseLongitude,
Long memberId,
int pageNumber) {
return new AcademiesByLocationWithScrollParam(baseLatitude, baseLongitude, memberId, pageNumber);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.guzzing.studayserver.domain.academy.service.dto.result;

import org.guzzing.studayserver.domain.academy.repository.dto.AcademiesByLocationWithScroll;
import org.guzzing.studayserver.domain.academy.repository.dto.AcademyByLocationWithScroll;
import org.guzzing.studayserver.domain.academy.util.CategoryInfo;
import java.util.List;
import java.util.Map;

public record AcademiesByLocationResultsWithScroll(
List<AcademiesByLocationResultWithScroll> academiesByLocationResults,
boolean hasNext
) {

public static AcademiesByLocationResultsWithScroll to(
AcademiesByLocationWithScroll academiesByLocationWithScroll,
Map<Long, List<Long>> academyIdWithCategories) {
return new AcademiesByLocationResultsWithScroll(
academiesByLocationWithScroll
.academiesByLocation()
.stream()
.map(
academyByLocationWithScroll ->
AcademiesByLocationResultWithScroll.from(
academyByLocationWithScroll,
academyIdWithCategories.get(academyByLocationWithScroll.academyId())
))
.toList(),
academiesByLocationWithScroll.hasNext());
}

public record AcademiesByLocationResultWithScroll(
Long academyId,
String academyName,
String address,
String contact,
List<String> categories,
Double latitude,
Double longitude,
String shuttleAvailable,
boolean isLiked
) {

public static AcademiesByLocationResultWithScroll from(AcademyByLocationWithScroll academyByLocationWithScroll,
List<Long> categories) {
return new AcademiesByLocationResultWithScroll(
academyByLocationWithScroll.academyId(),
academyByLocationWithScroll.academyName(),
academyByLocationWithScroll.fullAddress(),
academyByLocationWithScroll.phoneNumber(),
categories.stream()
.map(categoryId -> CategoryInfo.getCategoryNameById(categoryId))
.toList(),
academyByLocationWithScroll.latitude(),
academyByLocationWithScroll.longitude(),
academyByLocationWithScroll.shuttleAvailable(),
academyByLocationWithScroll.isLiked()
);
}

}
}

0 comments on commit f07be95

Please sign in to comment.