source: src/main/java/edu/gjoko/schedlr/repositories/AppointmentRepository.java@ 950fa0d

Last change on this file since 950fa0d was 950fa0d, checked in by Gjoko Kostadinov <gjoko.kostadinov@…>, 14 months ago

Periodic update

  • Property mode set to 100644
File size: 1.3 KB
Line 
1package edu.gjoko.schedlr.repositories;
2
3import edu.gjoko.schedlr.entity.Appointment;
4import edu.gjoko.schedlr.entity.Business;
5import edu.gjoko.schedlr.entity.Stakeholder;
6import org.springframework.data.jpa.repository.JpaRepository;
7import org.springframework.data.jpa.repository.Query;
8import org.springframework.stereotype.Repository;
9
10import java.time.LocalDateTime;
11import java.util.List;
12
13@Repository
14public interface AppointmentRepository extends JpaRepository<Appointment, Long> {
15
16 List<Appointment> getAppointmentsByBusiness(Business business);
17
18 List<Appointment> getAppointmentsByCustomer(Stakeholder customer);
19
20 List<Appointment> findAppointmentsByBusinessAndStartTimeBetweenOrEndTimeBetween(Business business, LocalDateTime startTime, LocalDateTime endTime, LocalDateTime startTime1, LocalDateTime endTime1);
21
22 @Query(value = "select a from Appointment a " +
23 "where business_id = :businessId " +
24 "and (" +
25 "(start_time between :startDate and :endDate) " +
26 "or (end_time between :startDate and :endDate) " +
27 "or (:startDate <= start_time and end_time >= :endDate)" +
28 ")", nativeQuery = true)
29 List<Appointment> findBlockingAppointments(Long businessId, LocalDateTime startDate, LocalDateTime endDate);
30}
Note: See TracBrowser for help on using the repository browser.