- Go API server with PostgreSQL + Redis - AI floor replacement (OpenRouter Gemini) - Product database (10 brands, 3539 products) - Recommendation engine, calculator, articles - Redis async queue + worker pool - Hot product caching, brand view tracking - JWT auth, favorites, projects - Docker deployment ready Co-Authored-By: Claude <noreply@anthropic.com>
34 lines
789 B
Go
34 lines
789 B
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
type Article struct {
|
|
ID int `json:"id"`
|
|
Title string `json:"title"`
|
|
Summary string `json:"summary"`
|
|
Content string `json:"content"`
|
|
CoverURL string `json:"cover_url"`
|
|
ImageURLs []string `json:"image_urls"`
|
|
ImageJSON string `json:"-"` // stored as JSON in DB
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// ScanImageJSON unmarshals image_urls from the JSON column.
|
|
func (a *Article) ScanImageJSON() {
|
|
if a.ImageJSON != "" {
|
|
json.Unmarshal([]byte(a.ImageJSON), &a.ImageURLs)
|
|
}
|
|
if a.ImageURLs == nil {
|
|
a.ImageURLs = []string{}
|
|
}
|
|
}
|
|
|
|
// SetImageJSON marshals image_urls for DB storage.
|
|
func (a *Article) SetImageJSON() {
|
|
data, _ := json.Marshal(a.ImageURLs)
|
|
a.ImageJSON = string(data)
|
|
}
|