Add: GetIntSetting helper

This commit is contained in:
HFO4
2020-01-02 12:44:53 +08:00
parent fffcf1aa1b
commit a75be3a927
11 changed files with 59 additions and 110 deletions

View File

@@ -106,6 +106,7 @@ solid #e9e9e9;"bgcolor="#fff"><tbody><tr style="font-family: 'Helvetica Neue',He
{Name: "doc_preview_timeout", Value: `60`, Type: "timeout"},
{Name: "upload_credential_timeout", Value: `1800`, Type: "timeout"},
{Name: "upload_session_timeout", Value: `86400`, Type: "timeout"},
{Name: "slave_api_timeout", Value: `60`, Type: "timeout"},
{Name: "allowdVisitorDownload", Value: `false`, Type: "share"},
{Name: "login_captcha", Value: `0`, Type: "login"},
{Name: "qq_login", Value: `0`, Type: "login"},

View File

@@ -4,6 +4,7 @@ import (
"github.com/HFO4/cloudreve/pkg/cache"
"github.com/jinzhu/gorm"
"net/url"
"strconv"
)
// Setting 系统设置模型
@@ -72,3 +73,13 @@ func GetSiteURL() *url.URL {
}
return base
}
// GetIntSetting 获取整形设置值如果转换失败则返回默认值defaultVal
// TODO 测试
func GetIntSetting(key string, defaultVal int) int {
res, err := strconv.Atoi(GetSettingByName(key))
if err != nil {
return defaultVal
}
return res
}