2018-09-16 19:09:40 +02:00
|
|
|
package models
|
2018-07-18 15:17:56 +02:00
|
|
|
|
|
|
|
import (
|
2018-08-09 23:10:05 +02:00
|
|
|
"time"
|
2018-10-31 07:14:33 +01:00
|
|
|
|
|
|
|
"github.com/jinzhu/gorm"
|
2019-06-09 05:22:53 +02:00
|
|
|
uuid "github.com/satori/go.uuid"
|
2018-07-18 15:17:56 +02:00
|
|
|
)
|
|
|
|
|
2018-11-06 19:02:03 +01:00
|
|
|
// A photo can have multiple images and sidecar files
|
2018-07-18 15:17:56 +02:00
|
|
|
type Photo struct {
|
2019-06-04 18:26:35 +02:00
|
|
|
Model
|
|
|
|
PhotoUUID string `gorm:"unique_index;"`
|
2018-09-27 08:59:53 +02:00
|
|
|
PhotoTitle string
|
|
|
|
PhotoTitleChanged bool
|
|
|
|
PhotoDescription string `gorm:"type:text;"`
|
|
|
|
PhotoNotes string `gorm:"type:text;"`
|
|
|
|
PhotoArtist string
|
|
|
|
PhotoCanonicalName string
|
|
|
|
PhotoFavorite bool
|
|
|
|
PhotoLat float64
|
|
|
|
PhotoLong float64
|
|
|
|
PhotoFocalLength float64
|
|
|
|
PhotoAperture float64
|
|
|
|
Camera *Camera
|
|
|
|
CameraID uint
|
|
|
|
Lens *Lens
|
|
|
|
LensID uint
|
|
|
|
Country *Country
|
|
|
|
CountryID string
|
|
|
|
CountryChanged bool
|
|
|
|
Location *Location
|
|
|
|
LocationID uint
|
|
|
|
LocationChanged bool
|
2019-06-04 18:26:35 +02:00
|
|
|
TakenAt time.Time
|
|
|
|
TakenAtChanged bool
|
2019-06-07 00:04:34 +02:00
|
|
|
TimeZone string
|
2019-06-04 18:26:35 +02:00
|
|
|
Labels []*PhotoLabel
|
2018-09-27 08:59:53 +02:00
|
|
|
Files []*File
|
|
|
|
Albums []*Album `gorm:"many2many:album_photos;"`
|
2018-08-15 09:59:51 +02:00
|
|
|
}
|
2019-06-04 18:26:35 +02:00
|
|
|
|
|
|
|
func (m *Photo) BeforeCreate(scope *gorm.Scope) error {
|
|
|
|
return scope.SetColumn("PhotoUUID", uuid.NewV4().String())
|
|
|
|
}
|