Skip to content

Commit

Permalink
#18 [Refactor] - DTO 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
JSoi committed Jul 30, 2022
1 parent 0e10a20 commit c0bbad0
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ public LocationInfoDto.LocationResponse convertGeoAndStoreNameToKeyword(String l
* @return 업장명 대신에 주소를 입력해 해당 건물에 있는 업장을 배리어 프리 시설로 등록한다
*/

// TODO 페이징 까지 완료하기 - 여러 건이 필요
@Override
public List<LocationInfoDto.LocationResponse> convertGeoAndAddressToKeyword(String lat, String lng, String address) {
List<LocationInfoDto.LocationResponse> resultList = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ public LocationInfoDto.LocationResponse convertGeoAndStoreNameToKeyword(String l
* @return 업장명 대신에 주소를 입력해 해당 건물에 있는 업장을 배리어 프리 시설로 등록한다
*/

// TODO 페이징 까지 완료하기 - 여러 건이 필요
@Override
public List<LocationInfoDto.LocationResponse> convertGeoAndAddressToKeyword(String lat, String lng, String address) {
List<LocationInfoDto.LocationResponse> resultList = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ public void processForm(PublicApiV2Form formResult) {
private void mapApiToStoreWithPaging(PublicApiV2Form.ServList servList) {
// 태그 String을 분리 & 매핑해 리스트에 저장
List<String> barrierTagList = tagStrToList(servList.getWfcltId());

// TODO 태그가 비어있다면 어떻게 해야 할 지 ? -> 저장 혹은 버리기 (현재 버리기로 구현)
if (barrierTagList.isEmpty()) return;

/*
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public ResponseEntity<?> reviewDelete(@AuthenticationPrincipal User user,
return new ResponseEntity<>(HttpStatus.OK);
}

// TODO - 최근 등록한 리뷰 보여주기 - 로그인 불필요
// 반경 넓히기
@GetMapping("/recent-review")
public List<ReviewMainResponseDto> recentReview(@RequestParam(required = false) BigDecimal lat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public List<Review> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
28 changes: 1 addition & 27 deletions src/main/java/com/mpnp/baechelin/store/service/StoreService.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,39 +128,13 @@ public StorePagedResponseDto getStoreInRangeHighBookmark(BigDecimal lat, BigDeci
private StorePagedResponseDto getStoreCardPagedResponseDto(User targetUser, Page<Store> resultStoreList) {
List<StoreCardResponseDto> 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<StoreCardResponseDto> getStoreCardResponseDtos(User targetUser, List<Store> resultStoreList) {
List<StoreCardResponseDto> 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;
}

/**
* 업장 상세 조회
*
Expand Down

0 comments on commit c0bbad0

Please sign in to comment.