-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
...ing/studayserver/domain/academy/service/dto/param/AcademiesByLocationWithScrollParam.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,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); | ||
} | ||
} | ||
|
61 changes: 61 additions & 0 deletions
61
.../studayserver/domain/academy/service/dto/result/AcademiesByLocationResultsWithScroll.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,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() | ||
); | ||
} | ||
|
||
} | ||
} |