subject.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package model
  2. import (
  3. "go-common/library/time"
  4. )
  5. // All const variable used in dm subject
  6. const (
  7. AttrNo = int32(0) // no
  8. AttrYes = int32(1) // yes
  9. SubTypeVideo = int32(1) // 主题类型
  10. SubStateOpen = int32(0) // 主题打开
  11. SubStateClosed = int32(1) // 主题关闭
  12. AttrSubGuest = uint(0) // 允许游客弹幕
  13. AttrSubSpolier = uint(1) // 允许剧透弹幕
  14. AttrSubMission = uint(2) // 允许活动弹幕
  15. AttrSubAdvance = uint(3) // 允许高级弹幕
  16. AttrSubMonitorBefore = uint(4) // 弹幕先审后发
  17. AttrSubMonitorAfter = uint(5) // 弹幕先发后审
  18. AttrSubMaskOpen = uint(6) // 开启蒙版
  19. AttrSubMblMaskReady = uint(7) // 移动端蒙版生产完成
  20. AttrSubWebMaskReady = uint(8) // web端蒙版生产完成
  21. )
  22. // Subject dm_subject
  23. type Subject struct {
  24. ID int64 `json:"id"`
  25. Type int32 `json:"type"`
  26. Oid int64 `json:"oid"`
  27. Pid int64 `json:"pid"`
  28. Mid int64 `json:"mid"`
  29. State int32 `json:"state"`
  30. Attr int32 `json:"attr"`
  31. ACount int64 `json:"acount"`
  32. Count int64 `json:"count"`
  33. MCount int64 `json:"mcount"`
  34. MoveCnt int64 `json:"move_count"`
  35. Maxlimit int64 `json:"maxlimit"`
  36. Childpool int32 `json:"childpool"`
  37. Ctime time.Time `json:"ctime"`
  38. Mtime time.Time `json:"mtime"`
  39. }
  40. // SubjectLog subject log
  41. type SubjectLog struct {
  42. UID int64 `json:"uid"`
  43. Uname string `json:"uname"`
  44. Oid int64 `json:"oid"`
  45. Action string `json:"action"`
  46. Comment string `json:"comment"`
  47. Ctime string `json:"ctime"`
  48. }
  49. // SeasonInfo season info.
  50. type SeasonInfo struct {
  51. Aid int64 `json:"aid"`
  52. Cid int64 `json:"cid"`
  53. Epid int64 `json:"ep_id"`
  54. Ssid int64 `json:"season_id"`
  55. State int64 `json:"is_delete"`
  56. LTitle string `json:"long_title"`
  57. Title string `json:"title"`
  58. }
  59. // SearchSubjectReq search subject request.
  60. type SearchSubjectReq struct {
  61. Oids, Aids, Mids, Attrs []int64
  62. State int64
  63. Pn, Ps int64
  64. Sort, Order string
  65. }
  66. // SearchSubjectResult result from search
  67. type SearchSubjectResult struct {
  68. Page *Page
  69. Result []*struct {
  70. Oid int64 `json:"oid"`
  71. } `json:"result"`
  72. }
  73. // SearchSubjectLog get subject logs
  74. type SearchSubjectLog struct {
  75. Page *Page
  76. Result []*struct {
  77. UID int64 `json:"uid"`
  78. Uname string `json:"uname"`
  79. Oid int64 `json:"oid"`
  80. Action string `json:"action"`
  81. ExtraData string `json:"extra_data"`
  82. Ctime string `json:"ctime"`
  83. }
  84. }
  85. // AttrVal return val of subject'attr
  86. func (s *Subject) AttrVal(bit uint) int32 {
  87. return (s.Attr >> bit) & int32(1)
  88. }
  89. // AttrSet set val of subject'attr
  90. func (s *Subject) AttrSet(v int32, bit uint) {
  91. s.Attr = s.Attr&(^(1 << bit)) | (v << bit)
  92. }
  93. // IsMonitoring check if the subject is monitoring or not.
  94. func (s *Subject) IsMonitoring() bool {
  95. return s.AttrVal(AttrSubMonitorBefore) == AttrYes ||
  96. s.AttrVal(AttrSubMonitorAfter) == AttrYes
  97. }