model.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. package model
  2. import (
  3. "encoding/json"
  4. "time"
  5. "go-common/app/service/main/archive/api"
  6. relmdl "go-common/app/service/main/relation/model"
  7. )
  8. const (
  9. // PushTypeUnknown 用户未上报推送设置
  10. PushTypeUnknown = iota
  11. // PushTypeForbid 禁止推送稿件更新通知
  12. PushTypeForbid
  13. // PushTypeSpecial 推送特别关注的upper的更新
  14. PushTypeSpecial
  15. // PushTypeAttention 推送关注的upper的更新
  16. PushTypeAttention
  17. )
  18. const (
  19. // RelationAttention 关注
  20. RelationAttention = iota + 1
  21. // RelationSpecial 特别关注
  22. RelationSpecial
  23. )
  24. const (
  25. // StatisticsUnpush 命中分组但未推送
  26. StatisticsUnpush = iota
  27. // StatisticsPush 命中分组且推送
  28. StatisticsPush = 1
  29. )
  30. const (
  31. // GroupDataTypeDefault 默认
  32. GroupDataTypeDefault = "default"
  33. // GroupDataTypeHBase AI脚本提供的hbase数据
  34. GroupDataTypeHBase = "hbase"
  35. // GroupDataTypeAbtest ab实验数据
  36. GroupDataTypeAbtest = "ab_test"
  37. // GroupDataTypeAbComparison ab对照数据
  38. GroupDataTypeAbComparison = "ab_comparison"
  39. )
  40. const (
  41. // AttrBitIsPGC pgc稿件的属性位
  42. AttrBitIsPGC = 9
  43. )
  44. // Setting user push setting.
  45. type Setting struct {
  46. Type int `json:"type"`
  47. }
  48. // Message canal databus message.
  49. type Message struct {
  50. Action string `json:"action"`
  51. Table string `json:"table"`
  52. New json.RawMessage `json:"new"`
  53. Old json.RawMessage `json:"old"`
  54. }
  55. // Relation user relation.
  56. type Relation struct {
  57. Mid int64 `json:"mid,omitempty"`
  58. Fid int64 `json:"fid,omitempty"`
  59. Attribute uint32 `json:"attribute"`
  60. Status int `json:"status"`
  61. MTime string `json:"mtime"`
  62. CTime string `json:"ctime"`
  63. }
  64. // Following judge that whether has following relation.
  65. func (r *Relation) Following() bool {
  66. attr := relmdl.Following{Attribute: r.Attribute}
  67. return attr.Following()
  68. }
  69. // RelationTagUser user relatino tag.
  70. type RelationTagUser struct {
  71. Mid int64 `json:"mid,omitempty"`
  72. Fid int64 `json:"fid,omitempty"`
  73. Tag string `json:"tag"`
  74. MTime string `json:"mtime"`
  75. CTime string `json:"ctime"`
  76. }
  77. // HasTag judge that whether has specified tag.
  78. func (r *RelationTagUser) HasTag(tag int64) bool {
  79. i := new(Ints)
  80. i.Scan([]byte(r.Tag))
  81. return i.Exist(tag)
  82. }
  83. // Archive model
  84. type Archive struct {
  85. ID int64 `json:"aid"`
  86. Mid int64 `json:"mid"`
  87. TypeID int16 `json:"typeid"`
  88. HumanRank int `json:"humanrank"`
  89. Duration int `json:"duration"`
  90. Title string `json:"title"`
  91. Cover string `json:"cover"`
  92. Content string `json:"content"`
  93. Tag string `json:"tag"`
  94. Attribute int32 `json:"attribute"`
  95. Copyright int8 `json:"copyright"`
  96. AreaLimit int8 `json:"arealimit"`
  97. State int `json:"state"`
  98. Author string `json:"author"`
  99. Access int `json:"access"`
  100. Forward int `json:"forward"`
  101. PubTime string `json:"pubtime"`
  102. Round int8 `json:"round"`
  103. CTime string `json:"ctime"`
  104. MTime string `json:"mtime"`
  105. }
  106. // IsNormal judge that whether archive's state is normally.
  107. func (a *Archive) IsNormal() bool {
  108. arc := api.Arc{State: int32(a.State)}
  109. return arc.IsNormal()
  110. }
  111. // PushStatistic 推送统计数据对象
  112. type PushStatistic struct {
  113. Aid int64 `json:"aid"`
  114. Group string `json:"group"`
  115. Type int `json:"type"`
  116. Mids string `json:"mids"`
  117. MidsCounter int `json:"mids_counter"`
  118. CTime time.Time `json:"ctime"`
  119. }