161 lines
3.5 KiB
Java
161 lines
3.5 KiB
Java
package com.zeodao.reminder.config;
|
|
|
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* 多群任务提醒配置类
|
|
*
|
|
* @author Zeodao
|
|
* @version 2.0.0
|
|
*/
|
|
@Configuration
|
|
@ConfigurationProperties(prefix = "task.reminder")
|
|
public class TaskReminderConfig {
|
|
|
|
private Global global = new Global();
|
|
private List<Group> groups = new ArrayList<>();
|
|
|
|
public Global getGlobal() {
|
|
return global;
|
|
}
|
|
|
|
public void setGlobal(Global global) {
|
|
this.global = global;
|
|
}
|
|
|
|
public List<Group> getGroups() {
|
|
return groups;
|
|
}
|
|
|
|
public void setGroups(List<Group> groups) {
|
|
this.groups = groups;
|
|
}
|
|
|
|
/**
|
|
* 根据群组ID获取群组配置
|
|
*/
|
|
public Group getGroupById(String groupId) {
|
|
return groups.stream()
|
|
.filter(group -> group.getId().equals(groupId))
|
|
.findFirst()
|
|
.orElse(null);
|
|
}
|
|
|
|
/**
|
|
* 获取所有启用的群组
|
|
*/
|
|
public List<Group> getEnabledGroups() {
|
|
return groups.stream()
|
|
.filter(Group::isEnabled)
|
|
.toList();
|
|
}
|
|
|
|
public static class Global {
|
|
private int timeout = 5000;
|
|
|
|
public int getTimeout() {
|
|
return timeout;
|
|
}
|
|
|
|
public void setTimeout(int timeout) {
|
|
this.timeout = timeout;
|
|
}
|
|
}
|
|
|
|
public static class Group {
|
|
private String id;
|
|
private String name;
|
|
private Webhook webhook = new Webhook();
|
|
private String taskSystem;
|
|
private Map<String, Schedule> schedules = new HashMap<>();
|
|
private boolean enabled = true;
|
|
|
|
public String getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(String id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public Webhook getWebhook() {
|
|
return webhook;
|
|
}
|
|
|
|
public void setWebhook(Webhook webhook) {
|
|
this.webhook = webhook;
|
|
}
|
|
|
|
public String getTaskSystem() {
|
|
return taskSystem;
|
|
}
|
|
|
|
public void setTaskSystem(String taskSystem) {
|
|
this.taskSystem = taskSystem;
|
|
}
|
|
|
|
public Map<String, Schedule> getSchedules() {
|
|
return schedules;
|
|
}
|
|
|
|
public void setSchedules(Map<String, Schedule> schedules) {
|
|
this.schedules = schedules;
|
|
}
|
|
|
|
public boolean isEnabled() {
|
|
return enabled;
|
|
}
|
|
|
|
public void setEnabled(boolean enabled) {
|
|
this.enabled = enabled;
|
|
}
|
|
}
|
|
|
|
public static class Webhook {
|
|
private String url;
|
|
|
|
public String getUrl() {
|
|
return url;
|
|
}
|
|
|
|
public void setUrl(String url) {
|
|
this.url = url;
|
|
}
|
|
}
|
|
|
|
public static class Schedule {
|
|
private String time;
|
|
private String message;
|
|
|
|
public String getTime() {
|
|
return time;
|
|
}
|
|
|
|
public void setTime(String time) {
|
|
this.time = time;
|
|
}
|
|
|
|
public String getMessage() {
|
|
return message;
|
|
}
|
|
|
|
public void setMessage(String message) {
|
|
this.message = message;
|
|
}
|
|
}
|
|
}
|