feat: add AutoBackupInterval in SystemSetting (#1989)

Add AutoBackupInterval in SystemSetting page
This commit is contained in:
Athurg Gooth
2023-07-19 21:39:21 +08:00
committed by GitHub
parent 7b5c13b712
commit 336b32004d
7 changed files with 58 additions and 10 deletions

View File

@@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"net/http"
"strconv"
"strings"
"github.com/labstack/echo/v4"
@@ -143,18 +142,12 @@ func (upsert UpsertSystemSettingRequest) Validate() error {
return fmt.Errorf(systemSettingUnmarshalError, settingName)
}
case SystemSettingAutoBackupIntervalName:
var value string
var value int
if err := json.Unmarshal([]byte(upsert.Value), &value); err != nil {
return fmt.Errorf(systemSettingUnmarshalError, settingName)
}
if value != "" {
v, err := strconv.Atoi(value)
if err != nil {
return fmt.Errorf(systemSettingUnmarshalError, settingName)
}
if v < 0 {
return fmt.Errorf("backup interval should > 0")
}
if value < 0 {
return fmt.Errorf("must be positive")
}
case SystemSettingTelegramBotTokenName:
if upsert.Value == "" {