mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 02:32:57 +00:00
62 lines
1.6 KiB
Go
62 lines
1.6 KiB
Go
package models
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type SetupStatus string
|
|
|
|
const (
|
|
SetupStatusPending SetupStatus = "pending"
|
|
SetupStatusCompleted SetupStatus = "completed"
|
|
SetupStatusSkipped SetupStatus = "skipped"
|
|
)
|
|
|
|
type SetupInfo struct {
|
|
gorm.Model
|
|
Status SetupStatus `gorm:"not null;default:'pending'" json:"status"`
|
|
SkippedAt *time.Time `json:"skipped_at,omitempty"`
|
|
CompletedAt *time.Time `json:"completed_at,omitempty"`
|
|
SMTPConfigured bool `gorm:"default:false" json:"smtp_configured"`
|
|
ClubImported bool `gorm:"default:false" json:"club_imported"`
|
|
}
|
|
|
|
type ClubInfo struct {
|
|
gorm.Model
|
|
SetupInfoID uint `gorm:"not null" json:"-"`
|
|
FACRClubID string `gorm:"uniqueIndex" json:"facr_club_id"`
|
|
Name string `gorm:"not null" json:"name"`
|
|
ShortName string `json:"short_name"`
|
|
LogoURL string `json:"logo_url"`
|
|
PrimaryColor string `json:"primary_color"`
|
|
SecondaryColor string `json:"secondary_color"`
|
|
TextColor string `json:"text_color"`
|
|
}
|
|
|
|
// TableName specifies the table name for the SetupInfo model
|
|
func (SetupInfo) TableName() string {
|
|
return "setup_info"
|
|
}
|
|
|
|
// TableName specifies the table name for the ClubInfo model
|
|
func (ClubInfo) TableName() string {
|
|
return "club_info"
|
|
}
|
|
|
|
// ToJSON returns the JSON representation of the club info
|
|
func (c *ClubInfo) ToJSON() (string, error) {
|
|
data, err := json.Marshal(c)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return string(data), nil
|
|
}
|
|
|
|
// FromJSON populates the club info from JSON data
|
|
func (c *ClubInfo) FromJSON(jsonData string) error {
|
|
return json.Unmarshal([]byte(jsonData), c)
|
|
}
|