我有一个roomentity,它有一个可用性列表,可用性包含一周、一天和一个会话(开始时间和结束时间)
例如,2012年1月11日至2012年1月17日这一周的房间,星期四为一天,会议时间为13:30至15:00
我想获得给定日期和时间的所有可用房间(例如日期12/01/2012和时间14:30)
@Entity
public class RoomEntity {
@Id
private String roomId;
@OneToMany(mappedBy = "room", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<AvailabilityEntity> availabilities;
}
@Entity
public class AvailabilityEntity {
@Id
@GeneratedValue(generator = "availability-uuid")
@GenericGenerator(name = "availability-uuid", strategy = "uuid2")
private String availabilityId;
@ManyToOne(optional = true)
@JoinColumn(name = "fk_week")
private WeekEntity week;
private String day;
@ManyToOne(optional = true)
@JoinColumn(name = "fk_seance")
private SessionEntity session;
@JsonIgnore
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "fk_room")
private RoomEntity room;
}
@Entity
public class WeekEntity {
@Id
private String weekId;
private Date startDate;
private Date endDate;
}
@Entity
public class SessionEntity {
@Id
private String seanceId;
private String startHour;
private String endHour;
}
public interface RoomRepository extends JpaRepository<RoomEntity, String> {
@Query("...")
List<RoomEntity> findAllWithCondition(Date effectDate, String hour);
}
暂无答案!
目前还没有任何答案,快来回答吧!