-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DTO 추가 및 기존 DTO 수정
- Loading branch information
Showing
5 changed files
with
167 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/main/java/com/mpnp/baechelin/store/dto/StoreCardDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.mpnp.baechelin.store.dto; | ||
|
||
import com.mpnp.baechelin.review.domain.Review; | ||
import com.mpnp.baechelin.review.dto.ReviewImageResponseDto; | ||
import com.mpnp.baechelin.review.dto.ReviewResponseDto; | ||
import com.mpnp.baechelin.store.domain.Store; | ||
import com.mpnp.baechelin.user.domain.User; | ||
import lombok.*; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PACKAGE) | ||
@Getter | ||
@Setter | ||
@Builder | ||
@Slf4j | ||
public class StoreCardDto implements Comparable<StoreCardDto> { | ||
private int storeId; | ||
private String category; | ||
private String name; | ||
private BigDecimal latitude; | ||
private BigDecimal longitude; | ||
private String address; | ||
private String elevator; | ||
private String toilet; | ||
private String parking; | ||
private String phoneNumber; | ||
private String heightDifferent; | ||
private String approach; | ||
private List<StoreImgResponseDto> storeImgList; | ||
private boolean bookmark; | ||
|
||
@Builder.Default | ||
private double pointAvg = 0.0; | ||
|
||
@Override | ||
public int compareTo(StoreCardDto sad) { | ||
if (this.pointAvg > sad.pointAvg) { | ||
return 1; | ||
} else if (this.pointAvg < sad.pointAvg) { | ||
return -1; | ||
} | ||
return 0; | ||
} | ||
|
||
|
||
public StoreCardDto(Store store, User user) { | ||
this.storeId = store.getId(); | ||
this.category = store.getCategory(); | ||
this.name = store.getName(); | ||
this.latitude = store.getLatitude(); | ||
this.longitude = store.getLongitude(); | ||
this.address = store.getAddress(); | ||
this.elevator = store.getElevator(); | ||
this.toilet = store.getToilet(); | ||
this.parking = store.getParking(); | ||
this.phoneNumber = store.getPhoneNumber(); | ||
this.heightDifferent = store.getHeightDifferent(); | ||
this.approach = store.getApproach(); | ||
this.storeImgList = store.getStoreImageList().parallelStream().map(StoreImgResponseDto::new).collect(Collectors.toList()); | ||
this.pointAvg =Double.parseDouble(String.format(store.getReviewList().stream() | ||
.collect(Collectors.averagingDouble(Review::getPoint)).toString(), 0.1f)); | ||
this.bookmark = true; | ||
} | ||
} |
5 changes: 4 additions & 1 deletion
5
src/main/java/com/mpnp/baechelin/store/dto/StoreImgResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters