框架表改名 w_{name}

This commit is contained in:
ryan
2026-06-11 09:27:15 +08:00
parent 786fe71778
commit 312bc7d4d5
17 changed files with 245 additions and 21 deletions
+5
View File
@@ -30,6 +30,11 @@ type AccessToken struct {
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}
// TableName 表名
func (AccessToken) TableName() string {
return "w_access_tokens"
}
// GenerateTokenString 生成加密安全的随机 Token 值
func GenerateTokenString() (string, error) {
bytes := make([]byte, tokenByteLength)
+10
View File
@@ -38,6 +38,11 @@ type AuthSource struct {
ClientSecretConfigured bool `json:"client_secret_configured" gorm:"-"`
}
// TableName 表名
func (AuthSource) TableName() string {
return "w_auth_sources"
}
// ExternalAccount 外部账号绑定实体
type ExternalAccount struct {
ID uint64 `json:"id" gorm:"primaryKey"`
@@ -50,6 +55,11 @@ type ExternalAccount struct {
UpdatedAt time.Time `json:"updated_at"`
}
// TableName 表名
func (ExternalAccount) TableName() string {
return "w_external_accounts"
}
// ExternalAccountView 外部帐号绑定视图(脱敏展示用)
type ExternalAccountView struct {
ID uint64 `json:"id"`
+1 -1
View File
@@ -24,7 +24,7 @@ type Schedule struct {
// TableName 表名
func (Schedule) TableName() string {
return "schedules"
return "w_schedules"
}
// CreateSchedule 创建定时任务
+5
View File
@@ -68,6 +68,11 @@ type SystemConfig struct {
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
}
// TableName 表名
func (SystemConfig) TableName() string {
return "w_system_configs"
}
// GetByKey 通过 key 查询配置(带 Redis 缓存)
func (sc *SystemConfig) GetByKey(ctx context.Context, key string) error {
if db.Redis != nil {
+1 -1
View File
@@ -49,7 +49,7 @@ type TaskExecution struct {
// TableName 表名
func (TaskExecution) TableName() string {
return "task_executions"
return "w_task_executions"
}
// CreateTaskExecution 创建任务执行记录
+1 -1
View File
@@ -338,5 +338,5 @@ func TestListTaskExecutionsDefaultPaging(t *testing.T) {
func TestTaskExecutionTableName(t *testing.T) {
execution := TaskExecution{}
assert.Equal(t, "task_executions", execution.TableName())
assert.Equal(t, "w_task_executions", execution.TableName())
}
+5
View File
@@ -29,6 +29,11 @@ type Template struct {
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime;index"`
}
// TableName 表名
func (Template) TableName() string {
return "w_templates"
}
// Normalize 规范化模板字段
func (t *Template) Normalize() {
t.Key = strings.TrimSpace(t.Key)
+5
View File
@@ -47,3 +47,8 @@ type Upload struct {
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}
// TableName 表名
func (Upload) TableName() string {
return "w_uploads"
}
+5
View File
@@ -62,6 +62,11 @@ type User struct {
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime;index"`
}
// TableName 表名
func (User) TableName() string {
return "w_users"
}
// SetPassword 设置明文密码
func (u *User) SetPassword(password string) error {
u.Password = password