|
@@ -24,9 +24,11 @@ import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Sort;
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
+import org.springframework.scheduling.TaskScheduler;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.transaction.Transactional;
|
|
import javax.transaction.Transactional;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
@@ -44,6 +46,11 @@ public class CollectionService {
|
|
|
private UserRepo userRepo;
|
|
private UserRepo userRepo;
|
|
|
private AssetService assetService;
|
|
private AssetService assetService;
|
|
|
private RedisTemplate<String, Object> redisTemplate;
|
|
private RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
+ private TaskScheduler taskScheduler;
|
|
|
|
|
+
|
|
|
|
|
+ @PostConstruct
|
|
|
|
|
+ public void init() {
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
@CacheEvict(value = "collection", allEntries = true)
|
|
@CacheEvict(value = "collection", allEntries = true)
|
|
|
public void clearCache() {
|
|
public void clearCache() {
|
|
@@ -209,11 +216,11 @@ public class CollectionService {
|
|
|
.build());
|
|
.build());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Scheduled(fixedRate = 60000)
|
|
|
|
|
|
|
+ @Scheduled(fixedRate = 10000)
|
|
|
public void scheduleOnShelf() {
|
|
public void scheduleOnShelf() {
|
|
|
List<Collection> collections = collectionRepo.findByScheduleSaleTrueAndOnShelfFalseAndStartTimeBeforeAndDelFalse(LocalDateTime.now());
|
|
List<Collection> collections = collectionRepo.findByScheduleSaleTrueAndOnShelfFalseAndStartTimeBeforeAndDelFalse(LocalDateTime.now());
|
|
|
for (Collection collection : collections) {
|
|
for (Collection collection : collections) {
|
|
|
- collectionRepo.setOnShelf(collection.getId(), true);
|
|
|
|
|
|
|
+ collectionRepo.scheduleOnShelf(collection.getId(), true);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|