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.

62 lines
1.8 KiB

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