model.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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.管理后台 4.B+
  18. type BlockSource uint8
  19. // Contain .
  20. func (b BlockSource) Contain() bool {
  21. switch b {
  22. case BlockSourceBlackHouse, BlockSourceSys, BlockSourceManager, BlockSourceBplus:
  23. return true
  24. default:
  25. return false
  26. }
  27. }
  28. const (
  29. // BlockSourceBlackHouse 小黑屋封禁
  30. BlockSourceBlackHouse BlockSource = iota + 1
  31. // BlockSourceSys 系统封禁
  32. BlockSourceSys
  33. // BlockSourceManager 管理后台
  34. BlockSourceManager
  35. // BlockSourceBplus B+相关(动态、im、小视频)
  36. BlockSourceBplus
  37. )
  38. // String .
  39. func (b BlockSource) String() string {
  40. switch b {
  41. case BlockSourceBlackHouse:
  42. return "小黑屋"
  43. case BlockSourceSys:
  44. return "系统封禁"
  45. case BlockSourceManager:
  46. return "管理后台"
  47. case BlockSourceBplus:
  48. return "Bplus"
  49. default:
  50. return ""
  51. }
  52. }
  53. const (
  54. // BlockLogBizID 用户审核日志
  55. BlockLogBizID int = 122
  56. )
  57. // BlockArea 封禁业务
  58. type BlockArea uint8
  59. // Contain .
  60. func (b BlockArea) Contain() bool {
  61. switch b {
  62. case BlockAreaNone, BlockAreaReply, BlockAreaDanmaku, BlockAreaMessage, BlockAreaTag, BlockAreaProfile, BlockAreaArchive, BlockAreaMusic, BlockAreaArticle, BlockAreaSpaceBanner, BlockAreaDynamic, BlockAreaAlbum, BlockAreaQuickVideo:
  63. return true
  64. default:
  65. return false
  66. }
  67. }
  68. func (b BlockArea) String() string {
  69. switch b {
  70. case BlockAreaReply:
  71. return "评论"
  72. case BlockAreaDanmaku:
  73. return "弹幕"
  74. case BlockAreaMessage:
  75. return "私信"
  76. case BlockAreaTag:
  77. return "标签"
  78. case BlockAreaProfile:
  79. return "个人资料"
  80. case BlockAreaArchive:
  81. return "投稿"
  82. case BlockAreaMusic:
  83. return "音频"
  84. case BlockAreaArticle:
  85. return "专栏"
  86. case BlockAreaSpaceBanner:
  87. return "空间头图"
  88. case BlockAreaDynamic:
  89. return "动态"
  90. case BlockAreaAlbum:
  91. return "相册"
  92. case BlockAreaQuickVideo:
  93. return "小视频"
  94. default:
  95. return ""
  96. }
  97. }
  98. // const .
  99. const (
  100. BlockAreaNone BlockArea = iota
  101. BlockAreaReply
  102. BlockAreaDanmaku
  103. BlockAreaMessage
  104. BlockAreaTag
  105. BlockAreaProfile // 个人资料
  106. BlockAreaArchive
  107. BlockAreaMusic
  108. BlockAreaArticle
  109. BlockAreaSpaceBanner // 空间头图
  110. BlockAreaDynamic // 动态
  111. BlockAreaAlbum // 相册
  112. BlockAreaQuickVideo //小视频
  113. )
  114. // BlockAction .
  115. type BlockAction uint8
  116. const (
  117. // BlockActionLimit 限时封禁
  118. BlockActionLimit BlockAction = iota + 1
  119. // BlockActionForever 永久封禁
  120. BlockActionForever
  121. // BlockActionAdminRemove 后台解封
  122. BlockActionAdminRemove
  123. // BlockActionSelfRemove 自助解封
  124. BlockActionSelfRemove
  125. )
  126. // String .
  127. func (b BlockAction) String() string {
  128. switch b {
  129. case BlockActionLimit:
  130. return "限时封禁"
  131. case BlockActionForever:
  132. return "永久封禁"
  133. case BlockActionAdminRemove:
  134. return "后台解封"
  135. case BlockActionSelfRemove:
  136. return "自动解封"
  137. default:
  138. return ""
  139. }
  140. }
  141. // BlockInfo 封禁信息
  142. type BlockInfo struct {
  143. MID int64 `json:"mid"`
  144. BlockStatus BlockStatus `json:"status"` // status 封禁状态 0. 未封禁 1. 永久封禁 2. 限时封禁
  145. StartTime int64 `json:"start_time"` // 开始封禁时间 unix time 未封禁为 -1
  146. EndTime int64 `json:"end_time"` // 结束封禁时间 unix time 永久封禁为 -1
  147. }
  148. // ParseDB .
  149. func (b *BlockInfo) ParseDB(data *DBHistory) {
  150. b.MID = data.MID
  151. switch data.Action {
  152. case BlockActionForever:
  153. b.BlockStatus = BlockStatusForever
  154. case BlockActionLimit:
  155. b.BlockStatus = BlockStatusLimit
  156. default:
  157. b.BlockStatus = BlockStatusFalse
  158. }
  159. switch b.BlockStatus {
  160. case BlockStatusForever:
  161. b.StartTime = data.StartTime.Unix()
  162. b.EndTime = -1
  163. case BlockStatusLimit:
  164. b.StartTime = data.StartTime.Unix()
  165. b.EndTime = data.StartTime.Add(time.Duration(data.Duration) * time.Second).Unix()
  166. default:
  167. b.StartTime = -1
  168. b.EndTime = -1
  169. }
  170. }
  171. // ParseMC .
  172. func (b *BlockInfo) ParseMC(data *MCBlockInfo, mid int64) {
  173. b.MID = mid
  174. b.BlockStatus = data.BlockStatus
  175. b.StartTime = data.StartTime
  176. b.EndTime = data.EndTime
  177. }
  178. // BlockHistory 封禁历史
  179. type BlockHistory struct {
  180. Area BlockArea `json:"type"`
  181. Operator string `json:"operator"` // 操作人
  182. Reason string `json:"reason"` // 封禁原因
  183. Action BlockAction `json:"action"` // 操作类型
  184. ActionTime int64 `json:"action_time"` // 操作时间
  185. RemoveTime int64 `json:"remove_time"` // 解封时间
  186. Comment string `json:"comment"`
  187. }
  188. // ParseDB .
  189. func (b *BlockHistory) ParseDB(data *DBHistory) {
  190. b.Area = data.Area
  191. b.Operator = data.AdminName
  192. b.Reason = data.Reason
  193. b.Action = data.Action
  194. b.ActionTime = data.StartTime.Unix()
  195. b.RemoveTime = data.StartTime.Add(time.Second * time.Duration(data.Duration)).Unix()
  196. b.Comment = data.Comment
  197. }
  198. // BlockMessage 通知消息体
  199. type BlockMessage struct {
  200. MID int64 `json:"mid"` // 用户mid
  201. Area BlockArea `json:"area"` // BlockArea 封禁类型 1. 小黑屋(小黑屋和manager后台封禁) 2. 系统封禁(反作弊及监控系统上报) 3.解封 (所有后台,用户前台自助的解封)
  202. Status BlockStatus `json:"status"` // blockStatus 封禁状态 0. 未封禁 1. 永久封禁 2. 限时封禁
  203. }
  204. // BlockUserDetail .
  205. type BlockUserDetail struct {
  206. MID int64 `json:"mid"` // 用户mid
  207. BlockCount int64 `json:"block_count"` // 封禁次数
  208. }