archive.go 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. package archive
  2. import (
  3. xtime "go-common/library/time"
  4. )
  5. //# state 稿件状态
  6. //# 0 开放浏览 , -1 待审 , -2 打回稿件回收站 , -3 网警锁定删除
  7. //# -4 锁定稿件 , -6 修复待审 , -7 暂缓审核 , -9 等待转码
  8. //# -10 延迟发布 , -11 视频源待修 , -13 允许评论待审 , -15 分发中
  9. //# -16 转码失败, -30 创建提交, -40 用户定时发布, -100 UP主删除
  10. //# attribute bit位置
  11. //# 右1 - norank 禁止排名 , 右2 - noindex 首页禁止 , 右3 - noweb 禁止网页端输出 , 右4 - nomobile 禁止移动端输出
  12. //# 右5 - nosearch 禁止移动端未登录搜索 , 右6 - overseas 海外禁止 , 右7 - nocount 不计算点击
  13. //# 右8 - hidecoins 禁止显示硬币 , 右9 - is_hdflv2 1080p 是否有高清1080p , 右10 - dm 是否允许游客发弹幕
  14. //# 右11 - allow_bp 是否允许投放bp , 右12 - 是否番剧 , 右13 - allow_download 是否允许下载
  15. //# 右14 - hideclick 是否隐藏点击数, 右15 - allow_tag 允许添加tag, 右16 - 是否api投稿
  16. //# 右17 - jump 是否跳转别的url, 右18 - 是否付费影视, 右19 - 付费标识
  17. //# access 会员状态
  18. //# 10000 普通会员 , 15000 新番搬运 , 20000 字幕君, 25000 VIP , 30000 真职人
  19. //# 35000 橙色通过开放浏览 , 40000 橙色通过会员浏览
  20. const (
  21. // StateOpen 开发浏览
  22. StateOpen = int8(0)
  23. // StateOrange 橙色通过
  24. StateOrange = int8(1)
  25. // StateForbidWait 待审
  26. StateForbidWait = int8(-1)
  27. // StateForbidRecicle 打回
  28. StateForbidRecicle = int8(-2)
  29. // StateForbidPolice 网警锁定
  30. StateForbidPolice = int8(-3)
  31. // StateForbidLock 被锁定
  32. StateForbidLock = int8(-4)
  33. // StateForbidFackLock 管理员锁定(可浏览)
  34. StateForbidFackLock = int8(-5)
  35. // StateForbidFixed 修复待审
  36. StateForbidFixed = int8(-6)
  37. // StateForbidLater 暂缓审核
  38. StateForbidLater = int8(-7)
  39. // StateForbidPatched 补档待审
  40. StateForbidPatched = int8(-8)
  41. // StateForbidWaitXcode 等待转码
  42. StateForbidWaitXcode = int8(-9)
  43. // StateForbidAdminDelay 延迟审核
  44. StateForbidAdminDelay = int8(-10)
  45. // StateForbidFixing 视频源待修
  46. StateForbidFixing = int8(-11)
  47. // StateForbidStorageFail 转储失败
  48. StateForbidStorageFail = int8(-12)
  49. // StateForbidOnlyComment 允许评论待审
  50. StateForbidOnlyComment = int8(-13)
  51. // StateForbidTmpRecicle 临时回收站
  52. StateForbidTmpRecicle = int8(-14)
  53. // StateForbidDispatch 分发中
  54. StateForbidDispatch = int8(-15)
  55. // StateForbidXcodeFail 转码失败
  56. StateForbidXcodeFail = int8(-16)
  57. // StateForbidSubmit 创建已提交
  58. StateForbidSubmit = int8(-30)
  59. // StateForbidUserDelay 定时发布
  60. StateForbidUserDelay = int8(-40)
  61. // StateForbidUpDelete 用户删除
  62. StateForbidUpDelete = int8(-100)
  63. // RoundBegin 一审阶段
  64. RoundBegin = int8(0)
  65. // RoundAuditSecond 二审:选定分区的多P稿件 及 PGC/活动的单P多P稿件
  66. RoundAuditSecond = int8(10)
  67. // RoundAuditThird 三审:选定分区/PGC/活动 的单P多P稿件
  68. RoundAuditThird = int8(20)
  69. // RoundReviewFlow 私单回查:私单ID大于0
  70. RoundReviewFlow = int8(21)
  71. //RoundAuditUGCPayFlow 付费待审
  72. RoundAuditUGCPayFlow = int8(24)
  73. // RoundReviewFirst 分区回查:粉丝小于配置阈值 如 5000 且 指定分区
  74. RoundReviewFirst = int8(30)
  75. // RoundReviewFirstWaitTrigger 点击/粉丝 等待触发中间状态,7天内达到阈值进列表,未达到自动变99
  76. RoundReviewFirstWaitTrigger = int8(31)
  77. // RoundReviewSecond 社区回查:粉丝大于配置阈值 如 5000 或 优质高危up
  78. RoundReviewSecond = int8(40)
  79. // RoundTriggerFans 粉丝回查:粉丝量达到配置阈值
  80. RoundTriggerFans = int8(80)
  81. // RoundTriggerClick 点击回查:点击量达到配置阈值
  82. RoundTriggerClick = int8(90)
  83. // RoundEnd 结束
  84. RoundEnd = int8(99)
  85. // AccessDefault 非会员可见
  86. AccessDefault = int16(0)
  87. // AccessMember 会员可见
  88. AccessMember = int16(10000)
  89. // CopyrightUnknow 未知版权类型
  90. CopyrightUnknow = int8(0)
  91. // CopyrightOriginal 原创
  92. CopyrightOriginal = int8(1)
  93. // CopyrightCopy 转载
  94. CopyrightCopy = int8(2)
  95. // AttrYes attribute yes
  96. AttrYes = int32(1)
  97. // AttrNo attribute no
  98. AttrNo = int32(0)
  99. // AttrBitNoRank 禁止排行
  100. AttrBitNoRank = uint(0)
  101. // AttrBitNoDynamic 动态禁止
  102. AttrBitNoDynamic = uint(1)
  103. // AttrBitNoWeb 禁止网页输出
  104. AttrBitNoWeb = uint(2)
  105. // AttrBitNoMobile 禁止客户端列表
  106. AttrBitNoMobile = uint(3)
  107. // AttrBitNoSearch 搜索禁止
  108. AttrBitNoSearch = uint(4)
  109. // AttrBitOverseaLock 海外禁止
  110. AttrBitOverseaLock = uint(5)
  111. // AttrBitNoRecommend 禁止推荐
  112. AttrBitNoRecommend = uint(6)
  113. // AttrBitNoReprint 禁止转载
  114. AttrBitNoReprint = uint(7)
  115. // AttrBitHasHD5 是否高清
  116. AttrBitHasHD5 = uint(8)
  117. // AttrBitIsPGC 是否PGC稿件
  118. AttrBitIsPGC = uint(9)
  119. // AttrBitAllowBp 允许承包
  120. AttrBitAllowBp = uint(10)
  121. // AttrBitIsBangumi 是否番剧
  122. AttrBitIsBangumi = uint(11)
  123. // AttrBitIsPorder 是否私单
  124. AttrBitIsPorder = uint(12)
  125. // AttrBitLimitArea 是否限制地区
  126. AttrBitLimitArea = uint(13)
  127. // AttrBitAllowTag 允许其他人添加tag
  128. AttrBitAllowTag = uint(14)
  129. // AttrBitIsFromArcAPI useless
  130. AttrBitIsFromArcAPI = uint(15)
  131. // AttrBitJumpURL 跳转
  132. AttrBitJumpURL = uint(16)
  133. // AttrBitIsMovie 是否影视
  134. AttrBitIsMovie = uint(17)
  135. // AttrBitBadgepay 付费
  136. AttrBitBadgepay = uint(18)
  137. //AttrNoPushBplus 禁止Bplus动态
  138. AttrNoPushBplus = uint(20)
  139. //AttrParentMode 家长模式
  140. AttrBitParentMode = uint(21)
  141. //AttrUGCPay UGC付费
  142. AttrBitUGCPay = uint(22)
  143. //AttrBitSTAFF 联合投稿
  144. AttrBitSTAFF = uint(24)
  145. STATESTAFFON = int8(1)
  146. STATESTAFFOFF = int8(2)
  147. )
  148. // Archive is archive model.
  149. type Archive struct {
  150. Aid int64 `json:"aid"`
  151. Mid int64 `json:"mid"`
  152. TypeID int16 `json:"tid"`
  153. Title string `json:"title"`
  154. Author string `json:"author"`
  155. Cover string `json:"cover"`
  156. Tag string `json:"tag"`
  157. Duration int64 `json:"duration"`
  158. Copyright int8 `json:"copyright"`
  159. Desc string `json:"desc"`
  160. Round int8 `json:"round"`
  161. Forward int64 `json:"forward"`
  162. Attribute int32 `json:"attribute"`
  163. HumanRank int `json:"humanrank"`
  164. Access int16 `json:"access"`
  165. State int8 `json:"state"`
  166. Reason string `json:"reject_reason"`
  167. PTime xtime.Time `json:"ptime"`
  168. CTime xtime.Time `json:"ctime"`
  169. MTime xtime.Time `json:"mtime"`
  170. }
  171. // Attr archive attribute
  172. type Attr int32
  173. // Set set archive attribute
  174. func (a *Attr) Set(v int32, bit uint) {
  175. *a = Attr(int32(*a)&(^(1 << bit)) | (v << bit))
  176. }
  177. // IsNormal check archive is open.
  178. func (a *Archive) IsNormal() bool {
  179. return a.State >= StateOpen || a.State == StateForbidFixed
  180. }
  181. // NotAllowUp check archive is or not allow update state.
  182. func (a *Archive) NotAllowUp() bool {
  183. return a.State == StateForbidUpDelete || a.State == StateForbidLater || a.State == StateForbidLock || a.State == StateForbidPolice
  184. }
  185. // IsForbid check archive state forbid by admin or delete.
  186. func (a *Archive) IsForbid() bool {
  187. return a.State == StateForbidUpDelete || a.State == StateForbidRecicle || a.State == StateForbidPolice || a.State == StateForbidLock || a.State == StateForbidLater || a.State == StateForbidXcodeFail
  188. }
  189. // AttrVal get attribute value.
  190. func (a *Archive) AttrVal(bit uint) int32 {
  191. return (a.Attribute >> bit) & int32(1)
  192. }
  193. // AttrSet set attribute value.
  194. func (a *Archive) AttrSet(v int32, bit uint) {
  195. a.Attribute = a.Attribute&(^(1 << bit)) | (v << bit)
  196. }
  197. // WithAttr set attribute value with a attr value.
  198. func (a *Archive) WithAttr(attr Attr) {
  199. a.Attribute = a.Attribute | int32(attr)
  200. }
  201. // NormalState check archive state is normal
  202. func NormalState(state int8) bool {
  203. return state == StateOpen || state == StateOrange
  204. }
  205. // History archive history model
  206. type History struct {
  207. Aid int64 `json:"aid"`
  208. Title string `json:"title"`
  209. Cover string `json:"cover"`
  210. Desc string `json:"desc"`
  211. State int8 `json:"state"`
  212. }
  213. // BlogCard 粉丝动态
  214. type BlogCard struct {
  215. Type int64 `json:"type"`
  216. //Stype int64 `json:"stype"`
  217. Rid int64 `json:"rid"`
  218. OwnerID int64 `json:"owner_id"`
  219. Show int64 `json:"show"`
  220. Comment string `json:"comment"`
  221. Ts int64 `json:"ts"`
  222. Dynamic string `json:"dynamic"`
  223. Ext string `json:"extension"`
  224. Staffs []*StaffItem `json:"staffs,omitempty"`
  225. }
  226. //StaffItem 联合投稿人信息 type=1
  227. type StaffItem struct {
  228. Type int8 `json:"uid_type"`
  229. UID int64 `json:"uid"`
  230. }
  231. //Staff . 正式staff
  232. type Staff struct {
  233. ID int64 `json:"id"`
  234. AID int64 `json:"aid"`
  235. MID int64 `json:"mid"`
  236. StaffMID int64 `json:"staff_mid"`
  237. StaffTitle string `json:"staff_title"`
  238. StaffTitleID int64 `json:"staff_title_id"`
  239. State int8 `json:"state"`
  240. }
  241. //Ext 动态 ext 配置
  242. type Ext struct {
  243. LBS string `json:"lbs_cfg"`
  244. Vote string `json:"vote_cfg"`
  245. }