cards.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package model
  2. import (
  3. "fmt"
  4. )
  5. // Cards
  6. const (
  7. CardPrefixBangumi = "ss"
  8. CardPrefixBangumiEp = "ep"
  9. CardPrefixTicket = "pw"
  10. CardPrefixMall = "sp"
  11. CardPrefixAudio = "au"
  12. CardPrefixArchive = "av"
  13. CardPrefixArticle = "cv"
  14. )
  15. // TicketCard .
  16. type TicketCard struct {
  17. ID int64 `json:"id"`
  18. Name string `json:"name"`
  19. Image string `json:"performance_image"`
  20. StartTime int64 `json:"start_time"`
  21. EndTime int64 `json:"end_time"`
  22. Province string `json:"province_name"`
  23. City string `json:"city_name"`
  24. District string `json:"district_name"`
  25. Venue string `json:"venue_name"`
  26. PriceLow float64 `json:"price_low"`
  27. URL string `json:"url"`
  28. }
  29. // MallCard .
  30. type MallCard struct {
  31. ID int64 `json:"itemsId"`
  32. Name string `json:"name"`
  33. Brief string `json:"brief"`
  34. Images []string `json:"img"`
  35. Price int64 `json:"price"`
  36. Type int `json:"type"`
  37. }
  38. // AudioCard .
  39. type AudioCard struct {
  40. ID int64 `json:"song_id"`
  41. Title string `json:"title"`
  42. UpMid int64 `json:"up_mid"`
  43. UpName string `json:"up_name"`
  44. Play int64 `json:"play_num"`
  45. Reply int64 `json:"reply_num"`
  46. CoverURL string `json:"cover_url"`
  47. }
  48. // BangumiCard .
  49. type BangumiCard struct {
  50. ID int64 `json:"season_id"`
  51. Type int64 `json:"season_type"`
  52. TypeName string `json:"season_type_name"`
  53. Image string `json:"cover"`
  54. Title string `json:"title"`
  55. Rating struct {
  56. Score float64 `json:"score"`
  57. Count int64 `json:"count"`
  58. } `json:"rating"`
  59. Playable bool `json:"playable"`
  60. FollowCount int64 `json:"follow_count"`
  61. PlayCount int64 `json:"play_count"`
  62. }
  63. // Cards .
  64. type Cards struct {
  65. Type string `json:"type,omitempty"`
  66. TicketCard *TicketCard `json:"ticket_card,omitempty"`
  67. BangumiCard *BangumiCard `json:"bangumi_card,omitempty"`
  68. MallCard *MallCard `json:"mall_card,omitempty"`
  69. AudioCard *AudioCard `json:"audio_card,omitempty"`
  70. }
  71. // Key .
  72. func (c *Cards) Key() string {
  73. var id int64
  74. if c.TicketCard != nil {
  75. id = c.TicketCard.ID
  76. } else if c.BangumiCard != nil {
  77. id = c.BangumiCard.ID
  78. } else if c.MallCard != nil {
  79. id = c.MallCard.ID
  80. } else if c.AudioCard != nil {
  81. id = c.AudioCard.ID
  82. }
  83. return fmt.Sprintf("%s%d", c.Type, id)
  84. }
  85. // Item .
  86. func (c *Cards) Item() interface{} {
  87. if c.TicketCard != nil {
  88. return c.TicketCard
  89. } else if c.BangumiCard != nil {
  90. return c.BangumiCard
  91. } else if c.MallCard != nil {
  92. return c.MallCard
  93. }
  94. return c.AudioCard.ID
  95. }