Skip to content

Commit

Permalink
[Refactor] - 여행기 응답 DTO 속성 이름 변경 (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
hangillee authored Jul 24, 2024
1 parent b36e49b commit 8ef1bbd
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public record TraveloguePlaceRequest(
@Schema(description = "여행기 장소 위치 정보")
@NotNull(message = "여행기 장소 위치 정보는 비어있을 수 없습니다.")
@Valid
TravelogueLocationRequest location,
TraveloguePositionRequest position,
@Schema(description = "여행기 장소 설명", example = "성담 빌딩에 위치한 선릉 캠퍼스입니다.")
String description,
@Schema(description = "여행기 장소 사진")
Expand All @@ -29,6 +29,6 @@ public TraveloguePlace toTraveloguePlace(int order, Place place, TravelogueDay t
}

public Place toPlace() {
return new Place(name, location.lat(), location.lng());
return new Place(name, position.lat(), position.lng());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;

public record TravelogueLocationRequest(
public record TraveloguePositionRequest(
@Schema(description = "여행기 장소 위도", example = "37.5175896")
@NotNull(message = "여행기 장소 위도는 비어있을 수 없습니다.")
String lat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public record TraveloguePlaceResponse(
String name,
@Schema(description = "여행기 장소 설명", example = "성담 빌딩에 위치한 선릉 캠퍼스입니다.")
String description,
TravelogueLocationResponse location,
TraveloguePositionResponse position,
List<String> photoUrls
) {

Expand All @@ -22,7 +22,7 @@ public static TraveloguePlaceResponse of(TraveloguePlace place, List<String> pho
.id(place.getId())
.name(place.getName())
.description(place.getDescription())
.location(TravelogueLocationResponse.from(place))
.position(TraveloguePositionResponse.from(place))
.photoUrls(photoUrls)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import woowacourse.touroot.travelogue.domain.TraveloguePlace;

@Builder
public record TravelogueLocationResponse(
public record TraveloguePositionResponse(
@Schema(description = "여행기 장소 위도", example = "37.5175896")
String lat,
@Schema(description = "여행기 장소 설명", example = "127.0867236")
String lng
) {
public static TravelogueLocationResponse from(TraveloguePlace place) {
return TravelogueLocationResponse.builder()

public static TraveloguePositionResponse from(TraveloguePlace place) {
return TraveloguePositionResponse.builder()
.lat(place.getLatitude())
.lng(place.getLongitude())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public Map<TraveloguePlace, List<TraveloguePhotoRequest>> createPlaces(
private Place getPlace(TraveloguePlaceRequest request) {
return placeRepository.findByNameAndLatitudeAndLongitude(
request.name(),
request.location().lat(),
request.location().lng()
request.position().lat(),
request.position().lng()
).orElseGet(() -> placeRepository.save(request.toPlace()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import woowacourse.touroot.travelogue.domain.TraveloguePhoto;
import woowacourse.touroot.travelogue.domain.TraveloguePlace;
import woowacourse.touroot.travelogue.dto.request.TravelogueDayRequest;
import woowacourse.touroot.travelogue.dto.request.TravelogueLocationRequest;
import woowacourse.touroot.travelogue.dto.request.TraveloguePhotoRequest;
import woowacourse.touroot.travelogue.dto.request.TraveloguePlaceRequest;
import woowacourse.touroot.travelogue.dto.request.TraveloguePositionRequest;
import woowacourse.touroot.travelogue.dto.request.TravelogueRequest;
import woowacourse.touroot.travelogue.dto.response.TravelogueDayResponse;
import woowacourse.touroot.travelogue.dto.response.TravelogueLocationResponse;
import woowacourse.touroot.travelogue.dto.response.TraveloguePlaceResponse;
import woowacourse.touroot.travelogue.dto.response.TraveloguePositionResponse;
import woowacourse.touroot.travelogue.dto.response.TravelogueResponse;

@Component
Expand Down Expand Up @@ -56,14 +56,14 @@ public static List<TravelogueDayRequest> getTravelogueDayRequests() {
public static List<TraveloguePlaceRequest> getTraveloguePlaceRequests() {
return List.of(new TraveloguePlaceRequest(
"블라디보스토크",
getTravelogueLocationRequest(),
getTraveloguePositionRequest(),
"극동의 진주, 블라디보스토크.",
getTraveloguePhotoRequests()
));
}

public static TravelogueLocationRequest getTravelogueLocationRequest() {
return new TravelogueLocationRequest("37.1234", "127.1234");
public static TraveloguePositionRequest getTraveloguePositionRequest() {
return new TraveloguePositionRequest("37.1234", "127.1234");
}

public static List<TraveloguePhotoRequest> getTraveloguePhotoRequests() {
Expand Down Expand Up @@ -101,14 +101,14 @@ public static List<TraveloguePlaceResponse> getTraveloguePlaceResponses() {
.id(1L)
.name("블라디보스토크")
.description("극동의 진주, 블라디보스토크.")
.location(getTravelogueLocationResponse())
.position(getTraveloguePositionResponse())
.photoUrls(getTraveloguePhotoUrls())
.build()
);
}

public static TravelogueLocationResponse getTravelogueLocationResponse() {
return TravelogueLocationResponse.builder()
public static TraveloguePositionResponse getTraveloguePositionResponse() {
return TraveloguePositionResponse.builder()
.lat("37.1234")
.lng("127.1234")
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public static TraveloguePhoto getTraveloguePhoto(String key, Integer order, Trav
public void initTravelogueTestData() {
Travelogue travelogue = persistTravelogue();
TravelogueDay day = persistTravelogueDay(travelogue);
Place location = persistPlace();
TraveloguePlace place = persistTraveloguePlace(location, day);
Place position = persistPlace();
TraveloguePlace place = persistTraveloguePlace(position, day);
persistTraveloguePhoto(place);
}

Expand All @@ -85,8 +85,8 @@ public Place persistPlace() {
return placeRepository.save(place);
}

public TraveloguePlace persistTraveloguePlace(Place location, TravelogueDay day) {
TraveloguePlace place = getTraveloguePlace(1, "극동의 진주, 블라디보스토크.", location, day);
public TraveloguePlace persistTraveloguePlace(Place position, TravelogueDay day) {
TraveloguePlace place = getTraveloguePlace(1, "극동의 진주, 블라디보스토크.", position, day);

return traveloguePlaceRepository.save(place);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ void createPhotos() {
List<TraveloguePhotoRequest> requests = TravelogueTestFixture.getTraveloguePhotoRequests();
Travelogue travelogue = testHelper.persistTravelogue();
TravelogueDay day = testHelper.persistTravelogueDay(travelogue);
Place location = testHelper.persistPlace();
TraveloguePlace place = testHelper.persistTraveloguePlace(location, day);
Place position = testHelper.persistPlace();
TraveloguePlace place = testHelper.persistTraveloguePlace(position, day);

List<TraveloguePhoto> photos = photoService.createPhotos(requests, place);

Expand All @@ -48,8 +48,8 @@ void createPhotos() {
void findPhotoUrlsByPlace() {
Travelogue travelogue = testHelper.persistTravelogue();
TravelogueDay day = testHelper.persistTravelogueDay(travelogue);
Place location = testHelper.persistPlace();
TraveloguePlace place = testHelper.persistTraveloguePlace(location, day);
Place position = testHelper.persistPlace();
TraveloguePlace place = testHelper.persistTraveloguePlace(position, day);
TraveloguePhoto photo = testHelper.persistTraveloguePhoto(place);

List<String> photoUrls = photoService.findPhotoUrlsByPlace(place);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ void createPlaces() {
void findTraveloguePlacesByDay() {
Travelogue travelogue = testHelper.persistTravelogue();
TravelogueDay day = testHelper.persistTravelogueDay(travelogue);
Place location = testHelper.persistPlace();
TraveloguePlace place = testHelper.persistTraveloguePlace(location, day);
Place position = testHelper.persistPlace();
TraveloguePlace place = testHelper.persistTraveloguePlace(position, day);

List<TraveloguePlace> places = placeService.findTraveloguePlacesByDay(day);

Expand Down

0 comments on commit 8ef1bbd

Please sign in to comment.