Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Wonbn committed Jan 2, 2024
2 parents 7b5af00 + 1174c1b commit 95bc6d5
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public record TourDetailResponse(
@Schema(defaultValue = "1")
Long id,

@Schema(defaultValue = "카테고리 Id")
Long contentTypeId,

@Schema(defaultValue = "여행지 이름")
String title,

Expand Down Expand Up @@ -38,6 +41,7 @@ public TourDetailResponse(
) {
this(
tourItem.getId(),
tourItem.getContentTypeId(),
tourItem.getTitle(),
liked,
fullAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ public record TourSimpleResponse(
@Schema(defaultValue = "1")
Long id,

@Schema(defaultValue = "카테고리 Id")
Long contentTypeId,

@Schema(defaultValue = "여행지 이름")
String title,

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/tenten/tentenbe/domain/tour/model/TourItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class TourItem {
private String tel; // 전화번호
private String longitude; // x좌표
private String latitude; // y좌표
private Long reviewTotalCount; // 리뷰 총 개수
private Long likedTotalCount; // 좋아요 총 개수

@OneToMany(mappedBy = "tourItem", fetch = LAZY, cascade = REMOVE)
private final List<Review> reviews = new ArrayList<>();
Expand All @@ -54,4 +56,12 @@ public class TourItem {

@OneToMany(mappedBy = "tourItem", fetch = LAZY, cascade = REMOVE)
private final List<TripLikedItem> tripLikedItems = new ArrayList<>();

public void increaseLikedCount() {
this.likedTotalCount++;
}

public void decreaseLikedCount() {
this.likedTotalCount--;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public interface TourItemRepository extends JpaRepository<TourItem, Long>, JpaSp
List<TourItem> findByAreaCode(Long areaCode);
@Query("SELECT NEW org.tenten.tentenbe.domain.tour.dto.response.TourSimpleResponse(" +
"ti.id, " +
"ti.contentTypeId, " +
"ti.title, " +
"CAST(COALESCE(AVG(r.rating), 0) AS DOUBLE), " +
"CAST(COALESCE(COUNT(DISTINCT r.id), 0) AS LONG), " +
Expand All @@ -30,6 +31,7 @@ public interface TourItemRepository extends JpaRepository<TourItem, Long>, JpaSp
Page<TourSimpleResponse> findPopularTourItems(@Param("memberId") Long memberId, Pageable pageable);
@Query("SELECT NEW org.tenten.tentenbe.domain.tour.dto.response.TourSimpleResponse(" +
"ti.id, " +
"ti.contentTypeId, " +
"ti.title, " +
"CAST(COALESCE(AVG(r.rating), 0) AS DOUBLE), " +
"CAST(COALESCE(COUNT(DISTINCT r.id), 0) AS LONG), " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ private List<TourSimpleResponse> getTourSimpleResponses(Member member, List<Tour
return tourItems.stream()
.map(tourItem -> new TourSimpleResponse(
tourItem.getId(),
tourItem.getContentTypeId(),
tourItem.getTitle(),
tourItem.getReviews().stream()
.mapToDouble(Review::getRating)
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/data/TourItem.sql

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/main/resources/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ create table TourItem
smallThumbnailUrl varchar(255) null,
tel varchar(255) null,
title varchar(255) null,
zipcode varchar(255) null
zipcode varchar(255) null,
reviewTotalCount bigint null,
likedTotalCount bigint null
);

create table LikedItem
Expand Down

0 comments on commit 95bc6d5

Please sign in to comment.