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.

53 lines
1.4 KiB

  1. package Models
  2. import (
  3. "github.com/gofrs/uuid"
  4. )
  5. type Post struct {
  6. Base
  7. Title string `gorm:"not null" json:"title"`
  8. Content string `gorm:"not null" json:"content"`
  9. FrontPage bool `gorm:"not null;type:boolean" json:"front_page"`
  10. Order int `gorm:"not null" json:"order"`
  11. PostLinks []PostLink `json:"links"`
  12. PostImages []PostImage `json:"images"`
  13. PostVideos []PostVideo `json:"videos"`
  14. PostAudios []PostAudio `json:"audios"`
  15. }
  16. type PostLinkType string
  17. const (
  18. POST_LINK_FACEBOOK PostLinkType = "Facebook"
  19. POST_LINK_INSTAGRAM PostLinkType = "Instagram"
  20. POST_LINK_YOUTUBE PostLinkType = "YouTube"
  21. POST_LINK_SPOTIFY PostLinkType = "Spotify"
  22. POST_LINK_OTHER PostLinkType = "Other"
  23. )
  24. type PostLink struct {
  25. Base
  26. PostID uuid.UUID `gorm:"type:uuid;column:post_foreign_key;not null;" json:"post_id"`
  27. Link string `gorm:"not null" json:"link"`
  28. Type PostLinkType `gorm:"not null" json:"type"`
  29. }
  30. type PostImage struct {
  31. Base
  32. PostID uuid.UUID `gorm:"type:uuid;column:post_foreign_key;not null;" json:"post_id"`
  33. Filepath string `gorm:"not null" json:"filepath"`
  34. }
  35. type PostVideo struct {
  36. Base
  37. PostID uuid.UUID `gorm:"type:uuid;column:post_foreign_key;not null;" json:"post_id"`
  38. Filepath string `gorm:"not null" json:"filepath"`
  39. }
  40. type PostAudio struct {
  41. Base
  42. PostID uuid.UUID `gorm:"type:uuid;column:post_foreign_key;not null;" json:"post_id"`
  43. Filepath string `gorm:"not null" json:"filepath"`
  44. }