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.

69 lines
2.1 KiB

  1. package Models
  2. import (
  3. "time"
  4. "github.com/gofrs/uuid"
  5. )
  6. type Post struct {
  7. Base
  8. UserID uuid.UUID `gorm:"type:uuid;column:user_id;not null;" json:"user_id"`
  9. Title string `gorm:"not null" json:"title"`
  10. Content string `gorm:"not null" json:"content"`
  11. FrontPage bool `gorm:"not null;type:boolean" json:"front_page"`
  12. Order int `gorm:"not null" json:"order"`
  13. PublishedAt *time.Time `json:"published_at"`
  14. PostLinks []PostLink `json:"links"`
  15. PostImages []PostImage `json:"images"`
  16. PostVideos []PostVideo `json:"videos"`
  17. PostAudios []PostAudio `json:"audios"`
  18. }
  19. type PostLinkType string
  20. const (
  21. POST_LINK_FACEBOOK PostLinkType = "Facebook"
  22. POST_LINK_INSTAGRAM PostLinkType = "Instagram"
  23. POST_LINK_YOUTUBE PostLinkType = "YouTube"
  24. POST_LINK_SPOTIFY PostLinkType = "Spotify"
  25. POST_LINK_OTHER PostLinkType = "Other"
  26. )
  27. type PostLink struct {
  28. Base
  29. PostID uuid.UUID `gorm:"type:uuid;column:post_id;not null;" json:"post_id"`
  30. Link string `gorm:"not null" json:"link"`
  31. Type PostLinkType `gorm:"not null" json:"type"`
  32. }
  33. type PostImage struct {
  34. Base
  35. PostID uuid.UUID `gorm:"type:uuid;column:post_id;not null;" json:"post_id"`
  36. Filepath string `gorm:"not null" json:"-"`
  37. PublicFilepath string `gorm:"not null" json:"filepath"`
  38. Mimetype string `gorm:"not null" json:"mimetype"`
  39. Size int64 `gorm:"not null"`
  40. Order int `gorm:"not null" json:"order"`
  41. }
  42. type PostVideo struct {
  43. Base
  44. PostID uuid.UUID `gorm:"type:uuid;column:post_id;not null;" json:"post_id"`
  45. Filepath string `json:"filepath"`
  46. Mimetype string `json:"mimetype"`
  47. Size int64 `json:"size"`
  48. Url string `json:"url"`
  49. Order int `gorm:"not null" json:"order"`
  50. }
  51. type PostAudio struct {
  52. Base
  53. PostID uuid.UUID `gorm:"type:uuid;column:post_id;not null;" json:"post_id"`
  54. Filepath string `json:"filepath"`
  55. Mimetype string `json:"mimetype"`
  56. Size int64 `json:"size"`
  57. Url string `json:"url"`
  58. Order int `gorm:"not null" json:"order"`
  59. }