93 lines
2.9 KiB
Go
93 lines
2.9 KiB
Go
|
|
package service
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
)
|
||
|
|
|
||
|
|
// SystemSettings 系统设置
|
||
|
|
type SystemSettings struct {
|
||
|
|
System SystemInfo `json:"system"`
|
||
|
|
Security SecurityInfo `json:"security"`
|
||
|
|
Features FeaturesInfo `json:"features"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// SystemInfo 系统信息
|
||
|
|
type SystemInfo struct {
|
||
|
|
Name string `json:"name"`
|
||
|
|
Version string `json:"version"`
|
||
|
|
Environment string `json:"environment"`
|
||
|
|
Description string `json:"description"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// SecurityInfo 安全设置
|
||
|
|
type SecurityInfo struct {
|
||
|
|
PasswordMinLength int `json:"password_min_length"`
|
||
|
|
PasswordRequireUppercase bool `json:"password_require_uppercase"`
|
||
|
|
PasswordRequireLowercase bool `json:"password_require_lowercase"`
|
||
|
|
PasswordRequireNumbers bool `json:"password_require_numbers"`
|
||
|
|
PasswordRequireSymbols bool `json:"password_require_symbols"`
|
||
|
|
PasswordHistory int `json:"password_history"`
|
||
|
|
TOTPEnabled bool `json:"totp_enabled"`
|
||
|
|
LoginFailLock bool `json:"login_fail_lock"`
|
||
|
|
LoginFailThreshold int `json:"login_fail_threshold"`
|
||
|
|
LoginFailDuration int `json:"login_fail_duration"` // 分钟
|
||
|
|
SessionTimeout int `json:"session_timeout"` // 秒
|
||
|
|
DeviceTrustDuration int `json:"device_trust_duration"` // 秒
|
||
|
|
}
|
||
|
|
|
||
|
|
// FeaturesInfo 功能开关
|
||
|
|
type FeaturesInfo struct {
|
||
|
|
EmailVerification bool `json:"email_verification"`
|
||
|
|
PhoneVerification bool `json:"phone_verification"`
|
||
|
|
OAuthProviders []string `json:"oauth_providers"`
|
||
|
|
SSOEnabled bool `json:"sso_enabled"`
|
||
|
|
OperationLogEnabled bool `json:"operation_log_enabled"`
|
||
|
|
LoginLogEnabled bool `json:"login_log_enabled"`
|
||
|
|
DataExportEnabled bool `json:"data_export_enabled"`
|
||
|
|
DataImportEnabled bool `json:"data_import_enabled"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// SettingsService 系统设置服务
|
||
|
|
type SettingsService struct{}
|
||
|
|
|
||
|
|
// NewSettingsService 创建系统设置服务
|
||
|
|
func NewSettingsService() *SettingsService {
|
||
|
|
return &SettingsService{}
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetSettings 获取系统设置
|
||
|
|
func (s *SettingsService) GetSettings(ctx context.Context) (*SystemSettings, error) {
|
||
|
|
return &SystemSettings{
|
||
|
|
System: SystemInfo{
|
||
|
|
Name: "用户管理系统",
|
||
|
|
Version: "1.0.0",
|
||
|
|
Environment: "Production",
|
||
|
|
Description: "基于 Go + React 的现代化用户管理系统",
|
||
|
|
},
|
||
|
|
Security: SecurityInfo{
|
||
|
|
PasswordMinLength: 8,
|
||
|
|
PasswordRequireUppercase: true,
|
||
|
|
PasswordRequireLowercase: true,
|
||
|
|
PasswordRequireNumbers: true,
|
||
|
|
PasswordRequireSymbols: true,
|
||
|
|
PasswordHistory: 5,
|
||
|
|
TOTPEnabled: true,
|
||
|
|
LoginFailLock: true,
|
||
|
|
LoginFailThreshold: 5,
|
||
|
|
LoginFailDuration: 30,
|
||
|
|
SessionTimeout: 86400, // 1天
|
||
|
|
DeviceTrustDuration: 2592000, // 30天
|
||
|
|
},
|
||
|
|
Features: FeaturesInfo{
|
||
|
|
EmailVerification: true,
|
||
|
|
PhoneVerification: false,
|
||
|
|
OAuthProviders: []string{"GitHub", "Google"},
|
||
|
|
SSOEnabled: false,
|
||
|
|
OperationLogEnabled: true,
|
||
|
|
LoginLogEnabled: true,
|
||
|
|
DataExportEnabled: true,
|
||
|
|
DataImportEnabled: true,
|
||
|
|
},
|
||
|
|
}, nil
|
||
|
|
}
|