124 lines
5.5 KiB
Go
124 lines
5.5 KiB
Go
package db
|
|
|
|
import "time"
|
|
|
|
type SystemConfig struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
Key string `gorm:"uniqueIndex;size:100" json:"key"`
|
|
Value string `gorm:"type:text" json:"value"`
|
|
Group string `gorm:"size:50;index" json:"group"`
|
|
Label string `gorm:"size:100" json:"label"`
|
|
Type string `gorm:"size:20" json:"type"` // string, int, bool, password, textarea
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type EmailRecord struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
Email string `gorm:"size:200;uniqueIndex" json:"email"`
|
|
Status string `gorm:"size:20;index;default:in_use" json:"status"` // in_use, used, used_member, used_failed
|
|
UsedByAccountID *uint `gorm:"index" json:"used_by_account_id"`
|
|
UsedForRole string `gorm:"size:20" json:"used_for_role"` // owner, member
|
|
TaskID string `gorm:"size:36;index" json:"task_id"`
|
|
CreatedAt time.Time `gorm:"index" json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type Task struct {
|
|
ID string `gorm:"primaryKey;size:36" json:"id"`
|
|
Type string `gorm:"size:20;index" json:"type"` // plus, team, both
|
|
TotalCount int `json:"total_count"`
|
|
DoneCount int `json:"done_count"`
|
|
SuccessCount int `json:"success_count"`
|
|
FailCount int `json:"fail_count"`
|
|
Status string `gorm:"size:20;index" json:"status"` // pending, running, stopping, stopped, interrupted, completed
|
|
Config string `gorm:"type:text" json:"-"`
|
|
CreatedAt time.Time `gorm:"index" json:"created_at"`
|
|
StartedAt *time.Time `json:"started_at"`
|
|
StoppedAt *time.Time `json:"stopped_at"`
|
|
}
|
|
|
|
type TaskLog struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
TaskID string `gorm:"size:36;index" json:"task_id"`
|
|
Index int `json:"index"`
|
|
Email string `gorm:"size:200" json:"email"`
|
|
Status string `gorm:"size:20" json:"status"` // step, success, failed, skipped
|
|
Plan string `gorm:"size:20" json:"plan"` // plus, team, free
|
|
Message string `gorm:"size:500" json:"message"`
|
|
Error string `gorm:"type:text" json:"error"`
|
|
Duration int `json:"duration"` // seconds
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type CardCode struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
Code string `gorm:"size:100;uniqueIndex" json:"code"`
|
|
Status string `gorm:"size:20;index;default:unused" json:"status"` // unused, redeeming, redeemed, failed
|
|
CardID *uint `gorm:"index" json:"card_id"`
|
|
Error string `gorm:"size:200" json:"error"`
|
|
CreatedAt time.Time `gorm:"index" json:"created_at"`
|
|
RedeemedAt *time.Time `json:"redeemed_at"`
|
|
}
|
|
|
|
type Card struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
NumberHash string `gorm:"size:64;uniqueIndex" json:"-"`
|
|
NumberEnc string `gorm:"type:text" json:"-"`
|
|
CVCEnc string `gorm:"type:text" json:"-"`
|
|
ExpMonth string `gorm:"size:2" json:"exp_month"`
|
|
ExpYear string `gorm:"size:4" json:"exp_year"`
|
|
Name string `gorm:"size:100" json:"name"`
|
|
|
|
Country string `gorm:"size:10" json:"country"`
|
|
Address string `gorm:"size:200" json:"address"`
|
|
City string `gorm:"size:100" json:"city"`
|
|
State string `gorm:"size:100" json:"state"`
|
|
PostalCode string `gorm:"size:20" json:"postal_code"`
|
|
|
|
Source string `gorm:"size:20;index" json:"source"` // api, manual
|
|
CardCodeID *uint `gorm:"index" json:"card_code_id"`
|
|
|
|
Status string `gorm:"size:20;index;default:available" json:"status"` // available, active, exhausted, rejected, disabled, expired
|
|
BindCount int `gorm:"default:0" json:"bind_count"`
|
|
MaxBinds int `gorm:"default:1" json:"max_binds"`
|
|
ActivatedAt *time.Time `json:"activated_at"`
|
|
LastUsedAt *time.Time `json:"last_used_at"`
|
|
LastError string `gorm:"size:200" json:"last_error"`
|
|
BoundAccounts string `gorm:"type:text" json:"bound_accounts"` // JSON array
|
|
|
|
CreatedAt time.Time `gorm:"index" json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
// Transient fields for API response (not stored in DB)
|
|
NumberLast4 string `gorm:"-" json:"number_last4,omitempty"`
|
|
CVCPlain string `gorm:"-" json:"cvc_plain,omitempty"`
|
|
}
|
|
|
|
type Account struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
TaskID string `gorm:"size:36;index" json:"task_id"`
|
|
Email string `gorm:"size:200;uniqueIndex" json:"email"`
|
|
Password string `gorm:"size:100" json:"-"`
|
|
Plan string `gorm:"size:20;index" json:"plan"` // plus, team_owner, team_member
|
|
ParentID *uint `gorm:"index" json:"parent_id"`
|
|
Parent *Account `gorm:"foreignKey:ParentID" json:"parent,omitempty"`
|
|
SubAccounts []Account `gorm:"foreignKey:ParentID" json:"sub_accounts,omitempty"`
|
|
|
|
AccessToken string `gorm:"type:text" json:"-"`
|
|
RefreshToken string `gorm:"type:text" json:"-"`
|
|
IDToken string `gorm:"type:text" json:"-"`
|
|
AccountID string `gorm:"size:100" json:"account_id"`
|
|
DeviceID string `gorm:"size:100" json:"-"`
|
|
UserID string `gorm:"size:100" json:"user_id"`
|
|
|
|
TeamWorkspaceID string `gorm:"size:100" json:"team_workspace_id"`
|
|
WorkspaceToken string `gorm:"type:text" json:"-"`
|
|
|
|
Status string `gorm:"size:20;index;default:active" json:"status"` // active, free, plus, team, banned, unknown
|
|
StatusCheckedAt *time.Time `json:"status_checked_at"`
|
|
Note string `gorm:"type:text" json:"note"`
|
|
|
|
CreatedAt time.Time `gorm:"index" json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|