From c0bbad0e365b9a9696b78edacf1ed7d22b2bb7b6 Mon Sep 17 00:00:00 2001 From: JSoi Date: Sun, 31 Jul 2022 00:30:27 +0900 Subject: [PATCH] =?UTF-8?q?#18=20[Refactor]=20-=20DTO=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/LocationServiceRT.java | 1 - .../api/service/LocationServiceWC.java | 1 - .../api/service/PublicApiServiceV2.java | 4 +-- .../review/controller/ReviewController.java | 1 - .../repository/ReviewQueryRepository.java | 1 - .../store/dto/StoreCardResponseDto.java | 3 +- .../baechelin/store/service/StoreService.java | 28 +------------------ 7 files changed, 3 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/mpnp/baechelin/api/service/LocationServiceRT.java b/src/main/java/com/mpnp/baechelin/api/service/LocationServiceRT.java index 4ae132b..48cf1a1 100644 --- a/src/main/java/com/mpnp/baechelin/api/service/LocationServiceRT.java +++ b/src/main/java/com/mpnp/baechelin/api/service/LocationServiceRT.java @@ -160,7 +160,6 @@ public LocationInfoDto.LocationResponse convertGeoAndStoreNameToKeyword(String l * @return 업장명 대신에 주소를 입력해 해당 건물에 있는 업장을 배리어 프리 시설로 등록한다 */ - // TODO 페이징 까지 완료하기 - 여러 건이 필요 @Override public List convertGeoAndAddressToKeyword(String lat, String lng, String address) { List resultList = new ArrayList<>(); diff --git a/src/main/java/com/mpnp/baechelin/api/service/LocationServiceWC.java b/src/main/java/com/mpnp/baechelin/api/service/LocationServiceWC.java index 90971a5..5fdcefe 100644 --- a/src/main/java/com/mpnp/baechelin/api/service/LocationServiceWC.java +++ b/src/main/java/com/mpnp/baechelin/api/service/LocationServiceWC.java @@ -149,7 +149,6 @@ public LocationInfoDto.LocationResponse convertGeoAndStoreNameToKeyword(String l * @return 업장명 대신에 주소를 입력해 해당 건물에 있는 업장을 배리어 프리 시설로 등록한다 */ - // TODO 페이징 까지 완료하기 - 여러 건이 필요 @Override public List convertGeoAndAddressToKeyword(String lat, String lng, String address) { List resultList = new ArrayList<>(); diff --git a/src/main/java/com/mpnp/baechelin/api/service/PublicApiServiceV2.java b/src/main/java/com/mpnp/baechelin/api/service/PublicApiServiceV2.java index adb37cf..c73b6d6 100644 --- a/src/main/java/com/mpnp/baechelin/api/service/PublicApiServiceV2.java +++ b/src/main/java/com/mpnp/baechelin/api/service/PublicApiServiceV2.java @@ -104,8 +104,6 @@ public void processForm(PublicApiV2Form formResult) { private void mapApiToStoreWithPaging(PublicApiV2Form.ServList servList) { // 태그 String을 분리 & 매핑해 리스트에 저장 List barrierTagList = tagStrToList(servList.getWfcltId()); - - // TODO 태그가 비어있다면 어떻게 해야 할 지 ? -> 저장 혹은 버리기 (현재 버리기로 구현) if (barrierTagList.isEmpty()) return; /* @@ -224,7 +222,7 @@ public void start() { String line = null; while (true) { try { - if (!((line = br.readLine()) != null)) break; + if ((line = br.readLine()) == null) break; } catch (IOException e) { return; } diff --git a/src/main/java/com/mpnp/baechelin/review/controller/ReviewController.java b/src/main/java/com/mpnp/baechelin/review/controller/ReviewController.java index 490fa3a..2e29465 100644 --- a/src/main/java/com/mpnp/baechelin/review/controller/ReviewController.java +++ b/src/main/java/com/mpnp/baechelin/review/controller/ReviewController.java @@ -95,7 +95,6 @@ public ResponseEntity reviewDelete(@AuthenticationPrincipal User user, return new ResponseEntity<>(HttpStatus.OK); } - // TODO - 최근 등록한 리뷰 보여주기 - 로그인 불필요 // 반경 넓히기 @GetMapping("/recent-review") public List recentReview(@RequestParam(required = false) BigDecimal lat, diff --git a/src/main/java/com/mpnp/baechelin/review/repository/ReviewQueryRepository.java b/src/main/java/com/mpnp/baechelin/review/repository/ReviewQueryRepository.java index 5d57ad5..efe010f 100644 --- a/src/main/java/com/mpnp/baechelin/review/repository/ReviewQueryRepository.java +++ b/src/main/java/com/mpnp/baechelin/review/repository/ReviewQueryRepository.java @@ -33,7 +33,6 @@ public List findRecentReviews(BigDecimal lat, builder = QuerydslLocation.locationBuilder(location[0], location[1], location[2], location[3]); } // 위도 경도에 해당하는 가게를 찾음 -> 해당 댓글을 다 가져옴 -> 내림차순 정렬 -> limit - // TODO 쿼리문 개선하기 return queryFactory.selectFrom(review) .join(review.storeId, store) .where(builder) diff --git a/src/main/java/com/mpnp/baechelin/store/dto/StoreCardResponseDto.java b/src/main/java/com/mpnp/baechelin/store/dto/StoreCardResponseDto.java index 2287026..a91295d 100644 --- a/src/main/java/com/mpnp/baechelin/store/dto/StoreCardResponseDto.java +++ b/src/main/java/com/mpnp/baechelin/store/dto/StoreCardResponseDto.java @@ -54,8 +54,7 @@ public StoreCardResponseDto(Store store, String isBookMark) { this.storeImgList = new ArrayList<>(); store.getStoreImageList().parallelStream() .forEachOrdered(s -> storeImgList.add(s.getStoreImageUrl())); - double hap = store.getReviewList().stream().map(Review::getPoint).mapToDouble(Double::doubleValue).sum(); - this.pointAvg = store.getReviewList().size() == 0 ? 0 : Double.parseDouble(String.format("%1.1f", (hap / store.getReviewList().size()))); + this.pointAvg = store.getPointAvg(); this.bookmark = isBookMark; } } diff --git a/src/main/java/com/mpnp/baechelin/store/service/StoreService.java b/src/main/java/com/mpnp/baechelin/store/service/StoreService.java index 439f449..44fdc37 100644 --- a/src/main/java/com/mpnp/baechelin/store/service/StoreService.java +++ b/src/main/java/com/mpnp/baechelin/store/service/StoreService.java @@ -128,39 +128,13 @@ public StorePagedResponseDto getStoreInRangeHighBookmark(BigDecimal lat, BigDeci private StorePagedResponseDto getStoreCardPagedResponseDto(User targetUser, Page resultStoreList) { List mappingResult = new ArrayList<>(); for (Store store : resultStoreList) { - boolean isBookmark = bookmarkRepository.existsByStoreIdAndUserId(store, targetUser); + boolean isBookmark = targetUser != null && bookmarkRepository.existsByStoreIdAndUserId(store, targetUser); mappingResult.add(new StoreCardResponseDto(store, isBookmark ? "Y" : "N")); } return new StorePagedResponseDto(resultStoreList, mappingResult); } - /** - * @param targetUser 현재 접근하고 있는 유저 - * @param resultStoreList 업장 리스트 - * @return 접근하고 있는 유저가 보는 업장을 가공(북마크 등)하여 DTO로 리턴 - */ - private List getStoreCardResponseDtos(User targetUser, List resultStoreList) { - List storeCardResponseList = new ArrayList<>(); - if (targetUser == null) { - return resultStoreList.stream() - .map(store -> new StoreCardResponseDto(store, "N")) - .collect(Collectors.toList()); - } else { - for (Store store : resultStoreList) { - String isBookmark = "N"; - for (Bookmark bookmark : store.getBookmarkList()) { - if (bookmark.getStoreId().getId() == store.getId() - && bookmark.getUserId().getSocialId().equals(targetUser.getSocialId())) { - isBookmark = "Y"; - } - storeCardResponseList.add(new StoreCardResponseDto(store, isBookmark)); - } - } - } - return storeCardResponseList; - } - /** * 업장 상세 조회 *