69 lines
2.0 KiB
Go
69 lines
2.0 KiB
Go
package models
|
|
|
|
import "gorm.io/gorm"
|
|
|
|
type Event struct {
|
|
gorm.Model
|
|
ExternalID string `gorm:"uniqueIndex" json:"id"`
|
|
Title string `json:"title"`
|
|
City string `json:"city"`
|
|
Street string `json:"street"`
|
|
Country string
|
|
Categories []Category `gorm:"many2many:event_categories;" json:"-"`
|
|
CategoryNames []string `gorm:"-" json:"categories"` // used only for JSON decoding MediaObjects []MediaObject `json:"media_objects"`
|
|
Features []string `gorm:"-" json:"features"`
|
|
Keywords []string `gorm:"-" json:"keywords"`
|
|
Type string
|
|
Zip string
|
|
Phone string
|
|
Web string
|
|
Email string
|
|
Author string
|
|
Latitude float64 `gorm:"index"`
|
|
Longitude float64 `gorm:"index"`
|
|
Geo *GeoWrapper `gorm:"-" json:"geo"` // ignored by GORM, used for JSON
|
|
Description string
|
|
Teaser string
|
|
StartDate string
|
|
EndDate string
|
|
MediaObjects []MediaObject `gorm:"many2many:event_media_objects;" json:"-"`
|
|
RawMediaObjects []MediaObject `gorm:"-" json:"media_objects"`
|
|
}
|
|
|
|
type MediaObject struct {
|
|
gorm.Model
|
|
ID uint `gorm:"primaryKey"`
|
|
URL string `json:"url"`
|
|
Alt string `json:"alt"`
|
|
Rel string `json:"rel"`
|
|
Name string `json:"value" `
|
|
Type string `json:"type"`
|
|
RefID string `json:"id"`
|
|
Source string `json:"source"`
|
|
Prio int `json:"prio"`
|
|
Description string `json:"description"`
|
|
License string `json:"license"`
|
|
AiOptimized bool `json:"aiOptimized"`
|
|
Ext string
|
|
Hash string
|
|
}
|
|
|
|
type Category struct {
|
|
gorm.Model
|
|
ID uint `gorm:"primaryKey"`
|
|
Name string `gorm:"uniqueIndex"`
|
|
}
|
|
|
|
type GeoWrapper struct {
|
|
Main *GeoCoordinates `json:"main"`
|
|
}
|
|
|
|
type GeoCoordinates struct {
|
|
Latitude float64 `json:"latitude"`
|
|
Longitude float64 `json:"longitude"`
|
|
}
|
|
|
|
func Migrate(db *gorm.DB) {
|
|
db.AutoMigrate(&Event{}, &Category{}, &MediaObject{})
|
|
}
|