优化结构
This commit is contained in:
@@ -7,15 +7,15 @@ import (
|
||||
"kra/internal/biz/system"
|
||||
"time"
|
||||
|
||||
"kra/internal/conf"
|
||||
"kra/internal/config"
|
||||
"kra/internal/security"
|
||||
|
||||
jwt "github.com/golang-jwt/jwt/v5"
|
||||
)
|
||||
|
||||
type runtimeSettings struct{ runtime *conf.Runtime }
|
||||
type runtimeSettings struct{ runtime *config.Store }
|
||||
|
||||
func NewRuntimeSettings(runtime *conf.Runtime) system.RuntimeSettings {
|
||||
func NewRuntimeSettings(runtime *config.Store) system.RuntimeSettings {
|
||||
return &runtimeSettings{runtime: runtime}
|
||||
}
|
||||
|
||||
@@ -30,18 +30,18 @@ func (s *runtimeSettings) RouterPrefix() string {
|
||||
func (s *runtimeSettings) JWTSettings() system.JWTSettings {
|
||||
value := system.JWTSettings{Issuer: "kra", Expires: 7 * 24 * time.Hour, Buffer: 24 * time.Hour}
|
||||
config := s.runtime.Admin()
|
||||
if config == nil || config.Jwt == nil {
|
||||
if config == nil || config.JWT == nil {
|
||||
return value
|
||||
}
|
||||
value.SigningKey = config.Jwt.SigningKey
|
||||
if config.Jwt.Issuer != "" {
|
||||
value.Issuer = config.Jwt.Issuer
|
||||
value.SigningKey = config.JWT.SigningKey
|
||||
if config.JWT.Issuer != "" {
|
||||
value.Issuer = config.JWT.Issuer
|
||||
}
|
||||
if config.Jwt.ExpiresTime != nil {
|
||||
value.Expires = config.Jwt.ExpiresTime.AsDuration()
|
||||
if config.JWT.ExpiresTime > 0 {
|
||||
value.Expires = config.JWT.ExpiresTime
|
||||
}
|
||||
if config.Jwt.BufferTime != nil {
|
||||
value.Buffer = config.Jwt.BufferTime.AsDuration()
|
||||
if config.JWT.BufferTime > 0 {
|
||||
value.Buffer = config.JWT.BufferTime
|
||||
}
|
||||
return value
|
||||
}
|
||||
@@ -53,16 +53,16 @@ func (s *runtimeSettings) CaptchaSettings() system.CaptchaSettings {
|
||||
return value
|
||||
}
|
||||
if config.Captcha.KeyLong > 0 {
|
||||
value.KeyLong = int(config.Captcha.KeyLong)
|
||||
value.KeyLong = config.Captcha.KeyLong
|
||||
}
|
||||
if config.Captcha.ImgWidth > 0 {
|
||||
value.ImageWidth = int(config.Captcha.ImgWidth)
|
||||
value.ImageWidth = config.Captcha.ImgWidth
|
||||
}
|
||||
if config.Captcha.ImgHeight > 0 {
|
||||
value.ImageHeight = int(config.Captcha.ImgHeight)
|
||||
value.ImageHeight = config.Captcha.ImgHeight
|
||||
}
|
||||
if config.Captcha.StoreExpiration != nil {
|
||||
value.StoreExpiration = config.Captcha.StoreExpiration.AsDuration()
|
||||
if config.Captcha.StoreExpiration > 0 {
|
||||
value.StoreExpiration = config.Captcha.StoreExpiration
|
||||
}
|
||||
return value
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func (s *runtimeSettings) MediaSettings() system.MediaSettings {
|
||||
if config == nil || config.Media == nil {
|
||||
return system.MediaSettings{}
|
||||
}
|
||||
return system.MediaSettings{SessionTTL: int(config.Media.SessionTtl), MaxFileSize: config.Media.MaxFileSize, ChunkDir: config.Media.ChunkDir}
|
||||
return system.MediaSettings{SessionTTL: config.Media.SessionTTL, MaxFileSize: config.Media.MaxFileSize, ChunkDir: config.Media.ChunkDir}
|
||||
}
|
||||
|
||||
func (s *runtimeSettings) UseMultipoint() bool {
|
||||
|
||||
Reference in New Issue
Block a user