2019-06-17 06:04:29 +02:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/jinzhu/gorm"
|
|
|
|
|
|
|
|
uuid "github.com/satori/go.uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Shared photos and/or albums
|
|
|
|
type Share struct {
|
|
|
|
ShareUUID string `gorm:"primary_key;auto_increment:false"`
|
|
|
|
PhotoID uint
|
|
|
|
AlbumID uint
|
2019-06-17 06:43:59 +02:00
|
|
|
ShareViews uint
|
2019-06-17 06:04:29 +02:00
|
|
|
ShareSecret string
|
|
|
|
SharePassword string
|
|
|
|
ShareExpires time.Time
|
|
|
|
Photo *Photo
|
|
|
|
Album *Album
|
2019-06-17 07:19:44 +02:00
|
|
|
CreatedAt time.Time
|
|
|
|
UpdatedAt time.Time
|
|
|
|
DeletedAt *time.Time `sql:"index"`
|
2019-06-17 06:04:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (Share) TableName() string {
|
|
|
|
return "shares"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Share) BeforeCreate(scope *gorm.Scope) error {
|
|
|
|
return scope.SetColumn("ShareUUID", uuid.NewV4().String())
|
|
|
|
}
|