-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…fo_search feat: [40] 숙소 예약 내역 상세 조회
- Loading branch information
Showing
6 changed files
with
86 additions
and
2 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
Empty file.
26 changes: 26 additions & 0 deletions
26
backend/src/main/java/team15/airbnb/reservation/infrastructure/ReservationRepository.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,26 @@ | ||
package team15.airbnb.reservation.infrastructure; | ||
|
||
import java.util.List; | ||
import javax.persistence.EntityManager; | ||
import javax.persistence.PersistenceContext; | ||
import org.springframework.stereotype.Repository; | ||
import team15.airbnb.reservation.presentation.dto.ReservationDto; | ||
|
||
@Repository | ||
public class ReservationRepository { | ||
|
||
@PersistenceContext | ||
private EntityManager em; | ||
|
||
public List<ReservationDto> findByUserId(Long userId) { | ||
return em.createQuery( | ||
"select new team15.airbnb.reservation.presentation.dto.ReservationDto(" | ||
+ "r.id, r.checkInDate, r.checkOutDate, a.address.city, a.address.firstAddress, a.accommodationName, a.mainImage) " | ||
+ "from Reservation r " | ||
+ "join r.accommodation a " | ||
+ "where r.user.id = :userId and r.isDeleted = false ", ReservationDto.class) | ||
.setParameter("userId", userId) | ||
.getResultList(); | ||
} | ||
|
||
} |
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
25 changes: 25 additions & 0 deletions
25
backend/src/main/java/team15/airbnb/reservation/presentation/dto/ReservationDto.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,25 @@ | ||
package team15.airbnb.reservation.presentation.dto; | ||
|
||
import java.time.LocalDate; | ||
import lombok.Getter; | ||
import team15.airbnb.accommodation.domain.City; | ||
|
||
@Getter | ||
public class ReservationDto { | ||
|
||
private Long reservationId; | ||
private LocalDate checkInDate; | ||
private LocalDate checkOutDate; | ||
private String location; | ||
private String accommodationName; | ||
private String mainImage; | ||
|
||
public ReservationDto(Long reservationId, LocalDate checkInDate, LocalDate checkOutDate, City city, String firstAddress, String accommodationName, String mainImage) { | ||
this.reservationId = reservationId; | ||
this.checkInDate = checkInDate; | ||
this.checkOutDate = checkOutDate; | ||
this.location = city.getName() + firstAddress; | ||
this.accommodationName = accommodationName; | ||
this.mainImage = mainImage; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
backend/src/main/java/team15/airbnb/reservation/presentation/dto/ReservationResponse.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,15 @@ | ||
package team15.airbnb.reservation.presentation.dto; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class ReservationResponse { | ||
|
||
private List<ReservationDto> reservations = new ArrayList<>(); | ||
|
||
public ReservationResponse(List<ReservationDto> reservations) { | ||
this.reservations = reservations; | ||
} | ||
} |