case.go 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. package blocked
  2. import (
  3. "strconv"
  4. xtime "go-common/library/time"
  5. )
  6. // const case
  7. const (
  8. // JudeCaseTypePrivate case type private
  9. JudeCaseTypePrivate = int8(0) // 小众众裁
  10. // JudeCaseTypePublic case type public
  11. JudeCaseTypePublic = int8(1) // 大众众裁
  12. // case status.
  13. CaseStatusGranting = int8(1) // 发放中
  14. CaseStatusGrantStop = int8(2) // 停止发放
  15. CaseStatusDealing = int8(3) // 结案中
  16. CaseStatusDealed = int8(4) // 已裁决
  17. CaseStatusRestart = int8(5) // 待重启
  18. CaseStatusUndealed = int8(6) // 未裁决
  19. CaseStatusFreeze = int8(7) // 冻结中
  20. CaseStatusQueueing = int8(8) // 队列中
  21. // vote status.
  22. VoteTypeUndo = int8(0) // 未投票
  23. VoteTypeViolate = int8(1) // 违规-封禁
  24. VoteTypeLegal = int8(2) // 不违规
  25. VoteTypeGiveUp = int8(3) // 放弃投票
  26. VoteTypeDelete = int8(4) // 违规-删除
  27. // origin_type.
  28. OriginReply = int8(1) // 评论
  29. OriginDM = int8(2) // 弹幕
  30. OriginMsg = int8(3) // 私信
  31. OriginTag = int8(4) // 标签
  32. OriginMember = int8(5) // 个人资料
  33. OriginArchive = int8(6) // 投稿
  34. OriginMusic = int8(7) // 音频
  35. OriginArticle = int8(8) // 专栏
  36. OriginSpaceTop = int8(9) // 空间头图
  37. OriginDsynamic = int8(10) // 动态
  38. OriginPhoto = int8(11) // 相册
  39. OriginMinVideo = int8(12) // 小视频
  40. // punish status
  41. PunishhNon = int8(0)
  42. PunishBlockedTree = int8(1)
  43. PunishBlockedSeven = int8(2)
  44. PunishBlockedEver = int8(3)
  45. PunishBlockedCustom = int8(4)
  46. PunishBlockedFifteen = int8(5)
  47. PunishJustDelete = int8(6)
  48. // block time.
  49. BlockMoralNum = -2 // 扣除节操
  50. BlockCustom = -1 // N天封禁
  51. BlockForever = 0 // 永久封禁
  52. BlockThree = 3 // 3天封禁
  53. BlockSeven = 7 // 7天封禁
  54. BlockFifteen = 15 // 15天封禁
  55. )
  56. // var case
  57. var (
  58. StatusDesc = map[int8]string{
  59. CaseStatusGranting: "发放中",
  60. CaseStatusGrantStop: "停止发放",
  61. CaseStatusDealing: "结案中",
  62. CaseStatusDealed: "已裁决",
  63. CaseStatusRestart: "待重启",
  64. CaseStatusUndealed: "未裁决",
  65. CaseStatusFreeze: "冻结中",
  66. CaseStatusQueueing: "队列中",
  67. }
  68. OriginTypeDesc = map[int8]string{
  69. OriginReply: "评论",
  70. OriginDM: "弹幕",
  71. OriginMsg: "私信",
  72. OriginTag: "标签",
  73. OriginMember: "个人资料",
  74. OriginArchive: "投稿",
  75. OriginMusic: "音频",
  76. OriginArticle: "专栏",
  77. OriginSpaceTop: "空间头图",
  78. OriginDsynamic: "动态",
  79. OriginPhoto: "相册",
  80. OriginMinVideo: "小视频",
  81. }
  82. PunishDesc = map[int8]string{
  83. PunishhNon: "不违规不封禁",
  84. PunishBlockedTree: "封禁3天",
  85. PunishBlockedSeven: "封禁7天",
  86. PunishBlockedEver: "永久封禁",
  87. PunishBlockedCustom: "自定义封禁",
  88. PunishBlockedFifteen: "封禁15天",
  89. PunishJustDelete: "违规仅删除",
  90. }
  91. blockedDesc = map[int]string{
  92. BlockMoralNum: "扣除%d节操",
  93. BlockCustom: "天封禁",
  94. BlockForever: "永久封禁",
  95. BlockThree: "3天封禁",
  96. BlockSeven: "7天封禁",
  97. BlockFifteen: "15天封禁",
  98. }
  99. CaseTypeDesc = map[int8]string{
  100. JudeCaseTypePrivate: "非公开众裁",
  101. JudeCaseTypePublic: "公开众裁",
  102. }
  103. )
  104. // Case is blocked_case model.
  105. type Case struct {
  106. ID int64 `gorm:"column:id" json:"id"`
  107. MID int64 `gorm:"column:mid" json:"uid"`
  108. OPID int64 `gorm:"column:oper_id" json:"oper_id"`
  109. Status int8 `gorm:"column:status" json:"status"`
  110. OriginType int8 `gorm:"column:origin_type" json:"origin_type"`
  111. ReasonType int8 `gorm:"column:reason_type" json:"reason_type"`
  112. PunishResult int8 `gorm:"column:punish_result" json:"punish_result"`
  113. JudgeType int `gorm:"column:judge_type" json:"judge_type"`
  114. CaseType int8 `gorm:"column:case_type" json:"case_type"`
  115. BlockedDays int `gorm:"column:blocked_days" json:"blocked_days"`
  116. PutTotal int `gorm:"column:put_total" json:"put_total"`
  117. VoteRule int64 `gorm:"column:vote_rule" json:"vote_rule"`
  118. VoteBreak int64 `gorm:"column:vote_break" json:"vote_break"`
  119. VoteDelete int64 `gorm:"column:vote_delete" json:"vote_delete"`
  120. VoteTotal int64 `gorm:"-" json:"vote_total"` // 总得票数
  121. StartTime xtime.Time `gorm:"column:start_time" json:"start_time"`
  122. EndTime xtime.Time `gorm:"column:end_time" json:"end_time"`
  123. CTime xtime.Time `gorm:"column:ctime" json:"ctime"`
  124. MTime xtime.Time `gorm:"column:mtime" json:"-"`
  125. OriginURL string `gorm:"column:origin_url" json:"origin_url"`
  126. OriginTitle string `gorm:"column:origin_title" json:"origin_title"`
  127. OriginContent string `gorm:"column:origin_content" json:"origin_content"`
  128. BusinessTime xtime.Time `gorm:"column:business_time" json:"business_time"`
  129. Uname string `gorm:"-" json:"uname"`
  130. StatusDesc string `gorm:"-" json:"status_desc"`
  131. OriginTypeDesc string `gorm:"-" json:"origin_type_desc"`
  132. ReasonTypeDesc string `gorm:"-" json:"reason_type_desc"`
  133. CaseTypeDesc string `gorm:"-" json:"case_type_desc"`
  134. RelationID string `gorm:"column:relation_id" json:"relation_id"`
  135. RulePercent string `gorm:"-" json:"rule_percent"` // 不违规得票率
  136. BlockedPercent string `gorm:"-" json:"blocked_percent"` // 违规(封禁)得票率
  137. DeletePercent string `gorm:"-" json:"delete_percent"` // 违规(仅删)得票率
  138. PunishDesc string `gorm:"-" json:"punish_desc"`
  139. OPName string `gorm:"-" json:"oname"` // 操作人
  140. Fans int64 `gorm:"-" json:"fans"` // 粉丝数
  141. }
  142. // CaseVote is blocked_case_vote model.
  143. type CaseVote struct {
  144. ID int64 `gorm:"column:id" json:"id"`
  145. CID int64 `gorm:"column:cid" json:"cid"`
  146. UID int64 `gorm:"column:mid" json:"uid"`
  147. VoteType int8 `gorm:"column:vote_type" json:"vote_type"`
  148. Expired xtime.Time `gorm:"column:expired" json:"expired"`
  149. CTime xtime.Time `gorm:"column:ctime" json:"-"`
  150. MTime xtime.Time `gorm:"column:mtime" json:"-"`
  151. }
  152. // TableName case tablename
  153. func (*Case) TableName() string {
  154. return "blocked_case"
  155. }
  156. // TableName CaseVote tablename
  157. func (*CaseVote) TableName() string {
  158. return "blocked_case_vote"
  159. }
  160. // CaseList is case list.
  161. type CaseList struct {
  162. Count int
  163. Order string
  164. Sort string
  165. PN int
  166. PS int
  167. IDs []int64
  168. List []*Case
  169. }
  170. // RulePercent is rule_percent.
  171. func RulePercent(voteRule, voteBreak, voteDelete int64) string {
  172. return strconv.FormatFloat(float64(voteRule)/float64(voteRule+voteBreak+voteDelete), 'f', 2, 64)
  173. }
  174. // BreakPercent is blocked percent.
  175. func BreakPercent(voteRule, voteBreak, voteDelete int64) string {
  176. return strconv.FormatFloat(float64(voteBreak)/float64(voteRule+voteBreak+voteDelete), 'f', 2, 64)
  177. }
  178. // DeletePercent is delete_percent.
  179. func DeletePercent(voteRule, voteBreak, voteDelete int64) string {
  180. return strconv.FormatFloat(float64(voteDelete)/float64(voteRule+voteBreak+voteDelete), 'f', 2, 64)
  181. }
  182. // VoteTotal is vote_total.
  183. func VoteTotal(voteRule, voteBreak, voteDelete int64) int64 {
  184. return voteRule + voteBreak + voteDelete
  185. }