model.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. package block
  2. import (
  3. "time"
  4. )
  5. // BlockStatus 封禁状态 0. 未封禁 1. 永久封禁 2. 限时封禁
  6. type BlockStatus uint8
  7. const (
  8. // BlockStatusFalse 未封禁
  9. BlockStatusFalse BlockStatus = iota
  10. // BlockStatusForever 永久封禁
  11. BlockStatusForever
  12. // BlockStatusLimit 限时封禁
  13. BlockStatusLimit
  14. // BlockStatusCredit 小黑屋封禁
  15. BlockStatusCredit
  16. )
  17. // BlockSource 封禁来源 1. 小黑屋(小黑屋和manager后台封禁) 2. 系统封禁(反作弊及监控系统上报) 3.解封 (所有后台,用户前台自助的解封)
  18. type BlockSource uint8
  19. const (
  20. // BlockSourceCredit 小黑屋封禁
  21. BlockSourceCredit BlockSource = iota + 1
  22. // BlockSourceSys 系统封禁
  23. BlockSourceSys
  24. // BlockSourceRemove 解封
  25. BlockSourceRemove
  26. )
  27. // String .
  28. func (b BlockSource) String() string {
  29. switch b {
  30. case BlockSourceCredit:
  31. return "小黑屋封禁"
  32. case BlockSourceSys:
  33. return "系统封禁"
  34. case BlockSourceRemove:
  35. return "解封"
  36. default:
  37. return ""
  38. }
  39. }
  40. const (
  41. // BlockLogBizID 用户审核日志
  42. BlockLogBizID = 122
  43. // BlockJOBManagerID blockjob manager uid
  44. BlockJOBManagerID = 1493
  45. // BlockJOBManagerName blockjob manager name
  46. BlockJOBManagerName = "blockjob"
  47. )
  48. // BlockArea 封禁业务
  49. type BlockArea uint8
  50. // const .
  51. const (
  52. BlockAreaNone BlockArea = iota
  53. BlockAreaReply
  54. BlockAreaDanmaku
  55. BlockAreaMessage
  56. BlockAreaTag
  57. BlockAreaProfile // 个人资料
  58. BlockAreaArchive
  59. BlockAreaMusic
  60. BlockAreaArticle
  61. BlockAreaSpaceBanner // 空间头图
  62. BlockAreaDynamic // 动态
  63. BlockAreaAlbum // 相册
  64. BlockAreaQuickVideo //小视频
  65. )
  66. // String .
  67. func (b BlockArea) String() string {
  68. switch b {
  69. case BlockAreaReply:
  70. return "评论"
  71. case BlockAreaDanmaku:
  72. return "弹幕"
  73. case BlockAreaMessage:
  74. return "私信"
  75. case BlockAreaTag:
  76. return "标签"
  77. case BlockAreaProfile:
  78. return "个人资料"
  79. case BlockAreaArchive:
  80. return "投稿"
  81. case BlockAreaMusic:
  82. return "音频"
  83. case BlockAreaArticle:
  84. return "专栏"
  85. case BlockAreaSpaceBanner:
  86. return "空间头图"
  87. case BlockAreaDynamic:
  88. return "动态"
  89. case BlockAreaAlbum:
  90. return "相册"
  91. case BlockAreaQuickVideo:
  92. return "小视频"
  93. default:
  94. return ""
  95. }
  96. }
  97. // BlockAction .
  98. type BlockAction uint8
  99. const (
  100. // BlockActionLimit 限时封禁
  101. BlockActionLimit BlockAction = iota + 1
  102. // BlockActionForever 永久封禁
  103. BlockActionForever
  104. // BlockActionAdminRemove 后台解封
  105. BlockActionAdminRemove
  106. // BlockActionSelfRemove 自助解封
  107. BlockActionSelfRemove
  108. )
  109. // String .
  110. func (b BlockAction) String() string {
  111. switch b {
  112. case BlockActionLimit:
  113. return "限时封禁"
  114. case BlockActionForever:
  115. return "永久封禁"
  116. case BlockActionAdminRemove:
  117. return "后台解封"
  118. case BlockActionSelfRemove:
  119. return "自动解封"
  120. default:
  121. return ""
  122. }
  123. }
  124. // BlockInfo 封禁信息
  125. type BlockInfo struct {
  126. MID int64 `json:"mid"`
  127. BlockStatus BlockStatus `json:"block_status"` // blockStatus 封禁状态 0. 未封禁 1. 永久封禁 2. 限时封禁
  128. // EndTime int64 `json:"end_time"` // 结束封禁时间 unix time 永久封禁为0
  129. }
  130. // ParseDB .
  131. func (b *BlockInfo) ParseDB(data *DBUser) {
  132. b.MID = data.MID
  133. b.BlockStatus = data.Status
  134. }
  135. // ParseMC .
  136. func (b *BlockInfo) ParseMC(data *MCBlockInfo, mid int64) {
  137. b.MID = mid
  138. b.BlockStatus = data.BlockStatus
  139. }
  140. // BlockHistory 封禁历史
  141. type BlockHistory struct {
  142. Area BlockArea `json:"type"`
  143. Operator string `json:"operator"` // 操作人
  144. Reason string `json:"reason"` // 封禁原因
  145. Action BlockAction `json:"action"` // 操作类型
  146. ActionTime int64 `json:"action_time"` // 操作时间
  147. RemoveTime int64 `json:"remove_time"` // 解封时间
  148. Comment string `json:"comment"`
  149. }
  150. // ParseDB .
  151. func (b *BlockHistory) ParseDB(data *DBHistory) {
  152. b.Area = data.Area
  153. b.Operator = data.AdminName
  154. b.Reason = data.Reason
  155. b.Action = data.Action
  156. b.ActionTime = data.StartTime.Unix()
  157. b.RemoveTime = data.StartTime.Add(time.Second * time.Duration(data.Duration)).Unix()
  158. b.Comment = data.Comment
  159. }
  160. // BlockMessage 通知消息体
  161. type BlockMessage struct {
  162. MID int64 `json:"mid"` // 用户mid
  163. Area BlockArea `json:"area"` // BlockArea 封禁类型 1. 小黑屋(小黑屋和manager后台封禁) 2. 系统封禁(反作弊及监控系统上报) 3.解封 (所有后台,用户前台自助的解封)
  164. Status BlockStatus `json:"status"` // blockStatus 封禁状态 0. 未封禁 1. 永久封禁 2. 限时封禁
  165. }