first commit

This commit is contained in:
Adrian Zürcher
2025-10-24 10:31:19 +02:00
commit 4db4262195
17 changed files with 1937 additions and 0 deletions

39
models/settings.go Normal file
View File

@@ -0,0 +1,39 @@
package models
import (
"database/sql/driver"
"encoding/json"
"fmt"
)
type Settings struct {
PrimaryColor string `json:"primaryColor,omitempty"`
PrimaryColorText string `json:"primaryColorText,omitempty"`
SecondaryColor string `json:"secondaryColor,omitempty"`
SecondaryColorText string `json:"secondaryColorText,omitempty"`
Icon string `json:"icon,omitempty"`
DatabaseName string `json:"databaseName,omitempty"`
DatabaseToken string `json:"databaseToken,omitempty"`
}
func (s *Settings) DefaultQuasarSettings() {
s.DatabaseName = "members.dba"
s.PrimaryColor = "#1976d2"
s.PrimaryColorText = "#ffffff"
s.SecondaryColor = "#26a69a"
s.SecondaryColorText = "#ffffff"
}
// --- Implement driver.Valuer (for saving to DB)
func (s Settings) Value() (driver.Value, error) {
return json.Marshal(s)
}
// --- Implement sql.Scanner (for reading from DB)
func (s *Settings) Scan(value any) error {
bytes, ok := value.([]byte)
if !ok {
return fmt.Errorf("failed to unmarshal Settings: %v", value)
}
return json.Unmarshal(bytes, s)
}