archive.go 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. package archive
  2. import (
  3. "sync"
  4. "time"
  5. )
  6. const (
  7. //StateOpen state open
  8. StateOpen = 0
  9. //StateOrange 橙色通过
  10. StateOrange = 1
  11. //StateForbidWait 待审
  12. StateForbidWait = -1
  13. //StateForbidRecicle 打回
  14. StateForbidRecicle = -2
  15. //StateForbidPolice 网警锁定
  16. StateForbidPolice = -3
  17. //StateForbidLock 锁定
  18. StateForbidLock = -4
  19. //StateForbidFixed 修复待审
  20. StateForbidFixed = -6
  21. //StateForbidLater 暂缓待审
  22. StateForbidLater = -7
  23. //StateForbidXcodeFail 转码失败
  24. StateForbidXcodeFail = -16
  25. //StateForbidSubmit 创建提交
  26. StateForbidSubmit = -30
  27. //StateForbidUserDelay 定时
  28. StateForbidUserDelay = -40
  29. //StateForbidUpDelete 删除
  30. StateForbidUpDelete = -100
  31. //RoundBegin 开始流转
  32. RoundBegin = 0
  33. //RoundAuditSecond 二审:选定分区的多P稿件 及 PGC/活动的单P多P稿件
  34. RoundAuditSecond = 10
  35. //RoundAuditThird 三审:选定分区/PGC/活动 的单P多P稿件
  36. RoundAuditThird = 20
  37. //RoundReviewFirst 分区回查:粉丝小于配置阈值 如 5000 且 指定分区
  38. RoundReviewFirst = 30
  39. //RoundReviewFirstWaitTrigger 点击/粉丝 等待触发中间状态,7天内达到阈值进列表,未达到自动变99
  40. RoundReviewFirstWaitTrigger = 31
  41. //RoundReviewSecond 社区回查:粉丝大于配置阈值 如 5000 或 优质高危up
  42. RoundReviewSecond = 40
  43. //RoundTriggerFans 粉丝回查:粉丝量达到配置阈值
  44. RoundTriggerFans = 80
  45. //RoundTriggerClick 点击回查:点击量达到配置阈值
  46. RoundTriggerClick = 90
  47. //RoundEnd 流转结束
  48. RoundEnd = 99
  49. //AccessDefault access
  50. AccessDefault = int16(0)
  51. //AccessMember 会员可见
  52. AccessMember = int16(10000)
  53. //CopyrightUnknow copyright
  54. CopyrightUnknow = 0
  55. //CopyrightOriginal 原创
  56. CopyrightOriginal = 1
  57. //CopyrightCopy 转载
  58. CopyrightCopy = 2
  59. //AttrYes attribute yes
  60. AttrYes = int32(1)
  61. //AttrNo attribute no
  62. AttrNo = int32(0)
  63. //AttrBitNoRank 禁止排序
  64. AttrBitNoRank = uint(0)
  65. //AttrBitNoDynamic 禁止动态
  66. AttrBitNoDynamic = uint(1)
  67. //AttrBitNoWeb 禁止web
  68. AttrBitNoWeb = uint(2)
  69. //AttrBitNoMobile 禁止手机端
  70. AttrBitNoMobile = uint(3)
  71. //AttrBitNoSearch 禁止搜索
  72. AttrBitNoSearch = uint(4)
  73. //AttrBitOverseaLock 禁止海外
  74. AttrBitOverseaLock = uint(5)
  75. //AttrBitNoRecommend 禁止推荐
  76. AttrBitNoRecommend = uint(6)
  77. // AttrBitHideCoins = uint(7)
  78. //AttrBitHasHD5 是否高清
  79. AttrBitHasHD5 = uint(8)
  80. // AttrBitVisitorDm = uint(9)
  81. //AttrBitAllowBp 允许承包
  82. AttrBitAllowBp = uint(10)
  83. //AttrBitIsBangumi 番剧
  84. AttrBitIsBangumi = uint(11)
  85. //AttrBitIsPOrder 是否私单
  86. AttrBitIsPOrder = uint(12)
  87. //AttrBitHideClick 点击
  88. AttrBitHideClick = uint(13)
  89. //AttrBitAllowTag 允许操作tag
  90. AttrBitAllowTag = uint(14)
  91. // AttrBitIsFromArcApi = uint(15)
  92. //AttrBitJumpURL 跳转
  93. AttrBitJumpURL = uint(16)
  94. //AttrBitIsMovie is movie
  95. AttrBitIsMovie = uint(17)
  96. //AttrBitBadgepay 付费
  97. AttrBitBadgepay = uint(18)
  98. //ReplyDefault 默认评论状态
  99. ReplyDefault = int64(-1)
  100. //ReplyOn 开评论
  101. ReplyOn = int64(0)
  102. //ReplyOff 关评论
  103. ReplyOff = int64(1)
  104. //LogBusJob 稿件后台任务日志bus
  105. LogBusJob = 211
  106. //LogTypeReply 稿件后台任务type评论
  107. LogTypeReply = 1
  108. )
  109. //ReplyState 评论开关状态
  110. var ReplyState = []int64{
  111. ReplyDefault,
  112. ReplyOn,
  113. ReplyOff,
  114. }
  115. //ReplyDesc 评论状态描述
  116. var ReplyDesc = map[int64]string{
  117. ReplyDefault: "未知状态",
  118. ReplyOn: "开",
  119. ReplyOff: "关",
  120. }
  121. //UpInfo up info
  122. type UpInfo struct {
  123. Nw *Archive
  124. Old *Archive
  125. }
  126. // Oper is archive operate model.
  127. type Oper struct {
  128. ID int64 `json:"id"`
  129. AID int64 `json:"aid"`
  130. UID int64 `json:"uid"`
  131. TypeID int16 `json:"typeid"`
  132. State int `json:"state"`
  133. Content string `json:"-"`
  134. Round int8 `json:"round"`
  135. Attribute int32 `json:"attribute"`
  136. LastID int64 `json:"last_id"`
  137. Remark string `json:"-"`
  138. CTime time.Time `json:"ctime"`
  139. MTime time.Time `json:"mtime"`
  140. }
  141. // ArcMoveTypeCache archive move typeid count
  142. type ArcMoveTypeCache struct {
  143. Data map[int8]map[int16]map[string]int
  144. sync.Mutex
  145. }
  146. // ArcRoundFlowCache archive round flow record
  147. type ArcRoundFlowCache struct {
  148. Data map[int8]map[int64]map[string]int
  149. sync.Mutex
  150. }
  151. //Archive archive
  152. type Archive struct {
  153. ID int64 `json:"id"`
  154. AID int64 `json:"aid"` //result库binlog={id:0,aid:xxx}
  155. Mid int64 `json:"mid"`
  156. TypeID int16 `json:"typeid"`
  157. HumanRank int `json:"humanrank"`
  158. Duration int `json:"duration"`
  159. Desc string `json:"desc"`
  160. Title string `json:"title"`
  161. Cover string `json:"cover"`
  162. Content string `json:"content"`
  163. Tag string `json:"tag"`
  164. Attribute int32 `json:"attribute"`
  165. Copyright int8 `json:"copyright"`
  166. AreaLimit int8 `json:"arealimit"`
  167. State int `json:"state"`
  168. Author string `json:"author"`
  169. Access int `json:"access"`
  170. Forward int `json:"forward"`
  171. PubTime string `json:"pubtime"`
  172. Reason string `json:"reject_reason"`
  173. Round int8 `json:"round"`
  174. CTime string `json:"ctime"`
  175. MTime string `json:"mtime"`
  176. PTime string `json:"ptime"`
  177. }
  178. //IsSyncState can archive sync
  179. func (a *Archive) IsSyncState() bool {
  180. if a.State >= 0 || a.State == StateForbidUserDelay || a.State == StateForbidUpDelete || a.State == StateForbidRecicle || a.State == StateForbidPolice ||
  181. a.State == StateForbidLock {
  182. return true
  183. }
  184. return false
  185. }
  186. //ArgStat arg state
  187. type ArgStat struct {
  188. Aid int64
  189. Field int
  190. Value int
  191. RealIP string
  192. }
  193. // AttrVal get attribute value.
  194. func (a *Archive) AttrVal(bit uint) int32 {
  195. return (a.Attribute >> bit) & int32(1)
  196. }
  197. //NormalState normal state
  198. func NormalState(state int) bool {
  199. return state == StateOpen || state == StateOrange
  200. }
  201. //Type archive_type
  202. type Type struct {
  203. ID int16 `json:"id"`
  204. PID int16 `json:"pid"`
  205. Name string `json:"name"`
  206. }
  207. // StateMean the mean for archive state
  208. var StateMean = map[int]string{
  209. StateOpen: "开放浏览",
  210. StateOrange: "橙色通过",
  211. // forbid state
  212. StateForbidWait: "待审",
  213. StateForbidRecicle: "打回",
  214. StateForbidPolice: "网警锁定",
  215. StateForbidLock: "锁定稿件",
  216. StateForbidFixed: "修复待审",
  217. StateForbidLater: "暂缓审核",
  218. //StateForbidAdminDelay: "延迟发布",
  219. StateForbidXcodeFail: "转码失败",
  220. StateForbidSubmit: "创建提交",
  221. StateForbidUserDelay: "用户定时发布",
  222. StateForbidUpDelete: "UP主删除",
  223. }