Skip to content

Commit

Permalink
[#33] fix: 예약리스트 조회시 countQuery 를 직접 정의하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
naneun authored and CMSSKKK committed Jun 1, 2022
1 parent b216c59 commit 00db98d
Show file tree
Hide file tree
Showing 16 changed files with 13 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.team14.cherrybnb.auth.domain;

import com.team14.cherrybnb.room.domain.Room;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.List;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Member {

Expand All @@ -29,5 +28,4 @@ public class Member {
private String oauthRefreshToken;

private String resourceServer;

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
@EnableJpaAuditing
public class SpringDataJpaConfig {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ private Set<String> getProduceContentTypes() {
produces.add("application/json;charset=UTF-8");
return produces;
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.team14.cherrybnb.common.domain;


import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.ToString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;
import org.locationtech.jts.util.GeometricShapeFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

public class GeometryUtils {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ public class DummyDataService {

private final RoomRepository roomRepository;


public DummyDataService(RoomRepository roomRepository) {
this.roomRepository = roomRepository;
}


private void requestDummyData() throws JsonProcessingException, org.locationtech.jts.io.ParseException {

String url = "http://openapi.seoul.go.kr:8088/454b52746e79687331303668466a544a/json/LOCALDATA_031101/1/1000/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,4 @@ public ReservationDetailResponse showReservationDetail(Long reservationId) {

return new ReservationDetailResponse(reservation);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,4 @@ public Reservation(LocalDateTime checkIn, LocalDateTime checkOut,
public void cancel() {
this.state = ReservationState.CANCEL;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,20 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface ReservationRepository extends JpaRepository<Reservation, Long> {

/**
* 로그인한 회원의 예약 리스트 조회하기 (ReservationState: 예약 완료)
*/
@Query("select r from Reservation r join fetch r.member" +
" join fetch r.room.roomImages join fetch r.room.address" +
" where r.member = :member")
Page<Reservation> findByMember(Pageable pageable, @Param("member")Member member);

/**
* 예약 취소하기
*/

/**
* 예약 상세 정보 보기
*/
@Query("select r from Reservation r join fetch r.room where r.id = :id")
Reservation findReservationDetailById(@Param("id") Long id);
@Query(value = "select distinct r from Reservation r" +
" join fetch r.member m" +
" join fetch r.room ro" +
" join fetch ro.roomImages" +
" join fetch ro.address" +
" where r.member = :member",
countQuery = "select count(r) from Reservation r where r.member = :member")
Page<Reservation> findByMember(Pageable pageable, @Param("member") Member member);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ public Reservation toEntity(Member member, Room room) {
return new Reservation(this.checkIn, this.checkOut, this.guestCount,
this.totalPrice, ReservationState.COMPLETE, room, member);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
@RequestMapping("/reservations")
public class ReservationController {


//예약하기
//예약취소
//예약 상세 조회
Expand Down Expand Up @@ -65,7 +64,4 @@ public ResponseEntity<ReservationDetailResponse> getReservationDetail(@PathVaria
public ResponseEntity<List<ReservationCardResponse>> getReservations() {
return null;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.team14.cherrybnb.auth.domain.Member;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.team14.cherrybnb.auth.domain.Member;
import com.team14.cherrybnb.common.domain.Address;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

Expand Down Expand Up @@ -38,7 +37,7 @@ public class Room {
@JoinColumn(name = "member_id")
private Member member;

@OneToMany(mappedBy = "room")
@OneToMany(mappedBy = "room", fetch = FetchType.LAZY)
private List<RoomImage> roomImages;

public Room(String name, RoomInfo roomInfo, String description,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class RoomImage {

private String imageUrl;

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "room_id")
private Room room;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@ public class RoomInfo {
private int bedCount;

private int restroomCount;


}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
public class ReviewSummary {

private final Long reviewCount;
private final Double averageRating;


private final Double averageRating;
}

0 comments on commit 00db98d

Please sign in to comment.