2019-12-11 16:55:18 +01:00
|
|
|
package entity
|
2019-06-17 07:19:44 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/jinzhu/gorm"
|
2020-01-12 14:00:56 +01:00
|
|
|
"github.com/photoprism/photoprism/pkg/rnd"
|
2019-06-17 07:19:44 +02:00
|
|
|
)
|
|
|
|
|
2020-02-21 01:14:45 +01:00
|
|
|
// Event defines temporal event that can be used to link photos together
|
2019-06-17 07:19:44 +02:00
|
|
|
type Event struct {
|
2019-12-27 05:18:52 +01:00
|
|
|
EventUUID string `gorm:"type:varbinary(36);unique_index;"`
|
2020-01-06 02:14:17 +01:00
|
|
|
EventSlug string `gorm:"type:varbinary(128);unique_index;"`
|
2019-06-17 07:19:44 +02:00
|
|
|
EventName string
|
|
|
|
EventType string
|
2019-12-21 17:24:29 +01:00
|
|
|
EventDescription string `gorm:"type:text;"`
|
|
|
|
EventNotes string `gorm:"type:text;"`
|
2019-12-19 09:37:10 +01:00
|
|
|
EventBegin time.Time `gorm:"type:datetime;"`
|
|
|
|
EventEnd time.Time `gorm:"type:datetime;"`
|
2019-06-17 07:19:44 +02:00
|
|
|
EventLat float64
|
2019-12-20 20:23:16 +01:00
|
|
|
EventLng float64
|
2019-06-17 07:19:44 +02:00
|
|
|
EventDist float64
|
|
|
|
CreatedAt time.Time
|
|
|
|
UpdatedAt time.Time
|
|
|
|
DeletedAt *time.Time `sql:"index"`
|
|
|
|
}
|
|
|
|
|
2020-02-21 01:14:45 +01:00
|
|
|
// TableName returns Event table identifier "events"
|
2019-06-17 07:19:44 +02:00
|
|
|
func (Event) TableName() string {
|
|
|
|
return "events"
|
|
|
|
}
|
|
|
|
|
2020-02-21 01:14:45 +01:00
|
|
|
// BeforeCreate computes a random UUID when a new event is created in database
|
2019-06-17 07:19:44 +02:00
|
|
|
func (e *Event) BeforeCreate(scope *gorm.Scope) error {
|
2020-01-12 12:32:24 +01:00
|
|
|
return scope.SetColumn("EventUUID", rnd.PPID('e'))
|
2019-06-17 07:19:44 +02:00
|
|
|
}
|