2019-12-11 16:55:18 +01:00
|
|
|
package entity
|
2019-06-17 06:04:29 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/jinzhu/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Shared photos and/or albums
|
|
|
|
type Share struct {
|
2019-12-27 05:18:52 +01:00
|
|
|
UUID string `gorm:"type:varbinary(36);primary_key;auto_increment:false"`
|
|
|
|
ShareUUID string `gorm:"type:varbinary(36);index;"`
|
2019-06-17 06:43:59 +02:00
|
|
|
ShareViews uint
|
2019-12-06 10:26:57 +01:00
|
|
|
ShareUrl string `gorm:"type:varchar(64);"`
|
2019-12-27 05:18:52 +01:00
|
|
|
SharePassword string `gorm:"type:varbinary(200);"`
|
2019-06-17 06:04:29 +02:00
|
|
|
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 {
|
2019-12-27 05:18:52 +01:00
|
|
|
if err := scope.SetColumn("ShareUUID", ID('s')); err != nil {
|
2019-12-06 10:26:57 +01:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
2019-06-17 06:04:29 +02:00
|
|
|
}
|