Image Saving & Serving
This commit is contained in:
@@ -8,10 +8,10 @@ import (
|
||||
|
||||
// Base contains common columns for all tables.
|
||||
type Base struct {
|
||||
UUID uuid.UUID `gorm:"type:uuid;primarykey"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||
UUID uuid.UUID `json:"uuid" gorm:"type:uuid;primarykey"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
|
||||
}
|
||||
|
||||
func (base *Base) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
@@ -21,48 +21,49 @@ func (base *Base) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
|
||||
type ServerSetting struct {
|
||||
Base
|
||||
Name string `json:"name" gorm:"not null"`
|
||||
Name string `json:"name" gorm:"not null"`
|
||||
Description string `json:"description" gorm:"not null"`
|
||||
Value string `json:"value" gorm:"not null"`
|
||||
Value string `json:"value" gorm:"not null"`
|
||||
}
|
||||
|
||||
type Device struct {
|
||||
Base
|
||||
User User `json:"user" gorm:"ForeignKey:UUID;not null"`
|
||||
Name string `json:"name" gorm:"not null"`
|
||||
Type string `json:"type" gorm:"not null"` // Android, iOS, Chrome, FireFox, Edge, etc
|
||||
RefreshKey string `json:"-"`
|
||||
User User `json:"user" gorm:"ForeignKey:UUID;not null"` // User UUID
|
||||
Name string `json:"name" gorm:"not null"` // Name of Device
|
||||
Type string `json:"type" gorm:"not null"` // Android, iOS, Chrome, FireFox, Edge
|
||||
RefreshKey string `json:"-"` // Device Specific Refresh Key
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Base
|
||||
Email string `json:"email" gorm:"unique"`
|
||||
Username string `json:"username" gorm:"unique"`
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
Role string `json:"role"`
|
||||
AuthType string `json:"auth_type" gorm:"default:Local;not null"`
|
||||
Password string `json:"-"`
|
||||
Email string `json:"email" gorm:"unique"` // Email
|
||||
Username string `json:"username" gorm:"unique"` // Username
|
||||
FirstName string `json:"first_name"` // First Name
|
||||
LastName string `json:"last_name"` // Last Name
|
||||
Role string `json:"role"` // Role
|
||||
AuthType string `json:"auth_type" gorm:"default:Local;not null"` // Auth Type (E.g. Local, LDAP)
|
||||
Password string `json:"-"` // Hased & Salted Password
|
||||
}
|
||||
|
||||
type MediaItem struct {
|
||||
Base
|
||||
User User `json:"user" gorm:"ForeignKey:UUID;not null"`
|
||||
EXIFDate time.Time `json:"exif_date"`
|
||||
Latitude string `json:"latitude"`
|
||||
Longitude string `json:"longitude"`
|
||||
MediaType string `json:"media_type" gorm:"default:Image;not null"` // Image, Video
|
||||
RelPath string `json:"rel_path" gorm:"not null"`
|
||||
Tags []Tag `json:"tags" gorm:"many2many:media_tags;"`
|
||||
Albums []Album `json:"albums" gorm:"many2many:media_albums;"`
|
||||
User User `json:"user" gorm:"ForeignKey:UUID;not null"` // User UUID
|
||||
EXIFDate time.Time `json:"exif_date"` // EXIF Date
|
||||
Latitude float32 `json:"latitude" gorm:"type:decimal(10,2)"` // Decimal Latitude
|
||||
Longitude float32 `json:"longitude" gorm:"type:decimal(10,2)"` // Decimal Longitude
|
||||
MediaType string `json:"media_type" gorm:"default:Image;not null"` // Image, Video
|
||||
OrigName string `json:"orig_name" gorm:"not null"` // Original Name
|
||||
FileName string `json:"file_name" gorm:"not null"` // File Name
|
||||
Tags []Tag `json:"tags" gorm:"many2many:media_tags;"` // Associated Tag UUIDs
|
||||
Albums []Album `json:"albums" gorm:"many2many:media_albums;"` // Associated Album UUIDs
|
||||
}
|
||||
|
||||
type Tag struct {
|
||||
Base
|
||||
Name string `json:"name" gorm:"not null"`
|
||||
Name string `json:"name" gorm:"not null"` // Tag Name
|
||||
}
|
||||
|
||||
type Album struct {
|
||||
Base
|
||||
Name string `json:"name" gorm:"not null"`
|
||||
Name string `json:"name" gorm:"not null"` // Album Name
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user