1 | package com.example.villadihovo.repository.reservation;
|
---|
2 |
|
---|
3 | import com.example.villadihovo.dto.ReservationForRoomDto;
|
---|
4 | import com.example.villadihovo.model.reservations.GuestMakeReservationId;
|
---|
5 | import com.example.villadihovo.model.reservations.GuestsMakeReservation;
|
---|
6 | import org.springframework.data.jpa.repository.JpaRepository;
|
---|
7 | import org.springframework.data.jpa.repository.Query;
|
---|
8 | import org.springframework.data.repository.query.Param;
|
---|
9 | import org.springframework.stereotype.Repository;
|
---|
10 |
|
---|
11 | import java.util.List;
|
---|
12 |
|
---|
13 | @Repository
|
---|
14 | public interface GuestMakeReservationRepository extends JpaRepository<GuestsMakeReservation, GuestMakeReservationId> {
|
---|
15 | @Query("SELECT new com.example.villadihovo.dto.ReservationForRoomDto(gmr.reservation_id, r2.room_id, r.start_date , r.end_date, r.number_guests,r.adults,r.children,r2.room_type, r2.price, v.name ,ut.full_name, ut.phone_number)" +
|
---|
16 | " FROM GuestsMakeReservation gmr " +
|
---|
17 | "JOIN UserTable ut ON gmr.user_id = ut.user_id " +
|
---|
18 | "JOIN Reservation r ON gmr.reservation_id = r.reservation_id " +
|
---|
19 | "JOIN Rooms r2 ON r.room_id.room_id = r2.room_id " +
|
---|
20 | "JOIN Villa v ON r.villa_id.villa_id = v.villa_id " +
|
---|
21 | "ORDER BY r.start_date")
|
---|
22 | List<ReservationForRoomDto> findAllRoomReservationsDTO();
|
---|
23 |
|
---|
24 | @Query("SELECT new com.example.villadihovo.dto.ReservationForRoomDto(gmr.reservation_id, r2.room_id, r.start_date , r.end_date, r.number_guests,r.adults,r.children,r2.room_type, r2.price, v.name ,ut.full_name, ut.phone_number)" +
|
---|
25 | " FROM GuestsMakeReservation gmr " +
|
---|
26 | "JOIN UserTable ut ON gmr.user_id = ut.user_id " +
|
---|
27 | "JOIN Reservation r ON gmr.reservation_id = r.reservation_id " +
|
---|
28 | "JOIN Rooms r2 ON r.room_id.room_id = r2.room_id " +
|
---|
29 | "JOIN Villa v ON r.villa_id.villa_id = v.villa_id " +
|
---|
30 | "WHERE r.reservation_id = gmr.reservation_id AND r.reservation_id = :id")
|
---|
31 | ReservationForRoomDto findRoomReservationsDTOById(@Param("id") Integer id);
|
---|
32 | }
|
---|