model.go 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. // 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. default:
  46. return ""
  47. }
  48. }
  49. const (
  50. // BlockLogBizID 用户审核日志
  51. BlockLogBizID int = 122
  52. )
  53. // BlockArea 封禁业务
  54. type BlockArea uint8
  55. // Contain .
  56. func (b BlockArea) Contain() bool {
  57. switch b {
  58. case BlockAreaNone, BlockAreaReply, BlockAreaDanmaku, BlockAreaMessage, BlockAreaTag, BlockAreaProfile, BlockAreaArchive, BlockAreaMusic, BlockAreaArticle, BlockAreaSpaceBanner, BlockAreaDynamic, BlockAreaAlbum, BlockAreaQuickVideo:
  59. return true
  60. default:
  61. return false
  62. }
  63. }
  64. func (b BlockArea) String() string {
  65. switch b {
  66. case BlockAreaReply:
  67. return "评论"
  68. case BlockAreaDanmaku:
  69. return "弹幕"
  70. case BlockAreaMessage:
  71. return "私信"
  72. case BlockAreaTag:
  73. return "标签"
  74. case BlockAreaProfile:
  75. return "个人资料"
  76. case BlockAreaArchive:
  77. return "投稿"
  78. case BlockAreaMusic:
  79. return "音频"
  80. case BlockAreaArticle:
  81. return "专栏"
  82. case BlockAreaSpaceBanner:
  83. return "空间头图"
  84. case BlockAreaDynamic:
  85. return "动态"
  86. case BlockAreaAlbum:
  87. return "相册"
  88. case BlockAreaQuickVideo:
  89. return "小视频"
  90. default:
  91. return ""
  92. }
  93. }
  94. // const .
  95. const (
  96. BlockAreaNone BlockArea = iota
  97. BlockAreaReply
  98. BlockAreaDanmaku
  99. BlockAreaMessage
  100. BlockAreaTag
  101. BlockAreaProfile // 个人资料
  102. BlockAreaArchive
  103. BlockAreaMusic
  104. BlockAreaArticle
  105. BlockAreaSpaceBanner // 空间头图
  106. BlockAreaDynamic // 动态
  107. BlockAreaAlbum // 相册
  108. BlockAreaQuickVideo //小视频
  109. )
  110. // BlockAction .
  111. type BlockAction uint8
  112. const (
  113. // BlockActionLimit 限时封禁
  114. BlockActionLimit BlockAction = iota + 1
  115. // BlockActionForever 永久封禁
  116. BlockActionForever
  117. // BlockActionAdminRemove 后台解封
  118. BlockActionAdminRemove
  119. // BlockActionSelfRemove 自动解封
  120. BlockActionSelfRemove
  121. )
  122. // String .
  123. func (b BlockAction) String() string {
  124. switch b {
  125. case BlockActionLimit:
  126. return "限时封禁"
  127. case BlockActionForever:
  128. return "永久封禁"
  129. case BlockActionAdminRemove:
  130. return "后台解封"
  131. case BlockActionSelfRemove:
  132. return "自动解封"
  133. default:
  134. return ""
  135. }
  136. }
  137. // BlockInfo 封禁信息
  138. type BlockInfo struct {
  139. MID int64 `json:"mid"`
  140. Nickname string `json:"nickname"`
  141. Username string `json:"username"` // 注册生成时不可更改的username
  142. Tel string `json:"tel"`
  143. TelStatus int32 `json:"tel_status"`
  144. Mail string `json:"mail"` // 绑定的邮箱
  145. Level int32 `json:"level"`
  146. SpyScore int8 `json:"spy_score"`
  147. FigureRank int8 `json:"figure_rank"`
  148. RegTime int64 `json:"reg_time"`
  149. BlockStatus BlockStatus `json:"block_status"` // blockStatus 封禁状态 0. 未封禁 1. 永久封禁 2. 限时封禁
  150. BlockCount int `json:"block_count"`
  151. }
  152. // ParseStatus .
  153. func (b *BlockInfo) ParseStatus(db *DBUser) {
  154. switch db.Status {
  155. case BlockStatusCredit:
  156. b.BlockStatus = BlockStatusLimit
  157. default:
  158. b.BlockStatus = db.Status
  159. }
  160. }
  161. // BlockHistory 封禁历史
  162. type BlockHistory struct {
  163. Type BlockMgrType `json:"type"`
  164. Operator string `json:"operator"` // 操作人
  165. Reason string `json:"reason"` // 封禁原因
  166. Action BlockAction `json:"action"` // 操作类型
  167. ActionTime int64 `json:"action_time"` // 操作时间
  168. RemoveTime int64 `json:"remove_time"` // 解封时间
  169. Comment string `json:"comment"`
  170. }
  171. // BlockDetail blockDetail.
  172. type BlockDetail struct {
  173. Status BlockStatus `json:"status"`
  174. Total int `json:"total"`
  175. History []*BlockHistory `json:"history"`
  176. }
  177. // ParseDB .
  178. func (b *BlockHistory) ParseDB(data *DBHistory) {
  179. switch data.Action {
  180. case BlockActionForever, BlockActionLimit:
  181. switch data.Source {
  182. case BlockSourceSys, BlockSourceManager:
  183. b.Type = BlockMgrTypeSys
  184. default:
  185. b.Type = BlockMgrTypeCredit
  186. }
  187. case BlockActionSelfRemove, BlockActionAdminRemove:
  188. b.Type = BlockMgrTypeRemove
  189. }
  190. b.Operator = data.AdminName
  191. if data.Area.String() == "" {
  192. b.Reason = data.Reason
  193. } else {
  194. b.Reason = data.Area.String() + " - " + data.Reason
  195. }
  196. b.Action = data.Action
  197. b.ActionTime = data.StartTime.Unix()
  198. if b.Action == BlockActionLimit {
  199. b.RemoveTime = data.StartTime.Add(time.Second * time.Duration(data.Duration)).Unix()
  200. }
  201. b.Comment = data.Comment
  202. }
  203. // BlockMessage 通知消息体
  204. type BlockMessage struct {
  205. MID int64 `json:"mid"` // 用户mid
  206. Area BlockArea `json:"area"` // BlockArea 封禁类型 1. 小黑屋(小黑屋和manager后台封禁) 2. 系统封禁(反作弊及监控系统上报) 3.解封 (所有后台,用户前台自助的解封)
  207. Status BlockStatus `json:"status"` // blockStatus 封禁状态 0. 未封禁 1. 永久封禁 2. 限时封禁
  208. }
  209. // BlockMgrType mgr后台用
  210. type BlockMgrType uint8
  211. // BlockType enum
  212. const (
  213. BlockMgrTypeCredit = iota + 1
  214. BlockMgrTypeSys
  215. BlockMgrTypeRemove
  216. )
  217. // BlockMgrSource mgr后台用
  218. type BlockMgrSource uint8
  219. // BlockMgrSource enum
  220. const (
  221. BlockMgrSourceSys = iota + 1
  222. BlockMgrSourceCredit
  223. )