2026-05-16 19:30:20 +00:00
|
|
|
package store
|
|
|
|
|
|
|
|
|
|
import (
|
2026-05-17 12:36:50 +00:00
|
|
|
"context"
|
2026-05-16 19:30:20 +00:00
|
|
|
"database/sql"
|
|
|
|
|
"os"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
_ "github.com/mattn/go-sqlite3"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Store struct {
|
|
|
|
|
db *sql.DB
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type SiteContent struct {
|
2026-05-17 12:36:50 +00:00
|
|
|
HeroTitle string
|
|
|
|
|
HeroSubtitle string
|
|
|
|
|
Positioning string
|
|
|
|
|
HeroCTALabel string
|
|
|
|
|
HeroCTAURL string
|
|
|
|
|
SecondaryCTALabel string
|
|
|
|
|
SecondaryCTAURL string
|
|
|
|
|
IntroTitle string
|
|
|
|
|
IntroText string
|
|
|
|
|
ServiceOneTitle string
|
|
|
|
|
ServiceOneText string
|
|
|
|
|
ServiceTwoTitle string
|
|
|
|
|
ServiceTwoText string
|
|
|
|
|
ServiceThreeTitle string
|
|
|
|
|
ServiceThreeText string
|
|
|
|
|
ProcessOneTitle string
|
|
|
|
|
ProcessOneText string
|
|
|
|
|
ProcessTwoTitle string
|
|
|
|
|
ProcessTwoText string
|
|
|
|
|
ProcessThreeTitle string
|
|
|
|
|
ProcessThreeText string
|
|
|
|
|
AboutName string
|
|
|
|
|
AboutRole string
|
|
|
|
|
AboutBio string
|
|
|
|
|
StudioPhilosophy string
|
|
|
|
|
StudioApproach string
|
|
|
|
|
StudioCredentials string
|
|
|
|
|
ServiceArea string
|
|
|
|
|
Email string
|
|
|
|
|
Phone string
|
|
|
|
|
Location string
|
|
|
|
|
HeroImage string
|
|
|
|
|
AboutImage string
|
2026-05-16 19:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Project struct {
|
|
|
|
|
ID int64
|
|
|
|
|
Slug string
|
|
|
|
|
Title string
|
|
|
|
|
Location string
|
|
|
|
|
Year string
|
|
|
|
|
Category string
|
2026-05-17 12:36:50 +00:00
|
|
|
Summary string
|
|
|
|
|
Scope string
|
|
|
|
|
Status string
|
|
|
|
|
Position int
|
2026-05-16 19:30:20 +00:00
|
|
|
Description string
|
|
|
|
|
CoverImage string
|
|
|
|
|
Featured bool
|
|
|
|
|
CreatedAt time.Time
|
|
|
|
|
Images []ProjectImage
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ProjectImage struct {
|
|
|
|
|
ID int64
|
|
|
|
|
ProjectID int64
|
|
|
|
|
Path string
|
|
|
|
|
Caption string
|
|
|
|
|
Position int
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-17 12:36:50 +00:00
|
|
|
type Service struct {
|
|
|
|
|
ID int64
|
|
|
|
|
Title string
|
|
|
|
|
Summary string
|
|
|
|
|
Details string
|
|
|
|
|
Position int
|
|
|
|
|
Active bool
|
|
|
|
|
CreatedAt time.Time
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type FAQ struct {
|
2026-05-16 19:30:20 +00:00
|
|
|
ID int64
|
2026-05-17 12:36:50 +00:00
|
|
|
Question string
|
|
|
|
|
Answer string
|
|
|
|
|
Position int
|
|
|
|
|
Active bool
|
2026-05-16 19:30:20 +00:00
|
|
|
CreatedAt time.Time
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-17 12:36:50 +00:00
|
|
|
type ContactRequest struct {
|
|
|
|
|
ID int64
|
|
|
|
|
Name string
|
|
|
|
|
Email string
|
|
|
|
|
Phone string
|
|
|
|
|
ProjectType string
|
|
|
|
|
ProjectLocation string
|
|
|
|
|
BudgetRange string
|
|
|
|
|
Timeline string
|
|
|
|
|
Message string
|
|
|
|
|
Status string
|
|
|
|
|
Notes string
|
|
|
|
|
CreatedAt time.Time
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-16 19:30:20 +00:00
|
|
|
type AdminUser struct {
|
|
|
|
|
ID int64
|
|
|
|
|
Username string
|
|
|
|
|
PasswordHash []byte
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Open(path string) (*Store, error) {
|
|
|
|
|
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
db, err := sql.Open("sqlite3", path+"?_foreign_keys=on")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
db.SetMaxOpenConns(1)
|
|
|
|
|
return &Store{db: db}, db.Ping()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *Store) Close() error {
|
|
|
|
|
return s.db.Close()
|
|
|
|
|
}
|
2026-05-17 12:36:50 +00:00
|
|
|
|
|
|
|
|
func (s *Store) Ping(ctx context.Context) error {
|
|
|
|
|
return s.db.PingContext(ctx)
|
|
|
|
|
}
|