新增备份监控与定时配置
This commit is contained in:
@@ -3,6 +3,7 @@ package systemconfig
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -24,3 +25,31 @@ func (s *Service) List(ctx context.Context) ([]ConfigDTO, error) {
|
||||
}
|
||||
return s.repo.List(ctx)
|
||||
}
|
||||
|
||||
func (s *Service) BackupSchedule(ctx context.Context) (*BackupScheduleDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
values := map[string]string{}
|
||||
for _, item := range defaultConfigs {
|
||||
if item.Key == "backup.schedule_enabled" || item.Key == "backup.full_hour" || item.Key == "backup.full_minute" || item.Key == "backup.binlog_interval_minutes" {
|
||||
values[item.Key] = item.Value
|
||||
}
|
||||
}
|
||||
for key := range values {
|
||||
value, err := s.repo.FindValue(ctx, key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
values[key] = value
|
||||
}
|
||||
hour, _ := strconv.Atoi(values["backup.full_hour"])
|
||||
minute, _ := strconv.Atoi(values["backup.full_minute"])
|
||||
interval, _ := strconv.Atoi(values["backup.binlog_interval_minutes"])
|
||||
return &BackupScheduleDTO{
|
||||
Enabled: values["backup.schedule_enabled"] == "true",
|
||||
FullHour: hour,
|
||||
FullMinute: minute,
|
||||
BinlogIntervalMinutes: interval,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user