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.

65 lines
1.8 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:"filepath"`
  37. Mimetype string `gorm:"not null" json:"mimetype"`
  38. Size int64 `gorm:"not null"`
  39. }
  40. type PostVideo struct {
  41. Base
  42. PostID uuid.UUID `gorm:"type:uuid;column:post_id;not null;" json:"post_id"`
  43. Filepath string `json:"filepath"`
  44. Mimetype string `json:"mimetype"`
  45. Size int64 `json:"size"`
  46. Url string `json:"url"`
  47. }
  48. type PostAudio struct {
  49. Base
  50. PostID uuid.UUID `gorm:"type:uuid;column:post_id;not null;" json:"post_id"`
  51. Filepath string `json:"filepath"`
  52. Mimetype string `json:"mimetype"`
  53. Size int64 `json:"size"`
  54. Url string `json:"url"`
  55. }