backup.go 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. package models
  2. import (
  3. "time"
  4. "github.com/google/uuid"
  5. )
  6. // BackupLog 备份记录
  7. type BackupLog struct {
  8. ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
  9. FileName string `gorm:"type:varchar(255)" json:"fileName"`
  10. FilePath string `gorm:"type:varchar(500)" json:"filePath"` // MinIO path
  11. Size int64 `gorm:"type:bigint" json:"size"`
  12. Status string `gorm:"type:varchar(20)" json:"status"` // SUCCESS, FAILED
  13. Message string `gorm:"type:text" json:"message"`
  14. StartTime time.Time `gorm:"type:timestamp" json:"startTime"`
  15. EndTime time.Time `gorm:"type:timestamp" json:"endTime"`
  16. UploadStatus string `gorm:"type:varchar(20)" json:"uploadStatus"` // PENDING, UPLOADED, FAILED
  17. }
  18. // BackupConfig 备份配置 (非数据库表,仅用于API交互,实际存储在 SysConfig)
  19. type BackupConfig struct {
  20. Enabled bool `json:"enabled"` // 数据库自动备份开关
  21. ResourceEnabled bool `json:"resourceEnabled"` // 资源与物联中心自动备份开关
  22. Time string `json:"time"` // "03:00"
  23. KeepDays int `json:"keepDays"` // Local retention or logic retention
  24. Endpoint string `json:"endpoint"`
  25. AccessKey string `json:"accessKey"`
  26. SecretKey string `json:"secretKey"`
  27. Bucket string `json:"bucket"`
  28. }