Skip to content

Commit

Permalink
Merge pull request #77 from Journey-Together/feat/#76
Browse files Browse the repository at this point in the history
[#76] feat: 관광지 장애 세부유형 설명 추가 & 리뷰리스트 추가
  • Loading branch information
mmihye authored Jun 12, 2024
2 parents 3b0b825 + cd3c881 commit 8661dc3
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public record PlaceDetailGuestRes(
Integer bookmarkNum,

List<Long> disability,
List<String> subDisability,
List<SubDisability> subDisability,
List<PlaceReviewDto> reviewList
) {
static String cat = "관광지";
public static PlaceDetailGuestRes of(Place place, Integer bookmarkNum, List<Long> disability, List<String> subDisability, List<PlaceReviewDto> reviewList){
public static PlaceDetailGuestRes of(Place place, Integer bookmarkNum, List<Long> disability, List<SubDisability> subDisability, List<PlaceReviewDto> reviewList){
if(place.getCategory().equals("B02"))
cat = "숙소";
else if (place.getCategory().equals("A05"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public record PlaceDetailRes(
Integer bookmarkNum,

List<Long> disability,
List<String> subDisability,
List<SubDisability> subDisability,
List<PlaceReviewDto> reviewList
) {
static String cat = "관광지";
public static PlaceDetailRes of(Place place, Boolean isMark, Integer bookmarkNum, List<Long> disability, List<String> subDisability, List<PlaceReviewDto> reviewList){
public static PlaceDetailRes of(Place place, Boolean isMark, Integer bookmarkNum, List<Long> disability, List<SubDisability> subDisability, List<PlaceReviewDto> reviewList){
if(place.getCategory().equals("B02"))
cat = "숙소";
else if (place.getCategory().equals("A05"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package Journey.Together.domain.place.dto.response;

import Journey.Together.domain.place.entity.PlaceReview;

import java.time.LocalDate;
import java.time.LocalDateTime;

Expand All @@ -11,4 +13,9 @@ public record PlaceReviewDto(
String reviewImg,
Float grade,
LocalDate date) {

public static PlaceReviewDto of(PlaceReview placeReview, String profileImg, String img){
return new PlaceReviewDto(placeReview.getId(), placeReview.getMember().getNickname(), profileImg,
placeReview.getContent(), img, placeReview.getGrade(), placeReview.getDate());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package Journey.Together.domain.place.dto.response;

import Journey.Together.domain.place.entity.DisabilityPlaceCategory;

public record SubDisability(
String subDisabilityName,
String description
) {
public static SubDisability of(DisabilityPlaceCategory disabilityPlaceCategory){
return new SubDisability(disabilityPlaceCategory.getSubCategory().getSubname(), disabilityPlaceCategory.getDescription());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class DisabilityPlaceCategory {
@JoinColumn(name = "subCategory_id")
private DisabilitySubCategory subCategory;

private String description;

@Builder
public DisabilityPlaceCategory(Place place, DisabilitySubCategory subCategory){
this.place=place;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface DisabilityPlaceCategoryRepository extends JpaRepository<Disabil
"WHERE dpc.place.id = :placeId")
List<Long> findDisabilityCategoryIds(@Param("placeId") long placeId);

@Query("SELECT DISTINCT dpc.subCategory.subname FROM DisabilityPlaceCategory dpc " +
@Query("SELECT DISTINCT dpc FROM DisabilityPlaceCategory dpc " +
"WHERE dpc.place.id = :placeId")
List<String> findDisabilitySubCategoryNames(@Param("placeId") long placeId);
List<DisabilityPlaceCategory> findDisabilitySubCategory(@Param("placeId") long placeId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface PlaceReviewRepository extends JpaRepository<PlaceReview,Long> {

PlaceReview findPlaceReviewByPlace(Place place);
List<PlaceReview> findAllByPlaceOrderByCreatedAtDesc(Place place);
PlaceReview findPlaceReviewByMemberAndPlace(Member member, Place place);

Page<PlaceReview> findAllByPlaceOrderByCreatedAtDesc(Place place, Pageable pageable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,23 @@ public PlaceDetailRes getPlaceDetail(Member member, Long placeId){
.anyMatch(placeBookmark -> placeBookmark.getMember().equals(member));

List<Long> disability = disabilityPlaceCategoryRepository.findDisabilityCategoryIds(placeId);
List<String> subDisability = disabilityPlaceCategoryRepository.findDisabilitySubCategoryNames(placeId);
List<SubDisability> subDisability = disabilityPlaceCategoryRepository.findDisabilitySubCategory(placeId).stream().map(SubDisability::of).toList();

return PlaceDetailRes.of(place, isMark, placeBookmarkList.size(), disability, subDisability, null);
List<PlaceReview> placeReviews = placeReviewRepository.findAllByPlaceOrderByCreatedAtDesc(place);
if(placeReviews.size()<0)
return PlaceDetailRes.of(place, isMark, placeBookmarkList.size(), disability, subDisability, null);

List<PlaceReviewDto> reviewList = new ArrayList<>();

placeReviews.forEach(placeReview -> {
List<PlaceReviewImg> placeReviewImgs = placeReviewImgRepository.findAllByPlaceReview(placeReview);
if (placeReviewImgs.size() > 0) {
reviewList.add(PlaceReviewDto.of(placeReview, s3Client.getUrl()+placeReview.getMember().getProfileUuid()+"/profile",placeReviewImgs.get(0).getImgUrl()));
} else
reviewList.add(PlaceReviewDto.of(placeReview,s3Client.getUrl()+placeReview.getMember().getProfileUuid()+"/profile", placeReview.getPlace().getFirstImg()));
});

return PlaceDetailRes.of(place, isMark, placeBookmarkList.size(), disability, subDisability, reviewList);

}

Expand All @@ -88,9 +102,24 @@ public PlaceDetailGuestRes getGeustPlaceDetail(Long placeId){

List<PlaceBookmark> placeBookmarkList = placeBookmarkRepository.findAllByPlace(place);
List<Long> disability = disabilityPlaceCategoryRepository.findDisabilityCategoryIds(placeId);
List<String> subDisability = disabilityPlaceCategoryRepository.findDisabilitySubCategoryNames(placeId);
List<SubDisability> subDisability = disabilityPlaceCategoryRepository.findDisabilitySubCategory(placeId).stream().map(SubDisability::of).toList();

List<PlaceReview> placeReviews = placeReviewRepository.findAllByPlaceOrderByCreatedAtDesc(place);
if(placeReviews.size()<0)
return PlaceDetailGuestRes.of(place, placeBookmarkList.size(), disability, subDisability, null);

List<PlaceReviewDto> reviewList = new ArrayList<>();

placeReviews.forEach(placeReview -> {
List<PlaceReviewImg> placeReviewImgs = placeReviewImgRepository.findAllByPlaceReview(placeReview);
if (placeReviewImgs.size() > 0) {
reviewList.add(PlaceReviewDto.of(placeReview, s3Client.getUrl()+placeReview.getMember().getProfileUuid()+"/profile",placeReviewImgs.get(0).getImgUrl()));
} else
reviewList.add(PlaceReviewDto.of(placeReview,s3Client.getUrl()+placeReview.getMember().getProfileUuid()+"/profile", placeReview.getPlace().getFirstImg()));
});


return PlaceDetailGuestRes.of(place, placeBookmarkList.size(), disability, subDisability, null);
return PlaceDetailGuestRes.of(place, placeBookmarkList.size(), disability, subDisability, reviewList);

}

Expand Down Expand Up @@ -124,7 +153,7 @@ public List<PlaceRes> searchPlaceMap(String category, List<Long> disabilityType,
public void createReview(Member member, List<MultipartFile> images, PlaceReviewReq placeReviewReq, Long placeId){
Place place = getPlace(placeId);

if(placeReviewRepository.findPlaceReviewByPlace(place) != null)
if(placeReviewRepository.findPlaceReviewByMemberAndPlace(member,place) != null)
throw new ApplicationException(ErrorCode.ALREADY_EXIST_EXCEPTION);

PlaceReview placeReview = PlaceReview.builder()
Expand Down

0 comments on commit 8661dc3

Please sign in to comment.