Skip to content

Commit

Permalink
feat: 코스 상세 조회 요청 시 위도와 경도를 응답 받도록 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeuk520 committed Sep 27, 2024
1 parent 200e86a commit b83ebdd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public record GetCommunityCourseInfoResponse(Long courseId, String courseName, S

@Builder
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public record PlaceList(Long placeId, String placeName, String placeDescription, String category, String imageUrl) {
public record PlaceList(Long placeId, String placeName, String placeDescription, String category,
String imageUrl, Double latitude, Double longitude) {
}

public static GetCommunityCourseInfoResponse from(Course course, boolean dibs) {
Expand All @@ -25,6 +26,8 @@ public static GetCommunityCourseInfoResponse from(Course course, boolean dibs) {
.placeName(place.getName())
.category(place.getCategory())
.imageUrl(place.getImageUrl())
.latitude(place.getCoordinate().getY())
.longitude(place.getCoordinate().getX())
.build()
).toList();
return GetCommunityCourseInfoResponse.builder()
Expand Down
11 changes: 10 additions & 1 deletion src/test/java/com/ku/covigator/service/CourseServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.ku.covigator.repository.CourseRepository;
import com.ku.covigator.repository.DibsRepository;
import com.ku.covigator.repository.MemberRepository;
import com.ku.covigator.support.GeometryUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -400,6 +401,7 @@ void findCourseInfo() {
.name("가츠시")
.description("공대생 추천 맛집")
.category("식당")
.coordinate(GeometryUtils.generatePoint(1.1,2.2))
.build();

CoursePlace place2 = CoursePlace.builder()
Expand All @@ -408,6 +410,7 @@ void findCourseInfo() {
.name("레스티오")
.description("공대생 추천 카페")
.category("카페")
.coordinate(GeometryUtils.generatePoint(3.3,4.4))
.build();
coursePlaceRepository.saveAll(List.of(place, place2));

Expand Down Expand Up @@ -435,7 +438,13 @@ void findCourseInfo() {
.containsExactlyInAnyOrder("공대생 추천 맛집", "공대생 추천 카페"),
() -> assertThat(response.places())
.extracting("category")
.containsExactlyInAnyOrder("식당", "카페")
.containsExactlyInAnyOrder("식당", "카페"),
() -> assertThat(response.places())
.extracting("latitude")
.containsExactlyInAnyOrder(1.1, 3.3),
() -> assertThat(response.places())
.extracting("longitude")
.containsExactlyInAnyOrder(2.2, 4.4)
);
}

Expand Down

0 comments on commit b83ebdd

Please sign in to comment.