article.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package model
  2. import (
  3. artmdl "go-common/app/interface/openplatform/article/model"
  4. accmdl "go-common/app/service/main/account/model"
  5. "go-common/library/time"
  6. "strconv"
  7. )
  8. // Info struct.
  9. type Info struct {
  10. Mid string `json:"mid"`
  11. Name string `json:"uname"`
  12. Sex string `json:"sex"`
  13. Sign string `json:"sign"`
  14. Avatar string `json:"avatar"`
  15. Rank string `json:"rank"`
  16. DisplayRank string `json:"DisplayRank"`
  17. LevelInfo struct {
  18. Cur int `json:"current_level"`
  19. Min int `json:"current_min"`
  20. NowExp int `json:"current_exp"`
  21. NextExp interface{} `json:"next_exp"`
  22. } `json:"level_info"`
  23. Pendant accmdl.PendantInfo `json:"pendant"`
  24. Nameplate accmdl.NameplateInfo `json:"nameplate"`
  25. OfficialVerify struct {
  26. Type int `json:"type"`
  27. Desc string `json:"desc"`
  28. } `json:"official_verify"`
  29. Vip struct {
  30. Type int `json:"vipType"`
  31. DueDate int64 `json:"vipDueDate"`
  32. DueRemark string `json:"dueRemark"`
  33. AccessStatus int `json:"accessStatus"`
  34. VipStatus int `json:"vipStatus"`
  35. VipStatusWarn string `json:"vipStatusWarn"`
  36. } `json:"vip"`
  37. // article
  38. ID int64 `json:"id"`
  39. Title string `json:"title"`
  40. PublishTime time.Time `json:"publish_time"`
  41. Following bool `json:"following"`
  42. }
  43. // FromCard from card.
  44. func (i *Info) FromCard(c *accmdl.Card) {
  45. i.Mid = strconv.FormatInt(c.Mid, 10)
  46. i.Name = c.Name
  47. i.Sex = c.Sex
  48. i.Sign = c.Sign
  49. i.Avatar = c.Face
  50. i.Rank = strconv.FormatInt(int64(c.Rank), 10)
  51. i.DisplayRank = "0"
  52. i.LevelInfo.Cur = int(c.Level)
  53. i.LevelInfo.NextExp = 0
  54. // i.LevelInfo.Min =
  55. i.Pendant = c.Pendant
  56. i.Nameplate = c.Nameplate
  57. if c.Official.Role == 0 {
  58. i.OfficialVerify.Type = -1
  59. } else {
  60. if c.Official.Role <= 2 {
  61. i.OfficialVerify.Type = 0
  62. i.OfficialVerify.Desc = c.Official.Title
  63. } else {
  64. i.OfficialVerify.Type = 1
  65. i.OfficialVerify.Desc = c.Official.Title
  66. }
  67. }
  68. i.Vip.Type = int(c.Vip.Type)
  69. i.Vip.VipStatus = int(c.Vip.Status)
  70. i.Vip.DueDate = c.Vip.DueDate
  71. }
  72. // Meta struct.
  73. type Meta struct {
  74. *artmdl.Meta
  75. Like int `json:"like"`
  76. }
  77. // ArticleUpInfo struct.
  78. type ArticleUpInfo struct {
  79. ArtCount int `json:"art_count"`
  80. Follower int64 `json:"follower"`
  81. IsFollowing bool `json:"is_following"`
  82. }