creation.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. package model
  2. import (
  3. "go-common/app/interface/main/creative/model/data"
  4. "go-common/library/time"
  5. )
  6. // const
  7. const (
  8. // ReprintForbid 禁止转载.
  9. ReprintForbid = int8(0)
  10. // ReprintAllow 允许规范转载.
  11. ReprintAllow = int8(1)
  12. // NoImage 无图.
  13. ///NoImage = int8(1)
  14. // HeadImage 头图.
  15. HeadImage = int8(4)
  16. )
  17. var (
  18. _reprint = map[int8]int8{
  19. ReprintForbid: ReprintForbid,
  20. ReprintAllow: ReprintAllow,
  21. }
  22. _tid = map[int8]int8{
  23. TemplateText: 0,
  24. TemplateSingleImg: 1,
  25. TemplateMultiImg: 3,
  26. TemplateSingleBigImg: 1,
  27. }
  28. )
  29. // InReprints check reprint in all reprints.
  30. func InReprints(rp int8) (ok bool) {
  31. _, ok = _reprint[rp]
  32. return
  33. }
  34. // InTemplateID check tid in all tids.
  35. func InTemplateID(tid int8) (ok bool) {
  36. _, ok = _tid[tid]
  37. return
  38. }
  39. // ValidTemplate checks template id & images count.
  40. func ValidTemplate(tid int32, imgs []string) bool {
  41. var images []string
  42. for _, image := range imgs {
  43. if image != "" {
  44. images = append(images, image)
  45. }
  46. }
  47. return len(images) == int(_tid[int8(tid)])
  48. }
  49. // UpStat for bigdata article up stat
  50. type UpStat struct {
  51. View int64 `json:"view"`
  52. Reply int64 `json:"reply"`
  53. Like int64 `json:"like"`
  54. Coin int64 `json:"coin"`
  55. Fav int64 `json:"fav"`
  56. Share int64 `json:"share"`
  57. PreView int64 `json:"-"`
  58. PreReply int64 `json:"-"`
  59. PreLike int64 `json:"-"`
  60. PreCoin int64 `json:"-"`
  61. PreFav int64 `json:"-"`
  62. PreShare int64 `json:"-"`
  63. IncrView int64 `json:"incr_view"`
  64. IncrReply int64 `json:"incr_reply"`
  65. IncrLike int64 `json:"incr_like"`
  66. IncrCoin int64 `json:"incr_coin"`
  67. IncrFav int64 `json:"incr_fav"`
  68. IncrShare int64 `json:"incr_share"`
  69. }
  70. // ThirtyDayArticle for article 30 days data.
  71. type ThirtyDayArticle struct {
  72. Category string `json:"category"`
  73. ThirtyDay []*data.ThirtyDay `json:"thirty_day"`
  74. }
  75. // ArtParam param for article info input.
  76. type ArtParam struct {
  77. AID int64 `json:"aid"`
  78. MID int64 `json:"mid"`
  79. Category int64 `json:"category"`
  80. State int32 `json:"state"`
  81. Reprint int32 `json:"reprint"`
  82. TemplateID int32 `json:"tid"`
  83. Title string `json:"title"`
  84. BannerURL string `json:"banner_url"`
  85. Content string `json:"content"`
  86. Summary string `json:"summary"`
  87. Tags string `json:"tags"`
  88. ImageURLs []string `json:"image_urls"`
  89. OriginImageURLs []string `json:"origin_image_urls"`
  90. RealIP string `json:"-"`
  91. Action int `json:"action"`
  92. Words int64 `json:"words"`
  93. DynamicIntro string `json:"dynamic_intro"`
  94. ActivityID int64 `json:"activity_id"`
  95. ListID int64 `json:"list_id"`
  96. MediaID int64 `json:"media_id"`
  97. Spoiler int32 `json:"spoiler"`
  98. }
  99. // CreativeMeta article detail.
  100. type CreativeMeta struct {
  101. ID int64 `json:"id"`
  102. Title string `json:"title"`
  103. Content string `json:"content"`
  104. Summary string `json:"summary"`
  105. BannerURL string `json:"banner_url"`
  106. Reason string `json:"reason"`
  107. TemplateID int32 `json:"template_id"`
  108. State int32 `json:"state"`
  109. Reprint int32 `json:"reprint"`
  110. ImageURLs []string `json:"image_urls"`
  111. OriginImageURLs []string `json:"origin_image_urls"`
  112. Tags []string `json:"tags"`
  113. Category *Category `json:"category"`
  114. Author *Author `json:"author"`
  115. Stats *Stats `json:"stats"`
  116. PTime time.Time `json:"publish_time"`
  117. CTime time.Time `json:"ctime"`
  118. MTime time.Time `json:"mtime"`
  119. ViewURL string `json:"view_url"`
  120. EditURL string `json:"edit_url"`
  121. IsPreview int `json:"is_preview"`
  122. DynamicIntro string `json:"dynamic_intro"`
  123. List *List `json:"list"`
  124. MediaID int64 `json:"media_id"`
  125. Spoiler int32 `json:"spoiler"`
  126. EditTimes int `json:"edit_times"`
  127. PreViewURL string `json:"pre_view_url"`
  128. }
  129. // CreativeArtList article for list.
  130. type CreativeArtList struct {
  131. Articles []*CreativeMeta `json:"articles"`
  132. Type *CreationArtsType `json:"type"`
  133. Page *ArtPage `json:"page"`
  134. }
  135. // CreativeDraftList draft list.
  136. type CreativeDraftList struct {
  137. Drafts []*CreativeMeta `json:"drafts"`
  138. Page *ArtPage `json:"page"`
  139. DraftURL string `json:"draft_url"`
  140. }
  141. // ExtMsg .
  142. type ExtMsg struct {
  143. Tags []*Tag `json:"tags"`
  144. }