Code cleanup
This commit is contained in:
parent
137f570aca
commit
8545e098c1
2 changed files with 189 additions and 291 deletions
|
@ -7,10 +7,7 @@ package api
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// uuid: string PhotoUID as returned by the API
|
// uuid: string PhotoUID as returned by the API
|
||||||
func (v1 *V1Client) GetPhoto(uuid string) (Photo, error) {
|
func (v1 *V1Client) GetPhoto(uuid string) (Photo, error) {
|
||||||
photo := Photo{
|
photo := Photo{}
|
||||||
UUID: uuid,
|
|
||||||
PhotoUID: uuid,
|
|
||||||
}
|
|
||||||
err := v1.GET("/api/v1/photos/%s", uuid).JSON(&photo)
|
err := v1.GET("/api/v1/photos/%s", uuid).JSON(&photo)
|
||||||
return photo, err
|
return photo, err
|
||||||
}
|
}
|
||||||
|
|
475
api/v1/types.go
475
api/v1/types.go
|
@ -1,7 +1,6 @@
|
||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -9,335 +8,237 @@ type Photos []Photo
|
||||||
|
|
||||||
// Photo represents a photo, all its properties, and link to all its images and sidecar files.
|
// Photo represents a photo, all its properties, and link to all its images and sidecar files.
|
||||||
type Photo struct {
|
type Photo struct {
|
||||||
UUID string `gorm:"type:VARBINARY(42);index;" json:"DocumentID,omitempty" yaml:"DocumentID,omitempty"`
|
PhotoID int `json:"ID,omitempty"`
|
||||||
TakenAt time.Time `gorm:"type:datetime;index:idx_photos_taken_uid;" json:"TakenAt" yaml:"TakenAt"`
|
TakenAt time.Time `json:"TakenAt"`
|
||||||
TakenAtLocal time.Time `gorm:"type:datetime;" yaml:"-"`
|
TakenAtLocal time.Time `json:"TakenAtLocal"`
|
||||||
TakenSrc string `gorm:"type:VARBINARY(8);" json:"TakenSrc" yaml:"TakenSrc,omitempty"`
|
TakenSrc string `json:"TakenSrc"`
|
||||||
PhotoUID string `gorm:"type:VARBINARY(42);unique_index;index:idx_photos_taken_uid;" json:"UID" yaml:"UID"`
|
PhotoUID string `json:"UID"`
|
||||||
PhotoType string `gorm:"type:VARBINARY(8);default:'image';" json:"Type" yaml:"Type"`
|
PhotoType string `json:"Type"`
|
||||||
TypeSrc string `gorm:"type:VARBINARY(8);" json:"TypeSrc" yaml:"TypeSrc,omitempty"`
|
TypeSrc string `json:"TypeSrc"`
|
||||||
PhotoTitle string `gorm:"type:VARCHAR(255);" json:"Title" yaml:"Title"`
|
PhotoTitle string `json:"Title"`
|
||||||
TitleSrc string `gorm:"type:VARBINARY(8);" json:"TitleSrc" yaml:"TitleSrc,omitempty"`
|
TitleSrc string `json:"TitleSrc"`
|
||||||
PhotoDescription string `gorm:"type:TEXT;" json:"Description" yaml:"Description,omitempty"`
|
PhotoDescription string `json:"Description"`
|
||||||
DescriptionSrc string `gorm:"type:VARBINARY(8);" json:"DescriptionSrc" yaml:"DescriptionSrc,omitempty"`
|
DescriptionSrc string `json:"DescriptionSrc"`
|
||||||
PhotoPath string `gorm:"type:VARBINARY(500);index:idx_photos_path_name;" json:"Path" yaml:"-"`
|
PhotoPath string `json:"Path"`
|
||||||
PhotoName string `gorm:"type:VARBINARY(255);index:idx_photos_path_name;" json:"Name" yaml:"-"`
|
PhotoName string `json:"Name"`
|
||||||
OriginalName string `gorm:"type:VARBINARY(755);" json:"OriginalName" yaml:"OriginalName,omitempty"`
|
OriginalName string `json:"OriginalName"`
|
||||||
PhotoStack int8 `json:"Stack" yaml:"Stack,omitempty"`
|
PhotoStack int8 `json:"Stack"`
|
||||||
PhotoFavorite bool `json:"Favorite" yaml:"Favorite,omitempty"`
|
PhotoFavorite bool `json:"Favorite"`
|
||||||
PhotoPrivate bool `json:"Private" yaml:"Private,omitempty"`
|
PhotoPrivate bool `json:"Private"`
|
||||||
PhotoScan bool `json:"Scan" yaml:"Scan,omitempty"`
|
PhotoScan bool `json:"Scan"`
|
||||||
PhotoPanorama bool `json:"Panorama" yaml:"Panorama,omitempty"`
|
PhotoPanorama bool `json:"Panorama"`
|
||||||
TimeZone string `gorm:"type:VARBINARY(64);" json:"TimeZone" yaml:"-"`
|
TimeZone string `json:"TimeZone"`
|
||||||
PlaceID string `gorm:"type:VARBINARY(42);index;default:'zz'" json:"PlaceID" yaml:"-"`
|
PlaceID string `json:"PlaceID"`
|
||||||
PlaceSrc string `gorm:"type:VARBINARY(8);" json:"PlaceSrc" yaml:"PlaceSrc,omitempty"`
|
PlaceSrc string `json:"PlaceSrc"`
|
||||||
CellID string `gorm:"type:VARBINARY(42);index;default:'zz'" json:"CellID" yaml:"-"`
|
CellID string `json:"CellID"`
|
||||||
CellAccuracy int `json:"CellAccuracy" yaml:"CellAccuracy,omitempty"`
|
CellAccuracy int `json:"CellAccuracy"`
|
||||||
PhotoAltitude int `json:"Altitude" yaml:"Altitude,omitempty"`
|
PhotoAltitude int `json:"Altitude"`
|
||||||
PhotoLat float32 `gorm:"type:FLOAT;index;" json:"Lat" yaml:"Lat,omitempty"`
|
PhotoLat float32 `json:"Lat"`
|
||||||
PhotoLng float32 `gorm:"type:FLOAT;index;" json:"Lng" yaml:"Lng,omitempty"`
|
PhotoLng float32 `json:"Lng"`
|
||||||
PhotoCountry string `gorm:"type:VARBINARY(2);index:idx_photos_country_year_month;default:'zz'" json:"Country" yaml:"-"`
|
PhotoCountry string `json:"Country"`
|
||||||
PhotoYear int `gorm:"index:idx_photos_country_year_month;" json:"Year" yaml:"Year"`
|
PhotoYear int `json:"Year"`
|
||||||
PhotoMonth int `gorm:"index:idx_photos_country_year_month;" json:"Month" yaml:"Month"`
|
PhotoMonth int `json:"Month"`
|
||||||
PhotoDay int `json:"Day" yaml:"Day"`
|
PhotoDay int `json:"Day"`
|
||||||
PhotoIso int `json:"Iso" yaml:"ISO,omitempty"`
|
PhotoIso int `json:"Iso"`
|
||||||
PhotoExposure string `gorm:"type:VARBINARY(64);" json:"Exposure" yaml:"Exposure,omitempty"`
|
PhotoExposure string `json:"Exposure"`
|
||||||
PhotoFNumber float32 `gorm:"type:FLOAT;" json:"FNumber" yaml:"FNumber,omitempty"`
|
PhotoFNumber float32 `json:"FNumber"`
|
||||||
PhotoFocalLength int `json:"FocalLength" yaml:"FocalLength,omitempty"`
|
PhotoFocalLength int `json:"FocalLength"`
|
||||||
PhotoQuality int `gorm:"type:SMALLINT" json:"Quality" yaml:"-"`
|
PhotoQuality int `json:"Quality"`
|
||||||
PhotoResolution int `gorm:"type:SMALLINT" json:"Resolution" yaml:"-"`
|
PhotoResolution int `json:"Resolution"`
|
||||||
PhotoColor uint8 `json:"Color" yaml:"-"`
|
PhotoColor uint8 `json:"Color"`
|
||||||
CameraID uint `gorm:"index:idx_photos_camera_lens;default:1" json:"CameraID" yaml:"-"`
|
CameraID uint `json:"CameraID"`
|
||||||
CameraSerial string `gorm:"type:VARBINARY(255);" json:"CameraSerial" yaml:"CameraSerial,omitempty"`
|
CameraSerial string `json:"CameraSerial"`
|
||||||
CameraSrc string `gorm:"type:VARBINARY(8);" json:"CameraSrc" yaml:"-"`
|
CameraSrc string `json:"CameraSrc"`
|
||||||
LensID uint `gorm:"index:idx_photos_camera_lens;default:1" json:"LensID" yaml:"-"`
|
LensID uint `json:"LensID"`
|
||||||
Details *Details `gorm:"association_autoupdate:false;association_autocreate:false;association_save_reference:false" json:"Details" yaml:"Details"`
|
Details *Details `json:"Details"`
|
||||||
Camera *Camera `gorm:"association_autoupdate:false;association_autocreate:false;association_save_reference:false" json:"Camera" yaml:"-"`
|
Camera *Camera `json:"Camera"`
|
||||||
Lens *Lens `gorm:"association_autoupdate:false;association_autocreate:false;association_save_reference:false" json:"Lens" yaml:"-"`
|
Lens *Lens `json:"Lens"`
|
||||||
Cell *Cell `gorm:"association_autoupdate:false;association_autocreate:false;association_save_reference:false" json:"Cell" yaml:"-"`
|
Cell *Cell `json:"Cell"`
|
||||||
Place *Place `gorm:"association_autoupdate:false;association_autocreate:false;association_save_reference:false" json:"Place" yaml:"-"`
|
Place *Place `json:"Place"`
|
||||||
Keywords []Keyword `json:"-" yaml:"-"`
|
Files []File `json:"Files"`
|
||||||
Albums []Album `json:"-" yaml:"-"`
|
Labels []PhotoLabel `json:"Labels"`
|
||||||
Files []File `yaml:"-"`
|
CreatedAt time.Time `json:"CreatedAt"`
|
||||||
Labels []PhotoLabel `yaml:"-"`
|
UpdatedAt time.Time `json:"UpdatedAt"`
|
||||||
CreatedAt time.Time `yaml:"CreatedAt,omitempty"`
|
EditedAt *time.Time `json:"EditedAt"`
|
||||||
UpdatedAt time.Time `yaml:"UpdatedAt,omitempty"`
|
CheckedAt *time.Time `json:"CheckedAt"`
|
||||||
EditedAt *time.Time `yaml:"EditedAt,omitempty"`
|
DeletedAt *time.Time `json:"DeletedAt"`
|
||||||
CheckedAt *time.Time `sql:"index" yaml:"-"`
|
|
||||||
DeletedAt *time.Time `sql:"index" yaml:"DeletedAt,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Details stores additional metadata fields for each photo to improve search performance.
|
// Details stores additional metadata fields for each photo to improve search performance.
|
||||||
type Details struct {
|
type Details struct {
|
||||||
PhotoID uint `gorm:"primary_key;auto_increment:false" yaml:"-"`
|
PhotoID uint `json:"PhotoID"`
|
||||||
Keywords string `gorm:"type:TEXT;" json:"Keywords" yaml:"Keywords"`
|
Keywords string `json:"Keywords"`
|
||||||
KeywordsSrc string `gorm:"type:VARBINARY(8);" json:"KeywordsSrc" yaml:"KeywordsSrc,omitempty"`
|
KeywordsSrc string `json:"KeywordsSrc"`
|
||||||
Notes string `gorm:"type:TEXT;" json:"Notes" yaml:"Notes,omitempty"`
|
Notes string `json:"Notes"`
|
||||||
NotesSrc string `gorm:"type:VARBINARY(8);" json:"NotesSrc" yaml:"NotesSrc,omitempty"`
|
NotesSrc string `json:"NotesSrc"`
|
||||||
Subject string `gorm:"type:VARCHAR(255);" json:"Subject" yaml:"Subject,omitempty"`
|
Subject string `json:"Subject"`
|
||||||
SubjectSrc string `gorm:"type:VARBINARY(8);" json:"SubjectSrc" yaml:"SubjectSrc,omitempty"`
|
SubjectSrc string `json:"SubjectSrc"`
|
||||||
Artist string `gorm:"type:VARCHAR(255);" json:"Artist" yaml:"Artist,omitempty"`
|
Artist string `json:"Artist"`
|
||||||
ArtistSrc string `gorm:"type:VARBINARY(8);" json:"ArtistSrc" yaml:"ArtistSrc,omitempty"`
|
ArtistSrc string `json:"ArtistSrc"`
|
||||||
Copyright string `gorm:"type:VARCHAR(255);" json:"Copyright" yaml:"Copyright,omitempty"`
|
Copyright string `json:"Copyright"`
|
||||||
CopyrightSrc string `gorm:"type:VARBINARY(8);" json:"CopyrightSrc" yaml:"CopyrightSrc,omitempty"`
|
CopyrightSrc string `json:"CopyrightSrc"`
|
||||||
License string `gorm:"type:VARCHAR(255);" json:"License" yaml:"License,omitempty"`
|
License string `json:"License"`
|
||||||
LicenseSrc string `gorm:"type:VARBINARY(8);" json:"LicenseSrc" yaml:"LicenseSrc,omitempty"`
|
LicenseSrc string `json:"LicenseSrc"`
|
||||||
CreatedAt time.Time `yaml:"-"`
|
Software string `json:"Software"`
|
||||||
UpdatedAt time.Time `yaml:"-"`
|
SoftwareSrc string `json:"SoftwareSrc"`
|
||||||
|
CreatedAt time.Time `json:"CreatedAt"`
|
||||||
|
UpdatedAt time.Time `json:"UpdatedAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Camera model and make (as extracted from UpdateExif metadata)
|
// Camera model and make (as extracted from UpdateExif metadata)
|
||||||
type Camera struct {
|
type Camera struct {
|
||||||
ID uint `gorm:"primary_key" json:"ID" yaml:"ID"`
|
ID uint `json:"ID"`
|
||||||
CameraSlug string `gorm:"type:VARBINARY(255);unique_index;" json:"Slug" yaml:"-"`
|
CameraSlug string `json:"Slug"`
|
||||||
CameraName string `gorm:"type:VARCHAR(255);" json:"Name" yaml:"Name"`
|
CameraName string `json:"Name"`
|
||||||
CameraMake string `gorm:"type:VARCHAR(255);" json:"Make" yaml:"Make,omitempty"`
|
CameraMake string `json:"Make"`
|
||||||
CameraModel string `gorm:"type:VARCHAR(255);" json:"Model" yaml:"Model,omitempty"`
|
CameraModel string `json:"Model"`
|
||||||
CameraType string `gorm:"type:VARCHAR(255);" json:"Type,omitempty" yaml:"Type,omitempty"`
|
CameraType string `json:"Type,omitempty"`
|
||||||
CameraDescription string `gorm:"type:TEXT;" json:"Description,omitempty" yaml:"Description,omitempty"`
|
CameraDescription string `json:"Description,omitempty"`
|
||||||
CameraNotes string `gorm:"type:TEXT;" json:"Notes,omitempty" yaml:"Notes,omitempty"`
|
CameraNotes string `json:"Notes,omitempty"`
|
||||||
CreatedAt time.Time `json:"-" yaml:"-"`
|
|
||||||
UpdatedAt time.Time `json:"-" yaml:"-"`
|
|
||||||
DeletedAt *time.Time `sql:"index" json:"-" yaml:"-"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lens represents camera lens (as extracted from UpdateExif metadata)
|
// Lens represents camera lens (as extracted from UpdateExif metadata)
|
||||||
type Lens struct {
|
type Lens struct {
|
||||||
ID uint `gorm:"primary_key" json:"ID" yaml:"ID"`
|
ID uint `json:"ID"`
|
||||||
LensSlug string `gorm:"type:VARBINARY(255);unique_index;" json:"Slug" yaml:"Slug,omitempty"`
|
LensSlug string `json:"Slug"`
|
||||||
LensName string `gorm:"type:VARCHAR(255);" json:"Name" yaml:"Name"`
|
LensName string `json:"Name"`
|
||||||
LensMake string `gorm:"type:VARCHAR(255);" json:"Make" yaml:"Make,omitempty"`
|
LensMake string `json:"Make"`
|
||||||
LensModel string `gorm:"type:VARCHAR(255);" json:"Model" yaml:"Model,omitempty"`
|
LensModel string `json:"Model"`
|
||||||
LensType string `gorm:"type:VARCHAR(255);" json:"Type" yaml:"Type,omitempty"`
|
LensType string `json:"Type"`
|
||||||
LensDescription string `gorm:"type:TEXT;" json:"Description,omitempty" yaml:"Description,omitempty"`
|
LensDescription string `json:"Description,omitempty"`
|
||||||
LensNotes string `gorm:"type:TEXT;" json:"Notes,omitempty" yaml:"Notes,omitempty"`
|
LensNotes string `json:"Notes,omitempty"`
|
||||||
CreatedAt time.Time `json:"-" yaml:"-"`
|
|
||||||
UpdatedAt time.Time `json:"-" yaml:"-"`
|
|
||||||
DeletedAt *time.Time `sql:"index" json:"-" yaml:"-"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cell represents a S2 cell with location data.
|
// Cell represents a S2 cell with location data.
|
||||||
type Cell struct {
|
type Cell struct {
|
||||||
ID string `gorm:"type:VARBINARY(42);primary_key;auto_increment:false;" json:"ID" yaml:"ID"`
|
ID string `json:"ID"`
|
||||||
CellName string `gorm:"type:VARCHAR(255);" json:"Name" yaml:"Name,omitempty"`
|
CellName string `json:"Name"`
|
||||||
CellCategory string `gorm:"type:VARCHAR(64);" json:"Category" yaml:"Category,omitempty"`
|
CellStreet string `json:"Street"`
|
||||||
PlaceID string `gorm:"type:VARBINARY(42);default:'zz'" json:"-" yaml:"PlaceID"`
|
CellPostcode string `json:"Postcode"`
|
||||||
Place *Place `gorm:"PRELOAD:true" json:"Place" yaml:"-"`
|
CellCategory string `json:"Category"`
|
||||||
CreatedAt time.Time `json:"CreatedAt" yaml:"-"`
|
Place *Place `json:"Place"`
|
||||||
UpdatedAt time.Time `json:"UpdatedAt" yaml:"-"`
|
CreatedAt time.Time `json:"CreatedAt"`
|
||||||
|
UpdatedAt time.Time `json:"UpdatedAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Place used to associate photos to places
|
// Place used to associate photos to places
|
||||||
type Place struct {
|
type Place struct {
|
||||||
ID string `gorm:"type:VARBINARY(42);primary_key;auto_increment:false;" json:"PlaceID" yaml:"PlaceID"`
|
ID string `json:"PlaceID"`
|
||||||
PlaceLabel string `gorm:"type:VARBINARY(755);unique_index;" json:"Label" yaml:"Label"`
|
PlaceLabel string `json:"Label"`
|
||||||
PlaceCity string `gorm:"type:VARCHAR(255);" json:"City" yaml:"City,omitempty"`
|
PlaceCity string `json:"City"`
|
||||||
PlaceState string `gorm:"type:VARCHAR(255);" json:"State" yaml:"State,omitempty"`
|
PlaceState string `json:"State"`
|
||||||
PlaceCountry string `gorm:"type:VARBINARY(2);" json:"Country" yaml:"Country,omitempty"`
|
PlaceCountry string `json:"Country"`
|
||||||
PlaceKeywords string `gorm:"type:VARCHAR(255);" json:"Keywords" yaml:"Keywords,omitempty"`
|
PlaceKeywords string `json:"Keywords"`
|
||||||
PlaceFavorite bool `json:"Favorite" yaml:"Favorite,omitempty"`
|
PlaceFavorite bool `json:"Favorite"`
|
||||||
PhotoCount int `gorm:"default:1" json:"PhotoCount" yaml:"-"`
|
PhotoCount int `json:"PhotoCount"`
|
||||||
CreatedAt time.Time `json:"CreatedAt" yaml:"-"`
|
CreatedAt time.Time `json:"CreatedAt"`
|
||||||
UpdatedAt time.Time `json:"UpdatedAt" yaml:"-"`
|
UpdatedAt time.Time `json:"UpdatedAt"`
|
||||||
}
|
|
||||||
|
|
||||||
// Keyword used for full text search
|
|
||||||
type Keyword struct {
|
|
||||||
ID uint `gorm:"primary_key"`
|
|
||||||
Keyword string `gorm:"type:VARCHAR(64);index;"`
|
|
||||||
Skip bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Album represents a photo album
|
// Album represents a photo album
|
||||||
type Album struct {
|
type Album struct {
|
||||||
ID uint `gorm:"primary_key" json:"ID" yaml:"-"`
|
ID uint `json:"ID"`
|
||||||
AlbumUID string `gorm:"type:VARBINARY(42);unique_index;" json:"UID" yaml:"UID"`
|
AlbumUID string `json:"UID"`
|
||||||
CoverUID string `gorm:"type:VARBINARY(42);" json:"CoverUID" yaml:"CoverUID,omitempty"`
|
AlbumSlug string `json:"Slug"`
|
||||||
FolderUID string `gorm:"type:VARBINARY(42);index;" json:"FolderUID" yaml:"FolderUID,omitempty"`
|
AlbumType string `json:"Type"`
|
||||||
AlbumSlug string `gorm:"type:VARBINARY(255);index;" json:"Slug" yaml:"Slug"`
|
AlbumTitle string `json:"Title"`
|
||||||
AlbumPath string `gorm:"type:VARBINARY(500);index;" json:"Path" yaml:"-"`
|
AlbumLocation string `json:"Location"`
|
||||||
AlbumType string `gorm:"type:VARBINARY(8);default:'album';" json:"Type" yaml:"Type,omitempty"`
|
AlbumCategory string `json:"Category"`
|
||||||
AlbumTitle string `gorm:"type:VARCHAR(255);" json:"Title" yaml:"Title"`
|
AlbumCaption string `json:"Caption"`
|
||||||
AlbumLocation string `gorm:"type:VARCHAR(255);" json:"Location" yaml:"Location,omitempty"`
|
AlbumDescription string `json:"Description"`
|
||||||
AlbumCategory string `gorm:"type:VARCHAR(255);index;" json:"Category" yaml:"Category,omitempty"`
|
AlbumNotes string `json:"Notes"`
|
||||||
AlbumCaption string `gorm:"type:TEXT;" json:"Caption" yaml:"Caption,omitempty"`
|
AlbumFilter string `json:"Filter"`
|
||||||
AlbumDescription string `gorm:"type:TEXT;" json:"Description" yaml:"Description,omitempty"`
|
AlbumOrder string `json:"Order"`
|
||||||
AlbumNotes string `gorm:"type:TEXT;" json:"Notes" yaml:"Notes,omitempty"`
|
AlbumTemplate string `json:"Template"`
|
||||||
AlbumFilter string `gorm:"type:VARBINARY(1024);" json:"Filter" yaml:"Filter,omitempty"`
|
AlbumCountry string `json:"Country"`
|
||||||
AlbumOrder string `gorm:"type:VARBINARY(32);" json:"Order" yaml:"Order,omitempty"`
|
AlbumYear int `json:"Year"`
|
||||||
AlbumTemplate string `gorm:"type:VARBINARY(255);" json:"Template" yaml:"Template,omitempty"`
|
AlbumMonth int `json:"Month"`
|
||||||
AlbumCountry string `gorm:"type:VARBINARY(2);index:idx_albums_country_year_month;default:'zz'" json:"Country" yaml:"Country,omitempty"`
|
AlbumDay int `json:"Day"`
|
||||||
AlbumYear int `gorm:"index:idx_albums_country_year_month;" json:"Year" yaml:"Year,omitempty"`
|
AlbumFavorite bool `json:"Favorite"`
|
||||||
AlbumMonth int `gorm:"index:idx_albums_country_year_month;" json:"Month" yaml:"Month,omitempty"`
|
AlbumPrivate bool `json:"Private"`
|
||||||
AlbumDay int `json:"Day" yaml:"Day,omitempty"`
|
CreatedAt time.Time `json:"CreatedAt"`
|
||||||
AlbumFavorite bool `json:"Favorite" yaml:"Favorite,omitempty"`
|
UpdatedAt time.Time `json:"UpdatedAt"`
|
||||||
AlbumPrivate bool `json:"Private" yaml:"Private,omitempty"`
|
DeletedAt *time.Time `json:"DeletedAt"`
|
||||||
CreatedAt time.Time `json:"CreatedAt" yaml:"CreatedAt,omitempty"`
|
|
||||||
UpdatedAt time.Time `json:"UpdatedAt" yaml:"UpdatedAt,omitempty"`
|
|
||||||
DeletedAt *time.Time `sql:"index" json:"DeletedAt" yaml:"DeletedAt,omitempty"`
|
|
||||||
Photos PhotoAlbums `gorm:"foreignkey:AlbumUID;association_foreignkey:AlbumUID" json:"-" yaml:"Photos,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PhotoAlbums []PhotoAlbum
|
type PhotoAlbums []PhotoAlbum
|
||||||
|
|
||||||
// PhotoAlbum represents the many_to_many relation between Photo and Album
|
// PhotoAlbum represents the many_to_many relation between Photo and Album
|
||||||
type PhotoAlbum struct {
|
type PhotoAlbum struct {
|
||||||
PhotoUID string `gorm:"type:VARBINARY(42);primary_key;auto_increment:false" json:"PhotoUID" yaml:"UID"`
|
PhotoUID string `json:"PhotoUID"`
|
||||||
AlbumUID string `gorm:"type:VARBINARY(42);primary_key;auto_increment:false;index" json:"AlbumUID" yaml:"-"`
|
AlbumUID string `json:"AlbumUID"`
|
||||||
Order int `json:"Order" yaml:"Order,omitempty"`
|
Order int `json:"Order"`
|
||||||
Hidden bool `json:"Hidden" yaml:"Hidden,omitempty"`
|
Hidden bool `json:"Hidden"`
|
||||||
Missing bool `json:"Missing" yaml:"Missing,omitempty"`
|
Missing bool `json:"Missing"`
|
||||||
CreatedAt time.Time `json:"CreatedAt" yaml:"CreatedAt,omitempty"`
|
CreatedAt time.Time `json:"CreatedAt"`
|
||||||
UpdatedAt time.Time `json:"UpdatedAt" yaml:"-"`
|
UpdatedAt time.Time `json:"UpdatedAt"`
|
||||||
Photo *Photo `gorm:"PRELOAD:false" yaml:"-"`
|
Photo *Photo
|
||||||
Album *Album `gorm:"PRELOAD:true" yaml:"-"`
|
Album *Album
|
||||||
}
|
}
|
||||||
|
|
||||||
type Files []File
|
type Files []File
|
||||||
|
|
||||||
// File represents an image or sidecar file that belongs to a photo.
|
// File represents an image or sidecar file that belongs to a photo.
|
||||||
type File struct {
|
type File struct {
|
||||||
ID uint `gorm:"primary_key" json:"-" yaml:"-"`
|
PhotoUID string `json:"PhotoUID"`
|
||||||
Photo *Photo `json:"-" yaml:"-"`
|
FileUID string `json:"UID"`
|
||||||
PhotoID uint `gorm:"index;" json:"-" yaml:"-"`
|
FileName string `json:"Name"`
|
||||||
PhotoUID string `gorm:"type:VARBINARY(42);index;" json:"PhotoUID" yaml:"PhotoUID"`
|
FileRoot string `json:"Root"`
|
||||||
InstanceID string `gorm:"type:VARBINARY(42);index;" json:"InstanceID,omitempty" yaml:"InstanceID,omitempty"`
|
OriginalName string `json:"OriginalName"`
|
||||||
FileUID string `gorm:"type:VARBINARY(42);unique_index;" json:"UID" yaml:"UID"`
|
FileHash string `json:"Hash"`
|
||||||
FileName string `gorm:"type:VARBINARY(755);unique_index:idx_files_name_root;" json:"Name" yaml:"Name"`
|
FileSize int64 `json:"Size"`
|
||||||
FileRoot string `gorm:"type:VARBINARY(16);default:'/';unique_index:idx_files_name_root;" json:"Root" yaml:"Root,omitempty"`
|
FileCodec string `json:"Codec"`
|
||||||
OriginalName string `gorm:"type:VARBINARY(755);" json:"OriginalName" yaml:"OriginalName,omitempty"`
|
FileType string `json:"Type"`
|
||||||
FileHash string `gorm:"type:VARBINARY(128);index" json:"Hash" yaml:"Hash,omitempty"`
|
FileMime string `json:"Mime"`
|
||||||
FileSize int64 `json:"Size" yaml:"Size,omitempty"`
|
FilePrimary bool `json:"Primary"`
|
||||||
FileCodec string `gorm:"type:VARBINARY(32)" json:"Codec" yaml:"Codec,omitempty"`
|
FileSidecar bool `json:"Sidecar"`
|
||||||
FileType string `gorm:"type:VARBINARY(32)" json:"Type" yaml:"Type,omitempty"`
|
FileMissing bool `json:"Missing"`
|
||||||
FileMime string `gorm:"type:VARBINARY(64)" json:"Mime" yaml:"Mime,omitempty"`
|
FilePortrait bool `json:"Portrait"`
|
||||||
FilePrimary bool `json:"Primary" yaml:"Primary,omitempty"`
|
FileVideo bool `json:"Video"`
|
||||||
FileSidecar bool `json:"Sidecar" yaml:"Sidecar,omitempty"`
|
FileDuration time.Duration `json:"Duration"`
|
||||||
FileMissing bool `json:"Missing" yaml:"Missing,omitempty"`
|
FileWidth int `json:"Width"`
|
||||||
FilePortrait bool `json:"Portrait" yaml:"Portrait,omitempty"`
|
FileHeight int `json:"Height"`
|
||||||
FileVideo bool `json:"Video" yaml:"Video,omitempty"`
|
FileOrientation int `json:"Orientation"`
|
||||||
FileDuration time.Duration `json:"Duration" yaml:"Duration,omitempty"`
|
FileProjection string `json:"Projection,omitempty"`
|
||||||
FileWidth int `json:"Width" yaml:"Width,omitempty"`
|
FileAspectRatio float32 `json:"AspectRatio"`
|
||||||
FileHeight int `json:"Height" yaml:"Height,omitempty"`
|
FileMainColor string `json:"MainColor"`
|
||||||
FileOrientation int `json:"Orientation" yaml:"Orientation,omitempty"`
|
FileColors string `json:"Colors"`
|
||||||
FileProjection string `gorm:"type:VARBINARY(16);" json:"Projection,omitempty" yaml:"Projection,omitempty"`
|
FileLuminance string `json:"Luminance"`
|
||||||
FileAspectRatio float32 `gorm:"type:FLOAT;" json:"AspectRatio" yaml:"AspectRatio,omitempty"`
|
FileDiff uint32 `json:"Diff"`
|
||||||
FileMainColor string `gorm:"type:VARBINARY(16);index;" json:"MainColor" yaml:"MainColor,omitempty"`
|
FileChroma uint8 `json:"Chroma"`
|
||||||
FileColors string `gorm:"type:VARBINARY(9);" json:"Colors" yaml:"Colors,omitempty"`
|
FileError string `json:"Error"`
|
||||||
FileLuminance string `gorm:"type:VARBINARY(9);" json:"Luminance" yaml:"Luminance,omitempty"`
|
ModTime int64 `json:"ModTime"`
|
||||||
FileDiff uint32 `json:"Diff" yaml:"Diff,omitempty"`
|
CreatedAt time.Time `json:"CreatedAt"`
|
||||||
FileChroma uint8 `json:"Chroma" yaml:"Chroma,omitempty"`
|
CreatedIn int64 `json:"CreatedIn"`
|
||||||
FileError string `gorm:"type:VARBINARY(512)" json:"Error" yaml:"Error,omitempty"`
|
UpdatedAt time.Time `json:"UpdatedAt"`
|
||||||
ModTime int64 `json:"ModTime" yaml:"-"`
|
UpdatedIn int64 `json:"UpdatedIn"`
|
||||||
CreatedAt time.Time `json:"CreatedAt" yaml:"-"`
|
DeletedAt *time.Time `json:"DeletedAt,omitempty"`
|
||||||
CreatedIn int64 `json:"CreatedIn" yaml:"-"`
|
|
||||||
UpdatedAt time.Time `json:"UpdatedAt" yaml:"-"`
|
|
||||||
UpdatedIn int64 `json:"UpdatedIn" yaml:"-"`
|
|
||||||
DeletedAt *time.Time `sql:"index" json:"DeletedAt,omitempty" yaml:"-"`
|
|
||||||
Share []FileShare `json:"-" yaml:"-"`
|
|
||||||
Sync []FileSync `json:"-" yaml:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// FileSync represents a one-to-many relation between File and Account for syncing with remote services.
|
|
||||||
type FileSync struct {
|
|
||||||
RemoteName string `gorm:"primary_key;auto_increment:false;type:VARBINARY(255)"`
|
|
||||||
AccountID uint `gorm:"primary_key;auto_increment:false"`
|
|
||||||
FileID uint `gorm:"index;"`
|
|
||||||
RemoteDate time.Time
|
|
||||||
RemoteSize int64
|
|
||||||
Status string `gorm:"type:VARBINARY(16);"`
|
|
||||||
Error string `gorm:"type:VARBINARY(512);"`
|
|
||||||
Errors int
|
|
||||||
File *File
|
|
||||||
Account *Account
|
|
||||||
CreatedAt time.Time
|
|
||||||
UpdatedAt time.Time
|
|
||||||
}
|
|
||||||
|
|
||||||
// FileShare represents a one-to-many relation between File and Account for pushing files to remote services.
|
|
||||||
type FileShare struct {
|
|
||||||
FileID uint `gorm:"primary_key;auto_increment:false"`
|
|
||||||
AccountID uint `gorm:"primary_key;auto_increment:false"`
|
|
||||||
RemoteName string `gorm:"primary_key;auto_increment:false;type:VARBINARY(255)"`
|
|
||||||
Status string `gorm:"type:VARBINARY(16);"`
|
|
||||||
Error string `gorm:"type:VARBINARY(512);"`
|
|
||||||
Errors int
|
|
||||||
File *File
|
|
||||||
Account *Account
|
|
||||||
CreatedAt time.Time
|
|
||||||
UpdatedAt time.Time
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PhotoLabel represents the many-to-many relation between Photo and label.
|
// PhotoLabel represents the many-to-many relation between Photo and label.
|
||||||
// Labels are weighted by uncertainty (100 - confidence)
|
// Labels are weighted by uncertainty (100 - confidence)
|
||||||
type PhotoLabel struct {
|
type PhotoLabel struct {
|
||||||
PhotoID uint `gorm:"primary_key;auto_increment:false"`
|
PhotoID uint `json:"PhotoID"`
|
||||||
LabelID uint `gorm:"primary_key;auto_increment:false;index"`
|
LabelID uint `json:"LabelID"`
|
||||||
LabelSrc string `gorm:"type:VARBINARY(8);"`
|
LabelSrc string `json:"LabelSrc""`
|
||||||
Uncertainty int `gorm:"type:SMALLINT"`
|
Uncertainty int `json:"Uncertainty"`
|
||||||
Photo *Photo `gorm:"PRELOAD:false"`
|
Photo *Photo `json:"Photo"`
|
||||||
Label *Label `gorm:"PRELOAD:true"`
|
Label *Label `json:"Label"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Label is used for photo, album and location categorization
|
// Label is used for photo, album and location categorization
|
||||||
type Label struct {
|
type Label struct {
|
||||||
ID uint `gorm:"primary_key" json:"ID" yaml:"-"`
|
ID uint `json:"ID"`
|
||||||
LabelUID string `gorm:"type:VARBINARY(42);unique_index;" json:"UID" yaml:"UID"`
|
LabelUID string `json:"UID"`
|
||||||
LabelSlug string `gorm:"type:VARBINARY(255);unique_index;" json:"Slug" yaml:"-"`
|
LabelSlug string `json:"Slug"`
|
||||||
CustomSlug string `gorm:"type:VARBINARY(255);index;" json:"CustomSlug" yaml:"-"`
|
CustomSlug string `json:"CustomSlug"`
|
||||||
LabelName string `gorm:"type:VARCHAR(255);" json:"Name" yaml:"Name"`
|
LabelName string `json:"Name"`
|
||||||
LabelPriority int `json:"Priority" yaml:"Priority,omitempty"`
|
LabelPriority int `json:"Priority"`
|
||||||
LabelFavorite bool `json:"Favorite" yaml:"Favorite,omitempty"`
|
LabelFavorite bool `json:"Favorite"`
|
||||||
LabelDescription string `gorm:"type:TEXT;" json:"Description" yaml:"Description,omitempty"`
|
LabelDescription string `json:"Description"`
|
||||||
LabelNotes string `gorm:"type:TEXT;" json:"Notes" yaml:"Notes,omitempty"`
|
LabelNotes string `json:"Notes"`
|
||||||
LabelCategories []*Label `gorm:"many2many:categories;association_jointable_foreignkey:category_id" json:"-" yaml:"-"`
|
PhotoCount int `json:"PhotoCount"`
|
||||||
PhotoCount int `gorm:"default:1" json:"PhotoCount" yaml:"-"`
|
LabelThumb string `json:"Thumb"`
|
||||||
CreatedAt time.Time `json:"CreatedAt" yaml:"-"`
|
CreatedAt time.Time `json:"CreatedAt"`
|
||||||
UpdatedAt time.Time `json:"UpdatedAt" yaml:"-"`
|
UpdatedAt time.Time `json:"UpdatedAt"`
|
||||||
DeletedAt *time.Time `sql:"index" json:"DeletedAt,omitempty" yaml:"-"`
|
|
||||||
New bool `gorm:"-" json:"-" yaml:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// FileInfos represents meta data about a file
|
|
||||||
type FileInfos struct {
|
|
||||||
FileWidth int
|
|
||||||
FileHeight int
|
|
||||||
FileOrientation int
|
|
||||||
FileAspectRatio float32
|
|
||||||
FileMainColor string
|
|
||||||
FileColors string
|
|
||||||
FileLuminance string
|
|
||||||
FileDiff uint32
|
|
||||||
FileChroma uint8
|
|
||||||
}
|
|
||||||
|
|
||||||
// Account represents a remote service account for uploading, downloading or syncing media files.
|
|
||||||
type Account struct {
|
|
||||||
ID uint `gorm:"primary_key"`
|
|
||||||
AccName string `gorm:"type:VARCHAR(255);"`
|
|
||||||
AccOwner string `gorm:"type:VARCHAR(255);"`
|
|
||||||
AccURL string `gorm:"type:VARBINARY(512);"`
|
|
||||||
AccType string `gorm:"type:VARBINARY(255);"`
|
|
||||||
AccKey string `gorm:"type:VARBINARY(255);"`
|
|
||||||
AccUser string `gorm:"type:VARBINARY(255);"`
|
|
||||||
AccPass string `gorm:"type:VARBINARY(255);"`
|
|
||||||
AccError string `gorm:"type:VARBINARY(512);"`
|
|
||||||
AccErrors int
|
|
||||||
AccShare bool
|
|
||||||
AccSync bool
|
|
||||||
RetryLimit int
|
|
||||||
SharePath string `gorm:"type:VARBINARY(500);"`
|
|
||||||
ShareSize string `gorm:"type:VARBINARY(16);"`
|
|
||||||
ShareExpires int
|
|
||||||
SyncPath string `gorm:"type:VARBINARY(500);"`
|
|
||||||
SyncStatus string `gorm:"type:VARBINARY(16);"`
|
|
||||||
SyncInterval int
|
|
||||||
SyncDate sql.NullTime `deepcopier:"skip"`
|
|
||||||
SyncUpload bool
|
|
||||||
SyncDownload bool
|
|
||||||
SyncFilenames bool
|
|
||||||
SyncRaw bool
|
|
||||||
CreatedAt time.Time `deepcopier:"skip"`
|
|
||||||
UpdatedAt time.Time `deepcopier:"skip"`
|
|
||||||
DeletedAt *time.Time `deepcopier:"skip" sql:"index"`
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue