auto-complete scheduled appointments
This commit is contained in:
@@ -48,7 +48,7 @@ public interface AppointmentRepository extends JpaRepository<Appointment, Long>
|
|||||||
@Query("SELECT a FROM Appointment a JOIN FETCH a.service WHERE a.employee.id IN :employeeIds AND a.appointmentDate = :date AND LOWER(a.appointmentStatus) NOT IN ('cancelled', 'missed')")
|
@Query("SELECT a FROM Appointment a JOIN FETCH a.service WHERE a.employee.id IN :employeeIds AND a.appointmentDate = :date AND LOWER(a.appointmentStatus) NOT IN ('cancelled', 'missed')")
|
||||||
List<Appointment> findByEmployeeIdInAndAppointmentDate(@Param("employeeIds") List<Long> employeeIds, @Param("date") LocalDate date);
|
List<Appointment> findByEmployeeIdInAndAppointmentDate(@Param("employeeIds") List<Long> employeeIds, @Param("date") LocalDate date);
|
||||||
|
|
||||||
@Query("SELECT a FROM Appointment a WHERE (a.appointmentDate < :currentDate OR (a.appointmentDate = :currentDate AND a.appointmentTime < :currentTime)) AND LOWER(a.appointmentStatus) = 'booked'")
|
@Query("SELECT a FROM Appointment a WHERE (a.appointmentDate < :currentDate OR (a.appointmentDate = :currentDate AND a.appointmentTime < :currentTime)) AND LOWER(a.appointmentStatus) IN ('booked', 'scheduled')")
|
||||||
List<Appointment> findPastBookedAppointments(@Param("currentDate") LocalDate currentDate, @Param("currentTime") LocalTime currentTime);
|
List<Appointment> findPastBookedAppointments(@Param("currentDate") LocalDate currentDate, @Param("currentTime") LocalTime currentTime);
|
||||||
|
|
||||||
List<Appointment> findByPet_Id(Long petId);
|
List<Appointment> findByPet_Id(Long petId);
|
||||||
|
|||||||
@@ -279,8 +279,12 @@ public class AppointmentService {
|
|||||||
|
|
||||||
LocalDate tomorrow = currentDate.plusDays(1);
|
LocalDate tomorrow = currentDate.plusDays(1);
|
||||||
|
|
||||||
List<Appointment> tomorrowAppointments = appointmentRepository
|
List<Appointment> tomorrowBooked = appointmentRepository
|
||||||
.findByAppointmentDateAndAppointmentStatusIgnoreCase(tomorrow, "Booked");
|
.findByAppointmentDateAndAppointmentStatusIgnoreCase(tomorrow, "Booked");
|
||||||
|
List<Appointment> tomorrowScheduled = appointmentRepository
|
||||||
|
.findByAppointmentDateAndAppointmentStatusIgnoreCase(tomorrow, "Scheduled");
|
||||||
|
List<Appointment> tomorrowAppointments = new java.util.ArrayList<>(tomorrowBooked);
|
||||||
|
tomorrowAppointments.addAll(tomorrowScheduled);
|
||||||
for (Appointment appointment : tomorrowAppointments) {
|
for (Appointment appointment : tomorrowAppointments) {
|
||||||
eventPublisher.publishEvent(new AppointmentReminderEvent(appointment.getAppointmentId()));
|
eventPublisher.publishEvent(new AppointmentReminderEvent(appointment.getAppointmentId()));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user