dm.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. package model
  2. import (
  3. "strconv"
  4. "go-common/library/time"
  5. "go-common/library/xstr"
  6. )
  7. //CondIntNil cond int nil
  8. const CondIntNil = -10516
  9. // batch operation deleted code
  10. const (
  11. StatusNormal = iota // 正常弹幕
  12. StatusDelete // 删除弹幕
  13. StatusProtect // 保护弹幕
  14. DMIndexInactive = int8(0)
  15. DMIndexActive = int8(1)
  16. PoolNormal = int32(0) // 普通弹幕池
  17. PoolSubtitle = int32(1) // 字幕弹幕池
  18. PoolSpecial = int32(2) // 特殊弹幕池
  19. AttrProtect = uint(0) // 保护弹幕
  20. StateNormal = int32(0) // 普通状态
  21. StateDelete = int32(1) // 删除状态
  22. StateHide = int32(2) // 隐藏状态
  23. StateBlock = int32(3) // 屏蔽状态
  24. StateFilter = int32(4) // 过滤状态
  25. StateMonitorBefore = int32(5) // 先审后发
  26. StateMonitorAfter = int32(6) // 先发后审
  27. StateSensBlock = int32(7) // 敏感词过滤
  28. StateReportDelete = int32(8) // 举报删除
  29. StateAdminDelete = int32(9) // 后台管理删除
  30. StateUserDelete = int32(10) // 用户删除
  31. StateRptAutoDelete = int32(11) // 举报脚本自动删除
  32. StateTaskDelete = int32(12) // 弹幕任务删除
  33. StateAiDelete = int32(13) // ai删除
  34. DMLogBizID = int(31) // dm日志平台business id
  35. // mask platform
  36. MaskPlatWeb int8 = 0
  37. MaskPlatMbl int8 = 1
  38. MaskPlatAll int8 = 100
  39. )
  40. // StateDesc get a state description
  41. func StateDesc(state int32) (description string) {
  42. switch state {
  43. case StateNormal:
  44. description = "正常弹幕"
  45. case StateDelete:
  46. description = "删除状态"
  47. case StateHide:
  48. description = "隐藏状态"
  49. case StateBlock:
  50. description = "屏蔽状态"
  51. case StateFilter:
  52. description = "过滤状态"
  53. case StateMonitorBefore:
  54. description = "先审后发"
  55. case StateMonitorAfter:
  56. description = "先发后审"
  57. case StateSensBlock:
  58. description = "敏感词过滤"
  59. case StateReportDelete:
  60. description = "举报删除"
  61. case StateAdminDelete:
  62. description = "弹幕管理删除"
  63. case StateUserDelete:
  64. description = "用户删除"
  65. case StateRptAutoDelete:
  66. description = "举报脚本删除"
  67. case StateTaskDelete:
  68. description = "弹幕任务删除"
  69. default:
  70. description = "未知状态"
  71. }
  72. return
  73. }
  74. // DM dm info for new database
  75. type DM struct {
  76. ID int64 `json:"id"`
  77. Type int32 `json:"type"`
  78. Oid int64 `json:"oid"`
  79. Mid int64 `json:"mid"`
  80. Progress int32 `json:"progress"`
  81. Pool int32 `json:"pool"`
  82. Attr int32 `json:"attr"`
  83. State int32 `json:"state"`
  84. Ctime time.Time `json:"ctime"`
  85. Mtime time.Time `json:"mtime"`
  86. Content *Content `json:"content,omitempty"`
  87. ContentSpe *ContentSpecial `json:"content_special,omitempty"`
  88. }
  89. // AttrVal return val of index'attr
  90. func (d *DM) AttrVal(bit uint) int32 {
  91. return (d.Attr >> bit) & int32(1)
  92. }
  93. // AttrSet set val of index'attr
  94. func (d *DM) AttrSet(v int32, bit uint) {
  95. d.Attr = d.Attr&(^(1 << bit)) | (v << bit)
  96. }
  97. // AttrNtoA convert uint to string format,eg:5-->101-->1,3.
  98. func (d *DM) AttrNtoA() string {
  99. if d.Attr == 0 {
  100. return ""
  101. }
  102. var bits []int64
  103. for k, v := range strconv.FormatInt(int64(d.Attr), 2) {
  104. if v == 49 {
  105. bits = append(bits, int64(k+1))
  106. }
  107. }
  108. return xstr.JoinInts(bits)
  109. }
  110. // Content dm content info
  111. type Content struct {
  112. ID int64 `json:"id"`
  113. FontSize int32 `json:"fontsize"`
  114. Color int64 `json:"color"`
  115. Mode int32 `json:"mode"`
  116. IP int64 `json:"ip"`
  117. Plat int32 `json:"plat"`
  118. Msg string `json:"msg"`
  119. Ctime time.Time `json:"ctime"`
  120. Mtime time.Time `json:"mtime"`
  121. }
  122. // ContentSpecial special dm data
  123. type ContentSpecial struct {
  124. ID int64 `json:"id"`
  125. Msg string `json:"msg"`
  126. Ctime time.Time `json:"ctime"`
  127. Mtime time.Time `json:"mtime"`
  128. }
  129. // DMVisible check dm is visible or not.
  130. func DMVisible(state int32) bool {
  131. if state == StateNormal || state == StateHide || state == StateMonitorAfter {
  132. return true
  133. }
  134. return false
  135. }
  136. // SearchDMParams dm search params
  137. type SearchDMParams struct {
  138. Type int32 `form:"type" validate:"required"`
  139. Oid int64 `form:"oid" validate:"required"`
  140. Keyword string `form:"keyword"`
  141. Mid int64 `form:"mid" default:"-10516"`
  142. IP string `form:"ip"`
  143. State string `form:"state"`
  144. Pool string `form:"pool"`
  145. Attrs string `form:"attrs"`
  146. ProgressFrom int64 `form:"progress_from" default:"-10516"`
  147. ProgressTo int64 `form:"progress_to" default:"-10516"`
  148. CtimeFrom int64 `form:"ctime_from" default:"-10516"`
  149. CtimeTo int64 `form:"ctime_to" default:"-10516"`
  150. Page int64 `form:"page" default:"1"`
  151. Size int64 `form:"page_size" default:"100"`
  152. Sort string `form:"sort"`
  153. Order string `form:"order"`
  154. }
  155. // SearchDMData dm meta data from search
  156. type SearchDMData struct {
  157. Order string `json:"order"`
  158. Sort string `json:"sort"`
  159. Result []*struct {
  160. ID int64 `json:"id"`
  161. } `json:"result"`
  162. Page *Page `json:"page"`
  163. }
  164. //SearchDMResult dm list
  165. type SearchDMResult struct {
  166. Total int64 `json:"total"`
  167. Count int64 `json:"count"`
  168. MaxLimit int64 `json:"max_limit"`
  169. Protected int64 `json:"protected"`
  170. Deleted int64 `json:"deleted"`
  171. Page int64 `json:"page"`
  172. Pagesize int64 `json:"pagesize"`
  173. Result []*DMItem `json:"result"`
  174. }
  175. //ListItem dm list item
  176. type ListItem struct {
  177. ID int64 `json:"id"`
  178. CID int64 `json:"cid"`
  179. PoolID int `json:"pool_id"`
  180. Deleted int `json:"deleted"`
  181. UID int64 `json:"uid"`
  182. Uname string `json:"uname"`
  183. IP string `json:"ip"`
  184. Playtime float64 `json:"playtime"`
  185. Model int `json:"model"`
  186. Msg string `json:"msg"`
  187. Fontsize int `json:"fontsize"`
  188. Color string `json:"color"`
  189. Ctime time.Time `json:"ctime"`
  190. }
  191. // DMItem dm list item from new db
  192. type DMItem struct {
  193. IDStr string `json:"id_str"`
  194. ID int64 `json:"id"`
  195. Type int32 `json:"type"`
  196. Oid int64 `json:"oid"`
  197. Mid int64 `json:"mid"`
  198. Pool int32 `json:"pool"`
  199. State int32 `json:"state"`
  200. Attrs string `json:"attrs"`
  201. IP int64 `json:"ip"`
  202. Progress int32 `json:"progress"`
  203. Mode int32 `json:"mode"`
  204. Msg string `json:"msg"`
  205. Fontsize int32 `json:"fontsize"`
  206. Color string `json:"color"`
  207. Ctime time.Time `json:"ctime"`
  208. Uname string `json:"uname"`
  209. }
  210. // DMSubject dm_inid info
  211. type DMSubject struct {
  212. OID int64 `json:"oid"`
  213. Type int32 `json:"type"`
  214. AID int64 `json:"aid"`
  215. MID int64 `json:"uid"`
  216. ACount int64 `json:"count"`
  217. Limit int64 `json:"limit"`
  218. TID int64 `json:"tid"`
  219. TName string `json:"tname"`
  220. State int32 `json:"state"`
  221. ETitle string `json:"ep_title"`
  222. Title string `json:"title"`
  223. CTime time.Time `json:"ctime"`
  224. MTime time.Time `json:"mtime"`
  225. }
  226. //ArchiveResult archive list
  227. type ArchiveResult struct {
  228. ArcLists []*DMSubject `json:"archives"`
  229. Page *Page `json:"page"`
  230. }
  231. //DMIndexInfo dm_inid index info
  232. type DMIndexInfo struct {
  233. CID int64 `json:"dm_inid"`
  234. AID int64 `json:"aid"`
  235. MID int64 `json:"mid"`
  236. UName string `json:"u_name"`
  237. Duration int64 `json:"duration"`
  238. Limit int64 `json:"limit"`
  239. Active int64 `json:"dm_active"`
  240. ETitle string `json:"ep_title"`
  241. Title string `json:"title"`
  242. Cover string `json:"cover"`
  243. CTime int64 `json:"ctime"`
  244. MTime int64 `json:"mtime"`
  245. }
  246. // ArcVideo arc+video info by api
  247. type ArcVideo struct {
  248. Archive *struct {
  249. AID int64 `json:"aid"`
  250. MID int64 `json:"mid"`
  251. TID int64 `json:"tid"`
  252. Title string `json:"title"`
  253. Cover string `json:"cover"`
  254. RjReason string `json:"reject_reason"`
  255. Tag string `json:"tag"`
  256. Duration int64 `json:"duration"`
  257. Copyright int64 `json:"copyright"`
  258. Desc string `json:"desc"`
  259. MissionID int64 `json:"mission_id"`
  260. Attribute int64 `json:"attribute"`
  261. State int64 `json:"state"`
  262. Source string `json:"source"`
  263. NoReprint int64 `json:"no_reprint"`
  264. OrderID int64 `json:"order_id"`
  265. DTime int64 `json:"dtime"`
  266. PTime int64 `json:"ptime"`
  267. CTime int64 `json:"ctime"`
  268. } `json:"archive"`
  269. Videos []*struct {
  270. AID int64 `json:"aid"`
  271. Title string `json:"title"`
  272. Desc string `json:"desc"`
  273. Filename string `json:"filename"`
  274. CID int64 `json:"cid"`
  275. Index int64 `json:"index"`
  276. Status int64 `json:"status"`
  277. FailCode int64 `json:"fail_code"`
  278. XState int64 `json:"xcode_state"`
  279. RjReason string `json:"reject_reason"`
  280. CTime int64 `json:"ctime"`
  281. } `json:"videos"`
  282. }
  283. // ArchiveType archive type info
  284. type ArchiveType struct {
  285. ID int64 `json:"id"`
  286. PID int64 `json:"pid"`
  287. Name string `json:"name"`
  288. Desc string `json:"description"`
  289. }
  290. // ArchiveListReq archive list request
  291. type ArchiveListReq struct {
  292. IDType string
  293. ID int64
  294. Page int64
  295. State int64
  296. Attrs []int64
  297. Pn int64
  298. Ps int64
  299. Sort string
  300. Order string
  301. }
  302. // UptSearchDMState update search dm state
  303. type UptSearchDMState struct {
  304. ID int64 `json:"id"`
  305. Oid int64 `json:"oid"`
  306. Type int32 `json:"type"`
  307. State int32 `json:"state"`
  308. Mtime string `json:"mtime"`
  309. }
  310. // UptSearchDMPool update search dm pool
  311. type UptSearchDMPool struct {
  312. ID int64 `json:"id"`
  313. Oid int64 `json:"oid"`
  314. Type int32 `json:"type"`
  315. Pool int32 `json:"pool"`
  316. Mtime string `json:"mtime"`
  317. }
  318. // UptSearchDMAttr update search dm attr
  319. type UptSearchDMAttr struct {
  320. ID int64 `json:"id"`
  321. Oid int64 `json:"oid"`
  322. Type int32 `json:"type"`
  323. Attr int32 `json:"attr"`
  324. Mtime string `json:"mtime"`
  325. AttrFormat []int64 `json:"attr_format"`
  326. }
  327. // MaskUp mask up info.
  328. type MaskUp struct {
  329. ID int64 `json:"id"`
  330. Mid int64 `json:"mid"`
  331. Name string `json:"name"`
  332. State int32 `json:"state"`
  333. Comment string `json:"comment"`
  334. CTime time.Time `json:"ctime"`
  335. MTime time.Time `json:"mtime"`
  336. }
  337. // MaskUpRes maskUp and page info
  338. type MaskUpRes struct {
  339. Result []*MaskUp `json:"result"`
  340. Page *PageInfo `json:"page"`
  341. }