init
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package com.caliverse.admin.scheduler;
|
||||
|
||||
import com.caliverse.admin.domain.entity.InGame;
|
||||
import com.caliverse.admin.domain.entity.Mail;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
@Service
|
||||
public class SchedulerService {
|
||||
|
||||
private final Map<String, ScheduledFuture<?>> scheduledTasks = new ConcurrentHashMap<>();
|
||||
|
||||
private final Map<Long, Mail> mailTask = new ConcurrentHashMap<>();
|
||||
private final Map<Long, InGame> noticeTask = new ConcurrentHashMap<>();
|
||||
|
||||
public boolean isTaskExist(String key){
|
||||
return scheduledTasks.containsKey(key);
|
||||
}
|
||||
|
||||
public void addTask(String key, ScheduledFuture<?> schdule){
|
||||
scheduledTasks.put(key, schdule);
|
||||
}
|
||||
|
||||
public void closeTask(String key) {
|
||||
ScheduledFuture<?> scheduledFuture = scheduledTasks.get(key);
|
||||
if (scheduledFuture != null) {
|
||||
scheduledFuture.cancel(true);
|
||||
scheduledTasks.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
// public boolean isTaskExist(String type, Long id) {
|
||||
// switch (type) {
|
||||
// case "mail" -> {
|
||||
// return mailTask.containsKey(id);
|
||||
// }
|
||||
// case "notice" -> {
|
||||
// return noticeTask.containsKey(id);
|
||||
// }
|
||||
// default -> {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void createTask(Mail mail) {
|
||||
// mailTask.put(mail.getId(), mail);
|
||||
// }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user