test: add comprehensive test coverage and improve code quality

- Add new test files for auth, service, and handler modules
- Improve test organization and coverage
- Refactor code for better maintainability
- Add captcha, settings, stats, and theme handler tests
- Add auth module tests (CAS, OAuth, password, SSO, state)
- Add service layer tests for auth, export, permissions, roles
- All Go tests pass (exit code 0)
- All frontend tests pass (325 tests in 59 files)
This commit is contained in:
2026-04-17 20:43:50 +08:00
parent 0d66aa0423
commit 582ad7a069
136 changed files with 19010 additions and 8544 deletions

View File

@@ -4,20 +4,20 @@ import "time"
// ThemeConfig 主题配置
type ThemeConfig struct {
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
Name string `gorm:"type:varchar(50);uniqueIndex;not null" json:"name"` // 主题名称
IsDefault bool `gorm:"default:false" json:"is_default"` // 是否默认主题
LogoURL string `gorm:"type:varchar(500)" json:"logo_url"` // Logo URL
FaviconURL string `gorm:"type:varchar(500)" json:"favicon_url"` // Favicon URL
PrimaryColor string `gorm:"type:varchar(20)" json:"primary_color"` // 主色调(如 #1890ff
SecondaryColor string `gorm:"type:varchar(20)" json:"secondary_color"` // 辅助色
BackgroundColor string `gorm:"type:varchar(20)" json:"background_color"` // 背景色
TextColor string `gorm:"type:varchar(20)" json:"text_color"` // 文字颜色
CustomCSS string `gorm:"type:text" json:"custom_css"` // 自定义CSS
CustomJS string `gorm:"type:text" json:"custom_js"` // 自定义JS
Enabled bool `gorm:"default:true" json:"enabled"` // 是否启用
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
Name string `gorm:"type:varchar(50);uniqueIndex;not null" json:"name"` // 主题名称
IsDefault bool `gorm:"default:false" json:"is_default"` // 是否默认主题
LogoURL string `gorm:"type:varchar(500)" json:"logo_url"` // Logo URL
FaviconURL string `gorm:"type:varchar(500)" json:"favicon_url"` // Favicon URL
PrimaryColor string `gorm:"type:varchar(20)" json:"primary_color"` // 主色调(如 #1890ff
SecondaryColor string `gorm:"type:varchar(20)" json:"secondary_color"` // 辅助色
BackgroundColor string `gorm:"type:varchar(20)" json:"background_color"` // 背景色
TextColor string `gorm:"type:varchar(20)" json:"text_color"` // 文字颜色
CustomCSS string `gorm:"type:text" json:"custom_css"` // 自定义CSS
CustomJS string `gorm:"type:text" json:"custom_js"` // 自定义JS
Enabled bool `gorm:"default:true" json:"enabled"` // 是否启用
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
}
// TableName 指定表名
@@ -28,12 +28,12 @@ func (ThemeConfig) TableName() string {
// DefaultThemeConfig 返回默认主题配置
func DefaultThemeConfig() *ThemeConfig {
return &ThemeConfig{
Name: "default",
IsDefault: true,
PrimaryColor: "#1890ff",
SecondaryColor: "#52c41a",
Name: "default",
IsDefault: true,
PrimaryColor: "#1890ff",
SecondaryColor: "#52c41a",
BackgroundColor: "#ffffff",
TextColor: "#333333",
Enabled: true,
TextColor: "#333333",
Enabled: true,
}
}