Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"dao.go",
"http.go",
"model.go",
"notify.go",
"rpc.go",
],
importpath = "go-common/app/service/main/member/model/block",
tags = ["automanaged"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,53 @@
package block
import (
"time"
)
// DBUser .
type DBUser struct {
ID int64
MID int64
Status BlockStatus
CTime time.Time
MTime time.Time
}
// DBUserDetail .
type DBUserDetail struct {
ID int64
MID int64
BlockCount int64
CTime time.Time
MTime time.Time
}
// DBHistory .
type DBHistory struct {
ID int64
MID int64
AdminID int64
AdminName string
Source BlockSource
Area BlockArea
Reason string
Comment string
Action BlockAction
StartTime time.Time
Duration int64
Notify bool
CTime time.Time
MTime time.Time
}
// MCBlockInfo .
type MCBlockInfo struct {
BlockStatus BlockStatus `json:"bs"`
StartTime int64 `json:"st"`
EndTime int64 `json:"et"`
}
// MCUserDetail .
type MCUserDetail struct {
BlockCount int64 `json:"block_count"`
}

View File

@@ -0,0 +1,160 @@
package block
// ParamValidator .
type ParamValidator interface {
Validate() bool
}
// ParamInfo .
type ParamInfo struct {
MID int64 `form:"mid"`
}
// Validate .
func (p *ParamInfo) Validate() bool {
return p.MID > 0
}
// ParamBatchInfo .
type ParamBatchInfo struct {
MIDs []int64 `form:"mids,split"`
}
// Validate .
func (p *ParamBatchInfo) Validate() bool {
if len(p.MIDs) == 0 || len(p.MIDs) > 20 {
return false
}
return true
}
// ParamBatchDetail .
type ParamBatchDetail struct {
MIDs []int64 `form:"mids,split"`
}
// Validate .
func (p *ParamBatchDetail) Validate() bool {
if len(p.MIDs) == 0 || len(p.MIDs) > 20 {
return false
}
return true
}
// ParamBlock .
type ParamBlock struct {
MID int64 `form:"mid"`
Source BlockSource `form:"source"`
Area BlockArea `form:"area"`
Action BlockAction `form:"action"`
Duration int64 `form:"duration"` // unix time
StartTime int64 `form:"start_time"`
OperatorID int `form:"op_id"`
Operator string `form:"operator"`
Reason string `form:"reason"`
Comment string `form:"comment"`
Notify bool `form:"notify"`
}
// Validate .
func (p *ParamBlock) Validate() bool {
if p.MID <= 0 {
return false
}
if !p.Source.Contain() {
return false
}
if p.Action != BlockActionLimit && p.Action != BlockActionForever {
return false
}
if p.StartTime <= 0 {
return false
}
if p.Action == BlockActionLimit {
if p.Duration <= 0 {
return false
}
}
return true
}
// ParamBatchBlock .
type ParamBatchBlock struct {
MIDs []int64 `form:"mids,split"`
Source BlockSource `form:"source"`
Area BlockArea `form:"area"`
Action BlockAction `form:"action"`
Duration int64 `form:"duration"` // unix time
StartTime int64 `form:"start_time"`
OperatorID int `form:"op_id"`
Operator string `form:"operator"`
Reason string `form:"reason"`
Comment string `form:"comment"`
Notify bool `form:"notify"`
}
// Validate .
func (p *ParamBatchBlock) Validate() bool {
if len(p.MIDs) == 0 || len(p.MIDs) > 20 {
return false
}
if !p.Source.Contain() {
return false
}
if p.Action != BlockActionLimit && p.Action != BlockActionForever {
return false
}
if p.StartTime <= 0 {
return false
}
if p.Action == BlockActionLimit {
if p.Duration <= 0 {
return false
}
}
return true
}
// ParamRemove .
type ParamRemove struct {
MID int64 `form:"mid"`
Source BlockSource `form:"source"`
OperatorID int `form:"op_id"`
Operator string `form:"operator"`
Reason string `form:"reason"`
Comment string `form:"comment"`
Notify bool `form:"notify"`
}
// Validate .
func (p *ParamRemove) Validate() bool {
if p.MID <= 0 {
return false
}
if !p.Source.Contain() {
return false
}
return true
}
// ParamBatchRemove .
type ParamBatchRemove struct {
MIDs []int64 `form:"mids,split"`
Source BlockSource `form:"source"`
OperatorID int `form:"op_id"`
Operator string `form:"operator"`
Reason string `form:"reason"`
Comment string `form:"comment"`
Notify bool `form:"notify"`
}
// Validate .
func (p *ParamBatchRemove) Validate() bool {
if len(p.MIDs) == 0 || len(p.MIDs) > 20 {
return false
}
if !p.Source.Contain() {
return false
}
return true
}

View File

@@ -0,0 +1,231 @@
package block
import (
"time"
)
// BlockStatus 封禁状态 0. 未封禁 1. 永久封禁 2. 限时封禁
type BlockStatus uint8
const (
// BlockStatusFalse 未封禁
BlockStatusFalse BlockStatus = iota
// BlockStatusForever 永久封禁
BlockStatusForever
// BlockStatusLimit 限时封禁
BlockStatusLimit
// BlockStatusCredit 小黑屋封禁
BlockStatusCredit
)
// BlockSource 封禁来源 1. 小黑屋(小黑屋和manager后台封禁) 2. 系统封禁(反作弊及监控系统上报) 3.管理后台 4.B+
type BlockSource uint8
// Contain .
func (b BlockSource) Contain() bool {
switch b {
case BlockSourceBlackHouse, BlockSourceSys, BlockSourceManager, BlockSourceBplus:
return true
default:
return false
}
}
const (
// BlockSourceBlackHouse 小黑屋封禁
BlockSourceBlackHouse BlockSource = iota + 1
// BlockSourceSys 系统封禁
BlockSourceSys
// BlockSourceManager 管理后台
BlockSourceManager
// BlockSourceBplus B+相关(动态、im、小视频)
BlockSourceBplus
)
// String .
func (b BlockSource) String() string {
switch b {
case BlockSourceBlackHouse:
return "小黑屋"
case BlockSourceSys:
return "系统封禁"
case BlockSourceManager:
return "管理后台"
case BlockSourceBplus:
return "Bplus"
default:
return ""
}
}
const (
// BlockLogBizID 用户审核日志
BlockLogBizID int = 122
)
// BlockArea 封禁业务
type BlockArea uint8
// Contain .
func (b BlockArea) Contain() bool {
switch b {
case BlockAreaNone, BlockAreaReply, BlockAreaDanmaku, BlockAreaMessage, BlockAreaTag, BlockAreaProfile, BlockAreaArchive, BlockAreaMusic, BlockAreaArticle, BlockAreaSpaceBanner, BlockAreaDynamic, BlockAreaAlbum, BlockAreaQuickVideo:
return true
default:
return false
}
}
func (b BlockArea) String() string {
switch b {
case BlockAreaReply:
return "评论"
case BlockAreaDanmaku:
return "弹幕"
case BlockAreaMessage:
return "私信"
case BlockAreaTag:
return "标签"
case BlockAreaProfile:
return "个人资料"
case BlockAreaArchive:
return "投稿"
case BlockAreaMusic:
return "音频"
case BlockAreaArticle:
return "专栏"
case BlockAreaSpaceBanner:
return "空间头图"
case BlockAreaDynamic:
return "动态"
case BlockAreaAlbum:
return "相册"
case BlockAreaQuickVideo:
return "小视频"
default:
return ""
}
}
// const .
const (
BlockAreaNone BlockArea = iota
BlockAreaReply
BlockAreaDanmaku
BlockAreaMessage
BlockAreaTag
BlockAreaProfile // 个人资料
BlockAreaArchive
BlockAreaMusic
BlockAreaArticle
BlockAreaSpaceBanner // 空间头图
BlockAreaDynamic // 动态
BlockAreaAlbum // 相册
BlockAreaQuickVideo //小视频
)
// BlockAction .
type BlockAction uint8
const (
// BlockActionLimit 限时封禁
BlockActionLimit BlockAction = iota + 1
// BlockActionForever 永久封禁
BlockActionForever
// BlockActionAdminRemove 后台解封
BlockActionAdminRemove
// BlockActionSelfRemove 自助解封
BlockActionSelfRemove
)
// String .
func (b BlockAction) String() string {
switch b {
case BlockActionLimit:
return "限时封禁"
case BlockActionForever:
return "永久封禁"
case BlockActionAdminRemove:
return "后台解封"
case BlockActionSelfRemove:
return "自动解封"
default:
return ""
}
}
// BlockInfo 封禁信息
type BlockInfo struct {
MID int64 `json:"mid"`
BlockStatus BlockStatus `json:"status"` // status 封禁状态 0. 未封禁 1. 永久封禁 2. 限时封禁
StartTime int64 `json:"start_time"` // 开始封禁时间 unix time 未封禁为 -1
EndTime int64 `json:"end_time"` // 结束封禁时间 unix time 永久封禁为 -1
}
// ParseDB .
func (b *BlockInfo) ParseDB(data *DBHistory) {
b.MID = data.MID
switch data.Action {
case BlockActionForever:
b.BlockStatus = BlockStatusForever
case BlockActionLimit:
b.BlockStatus = BlockStatusLimit
default:
b.BlockStatus = BlockStatusFalse
}
switch b.BlockStatus {
case BlockStatusForever:
b.StartTime = data.StartTime.Unix()
b.EndTime = -1
case BlockStatusLimit:
b.StartTime = data.StartTime.Unix()
b.EndTime = data.StartTime.Add(time.Duration(data.Duration) * time.Second).Unix()
default:
b.StartTime = -1
b.EndTime = -1
}
}
// ParseMC .
func (b *BlockInfo) ParseMC(data *MCBlockInfo, mid int64) {
b.MID = mid
b.BlockStatus = data.BlockStatus
b.StartTime = data.StartTime
b.EndTime = data.EndTime
}
// BlockHistory 封禁历史
type BlockHistory struct {
Area BlockArea `json:"type"`
Operator string `json:"operator"` // 操作人
Reason string `json:"reason"` // 封禁原因
Action BlockAction `json:"action"` // 操作类型
ActionTime int64 `json:"action_time"` // 操作时间
RemoveTime int64 `json:"remove_time"` // 解封时间
Comment string `json:"comment"`
}
// ParseDB .
func (b *BlockHistory) ParseDB(data *DBHistory) {
b.Area = data.Area
b.Operator = data.AdminName
b.Reason = data.Reason
b.Action = data.Action
b.ActionTime = data.StartTime.Unix()
b.RemoveTime = data.StartTime.Add(time.Second * time.Duration(data.Duration)).Unix()
b.Comment = data.Comment
}
// BlockMessage 通知消息体
type BlockMessage struct {
MID int64 `json:"mid"` // 用户mid
Area BlockArea `json:"area"` // BlockArea 封禁类型 1. 小黑屋(小黑屋和manager后台封禁) 2. 系统封禁(反作弊及监控系统上报) 3.解封 (所有后台,用户前台自助的解封)
Status BlockStatus `json:"status"` // blockStatus 封禁状态 0. 未封禁 1. 永久封禁 2. 限时封禁
}
// BlockUserDetail .
type BlockUserDetail struct {
MID int64 `json:"mid"` // 用户mid
BlockCount int64 `json:"block_count"` // 封禁次数
}

View File

@@ -0,0 +1,8 @@
package block
// AccountNotify .
type AccountNotify struct {
UID int64 `json:"mid"`
Type string `json:"type"`
Action string `json:"action"`
}

View File

@@ -0,0 +1,43 @@
package block
// RPCArgInfo .
type RPCArgInfo struct {
MID int64
}
// RPCArgBatchInfo .
type RPCArgBatchInfo struct {
MIDs []int64
}
// RPCResInfo .
type RPCResInfo struct {
MID int64
BlockStatus BlockStatus
StartTime int64
EndTime int64
}
// Parse .
func (r *RPCResInfo) Parse(b *BlockInfo) {
r.MID = b.MID
r.BlockStatus = b.BlockStatus
r.StartTime = b.StartTime
r.EndTime = b.EndTime
}
// RPCArgBlock .
// type RPCArgBlock struct {
// }
// RPCArgBatchBlock .
// type RPCArgBatchBlock struct {
// }
// RPCArgRemove .
// type RPCArgRemove struct {
// }
// RPCArgBatchRemove .RPCArgBatchRemove
// type RPCArgBatchRemove struct {
// }