model.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. package model
  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, BlockSourceRemove:
  23. return true
  24. default:
  25. return false
  26. }
  27. }
  28. const (
  29. // BlockSourceBlackHouse 小黑屋封禁
  30. BlockSourceBlackHouse BlockSource = iota + 1
  31. // BlockSourceSys 系统封禁
  32. BlockSourceSys
  33. // BlockSourceRemove 解封
  34. BlockSourceRemove
  35. )
  36. // String .
  37. func (b BlockSource) String() string {
  38. switch b {
  39. case BlockSourceBlackHouse:
  40. return "小黑屋封禁"
  41. case BlockSourceSys:
  42. return "系统封禁"
  43. case BlockSourceRemove:
  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. Source BlockSource `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. // ParseDB .
  172. func (b *BlockHistory) ParseDB(data *DBHistory) {
  173. b.Source = data.Source
  174. b.Operator = data.AdminName
  175. if data.Area.String() == "" {
  176. b.Reason = data.Reason
  177. } else {
  178. b.Reason = data.Area.String() + " - " + data.Reason
  179. }
  180. b.Action = data.Action
  181. b.ActionTime = data.StartTime.Unix()
  182. if b.Action == BlockActionLimit {
  183. b.RemoveTime = data.StartTime.Add(time.Second * time.Duration(data.Duration)).Unix()
  184. }
  185. b.Comment = data.Comment
  186. }
  187. // BlockMessage 通知消息体
  188. type BlockMessage struct {
  189. MID int64 `json:"mid"` // 用户mid
  190. Area BlockArea `json:"area"` // BlockArea 封禁类型 1. 小黑屋(小黑屋和manager后台封禁) 2. 系统封禁(反作弊及监控系统上报) 3.解封 (所有后台,用户前台自助的解封)
  191. Status BlockStatus `json:"status"` // blockStatus 封禁状态 0. 未封禁 1. 永久封禁 2. 限时封禁
  192. }