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.

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