You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.9 KiB

package Models
import (
"time"
"github.com/gofrs/uuid"
)
type Post struct {
Base
UserID uuid.UUID `gorm:"type:uuid;column:user_id;not null;" json:"user_id"`
Title string `gorm:"not null" json:"title"`
Content string `gorm:"not null" json:"content"`
FrontPage bool `gorm:"not null;type:boolean" json:"front_page"`
Order int `gorm:"not null" json:"order"`
PublishedAt *time.Time `json:"published_at"`
PostLinks []PostLink `json:"links"`
PostImages []PostImage `json:"images"`
PostVideos []PostVideo `json:"videos"`
PostAudios []PostAudio `json:"audios"`
}
type PostLinkType string
const (
POST_LINK_FACEBOOK PostLinkType = "Facebook"
POST_LINK_INSTAGRAM PostLinkType = "Instagram"
POST_LINK_YOUTUBE PostLinkType = "YouTube"
POST_LINK_SPOTIFY PostLinkType = "Spotify"
POST_LINK_OTHER PostLinkType = "Other"
)
type PostLink struct {
Base
PostID uuid.UUID `gorm:"type:uuid;column:post_id;not null;" json:"post_id"`
Link string `gorm:"not null" json:"link"`
Type PostLinkType `gorm:"not null" json:"type"`
}
type PostImage struct {
Base
PostID uuid.UUID `gorm:"type:uuid;column:post_id;not null;" json:"post_id"`
Filepath string `gorm:"not null" json:"-"`
PublicFilepath string `gorm:"not null" json:"filepath"`
Mimetype string `gorm:"not null" json:"mimetype"`
Size int64 `gorm:"not null"`
}
type PostVideo struct {
Base
PostID uuid.UUID `gorm:"type:uuid;column:post_id;not null;" json:"post_id"`
Filepath string `json:"filepath"`
Mimetype string `json:"mimetype"`
Size int64 `json:"size"`
Url string `json:"url"`
}
type PostAudio struct {
Base
PostID uuid.UUID `gorm:"type:uuid;column:post_id;not null;" json:"post_id"`
Filepath string `json:"filepath"`
Mimetype string `json:"mimetype"`
Size int64 `json:"size"`
Url string `json:"url"`
}