Last change
on this file was 743de55, checked in by macagaso <gasoskamarija@…>, 6 weeks ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
974 bytes
|
Line | |
---|
1 | package finki.it.terapijamkbackend.spring.services;
|
---|
2 |
|
---|
3 | import finki.it.terapijamkbackend.spring.repositories.AppointmentRepository;
|
---|
4 | import finki.it.terapijamkbackend.spring.repositories.RequestRepository;
|
---|
5 | import jakarta.transaction.Transactional;
|
---|
6 | import org.springframework.beans.factory.annotation.Autowired;
|
---|
7 | import org.springframework.scheduling.annotation.Scheduled;
|
---|
8 | import org.springframework.stereotype.Service;
|
---|
9 |
|
---|
10 | import java.time.LocalDateTime;
|
---|
11 |
|
---|
12 | @Service
|
---|
13 | public class CleanupService {
|
---|
14 | @Autowired
|
---|
15 | private AppointmentRepository appointmentRepository;
|
---|
16 | @Autowired
|
---|
17 | private RequestRepository requestRepository;
|
---|
18 |
|
---|
19 | @Scheduled(cron = "0 20 14 * * ?")
|
---|
20 | @Transactional
|
---|
21 | public void cleanupOldAppointmentsAndRequests() {
|
---|
22 | LocalDateTime now = LocalDateTime.now();
|
---|
23 | appointmentRepository.deleteByAppointmentDateBefore(now);
|
---|
24 | requestRepository.deleteByTermBefore(now.minusDays(1));
|
---|
25 | System.out.println("Cleanup completed!");
|
---|
26 | }
|
---|
27 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.