Conversation
| return PlaceSearchResponse.from(new PlaceSearchResponseParams( | ||
| place, | ||
| placeImagesUrl, | ||
| savedCategory.map(Category::getName).orElse(null), | ||
| savedMagazine.map(Magazine::getTitle).orElse(null), | ||
| savedMagazine.map(Magazine::getIconUrl).orElse(null)) | ||
| ); |
| public static PlaceSearchResponse from(PlaceSearchResponseParams params){ | ||
| Place place = params.place(); | ||
| return PlaceSearchResponse.builder() | ||
| .placeId(place.getId()) | ||
| .name(place.getName()) | ||
| .shortDescription(place.getShortDescription()) | ||
| .latitude(place.getLatitude()) | ||
| .longitude(place.getLongitude()) | ||
| .createdAt(place.getCreatedAt()) | ||
| .updatedAt(place.getUpdatedAt()) | ||
| .placeImageUrl(params.placeImageUrls()) | ||
| .categoryName(params.categoryName()) | ||
| .magazineTitle(params.magazineTitle()) | ||
| .instagramLink(place.getInstagramLink()) | ||
| .naverLink(place.getNaverplaceLink()) | ||
| .iconUrl(params.iconUrl()) | ||
| .placeImageId(place.getPlaceImages().stream().map(PlaceImage::getId).toList()) | ||
| .build(); | ||
| } | ||
| } |
| category.getName(), | ||
| magazine.getTitle(), | ||
| magazine.getIconUrl()) | ||
| ); |
There was a problem hiding this comment.
파라미터 많아서 싫다고 하셨는데 이런 방식이면 파라미터 똑같이 5개 아닌가요?
뭔가 괜히 new PlaceSearchResponseParams만 추가된 느낌인데 어떠신가요
There was a problem hiding this comment.
아뇨 다시 바꾸기보단 PlaceSearchResponseParams 조립을 따로 서비스에서 진행하고 from 메소드에는 조립된 객체만 넣는 식으로 하면 가독성이 훨씬 좋을 듯 해요
new PlaceSearchResponseParams(필요한 필드들..);
return PlaceSearchResponse.from(params);
저도 서비스 전용 dto를 만드는 것을 선호해서 좋은 방법이라 생각합니다. 본인 의견 밀고 나가세요!
There was a problem hiding this comment.
아하 그런 의미였군요
근데 이미 바꿨어요 푸하하
| String magazineTitle = (placeMagazine != null) ? | ||
| placeMagazine.getMagazine().getTitle() : "매거진 없음"; | ||
| String magazineTitle = (placeMagazine != null) ? placeMagazine.getMagazine().getTitle() : "매거진 없음"; | ||
|
|
There was a problem hiding this comment.
null값 내려주는 것보다 String으로 "매거진 없음" 주는 것이 클라이언트에서 더 처리하기 편할까요?
그리고 매거진 정보 응답에 추가하는 부분에서 제가 dto에 MagazineInfo 추가해서 주변 장소 탐색에 사용하고 있는데,
해당 dto 사용하는 건 어때요
There was a problem hiding this comment.
오호 그러네요 내려줄 거면 Null값을 반환하는 게 맞는 것 같습니다.
근데 하나 의문인 게 현재 우리 서비스는 place 객체의 카테고리와 매거진 정보가 반드시 유효한 값(null X)이어야 하는 구조 아닌가 하는 겁니다. 맞다면 아예 예외를 던져버리는 게 맞는 게 아닌가 하는 생각이 드네요.
There was a problem hiding this comment.
오 MagazineInfo 있는지 지금 알았어요 완전 굿이다
- CategoryCreateRequest, CategoryUpdateRequest를 삭제하고 CategoryTypeRequest로 통일 - PlaceCreateRequest dto 내 모든 필드가 not null이도록 커스텀 애노테이션 구현 - NPE 방지 위한 예외처리 코드 추가
f848fe5

#130