list.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package model
  2. import xtime "go-common/library/time"
  3. // sort type
  4. const (
  5. ListSortPtime = 0
  6. ListSortView = 1
  7. )
  8. // CreativeList creative list
  9. type CreativeList struct {
  10. *List
  11. Total int `json:"total"`
  12. }
  13. // ListArtMeta .
  14. type ListArtMeta struct {
  15. ID int64 `json:"id"`
  16. Title string `json:"title"`
  17. State int `json:"state"`
  18. PublishTime xtime.Time `json:"publish_time"`
  19. Position int `json:"-"`
  20. Words int64 `json:"words"`
  21. ImageURLs []string `json:"image_urls"`
  22. Category *Category `json:"category"`
  23. Categories []*Category `json:"categories"`
  24. Summary string `json:"summary"`
  25. }
  26. // Strong fill
  27. func (a *ListArtMeta) Strong() {
  28. if a == nil {
  29. return
  30. }
  31. if a.ImageURLs == nil {
  32. a.ImageURLs = []string{}
  33. }
  34. if a.Category == nil {
  35. a.Category = &Category{}
  36. }
  37. if a.Categories == nil {
  38. a.Categories = []*Category{}
  39. }
  40. }
  41. // FullListArtMeta .
  42. type FullListArtMeta struct {
  43. *ListArtMeta
  44. Stats Stats `json:"stats"`
  45. LikeState int8 `json:"like_state"`
  46. }
  47. // IsNormal judge whether article's state is normal.
  48. func (a *ListArtMeta) IsNormal() bool {
  49. return (a != nil) && (a.State >= StateOpen)
  50. }
  51. // ListArticles list articles
  52. type ListArticles struct {
  53. List *List `json:"list"`
  54. Articles []*ListArtMeta `json:"articles"`
  55. Author *Author `json:"author"`
  56. Last ListArtMeta `json:"last"`
  57. Attention bool `json:"attention"`
  58. }
  59. // WebListArticles .
  60. type WebListArticles struct {
  61. List *List `json:"list"`
  62. Articles []*FullListArtMeta `json:"articles"`
  63. Author *Author `json:"author"`
  64. Last ListArtMeta `json:"last"`
  65. Attention bool `json:"attention"`
  66. }
  67. // ListInfo list info
  68. type ListInfo struct {
  69. List *List `json:"list"`
  70. Last *ListArtMeta `json:"last"`
  71. Next *ListArtMeta `json:"next"`
  72. Now int `json:"now"`
  73. Total int `json:"total"`
  74. }
  75. // UpLists .
  76. type UpLists struct {
  77. Lists []*List `json:"lists"`
  78. Total int `json:"total"`
  79. }