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,47 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"action.go",
"advance.go",
"dm.go",
"filter.go",
"monitor.go",
"report.go",
"subject.go",
"subtitle.go",
"subtitle_subject.go",
"task.go",
"transfer.go",
],
importpath = "go-common/app/admin/main/dm/model",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/time:go_default_library",
"//library/xstr:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/admin/main/dm/model/oplog:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,18 @@
package model
import (
"encoding/json"
)
// All const variable used in admin
const (
ActFlushDM = "flush"
ActReportDel = "report_del"
)
// Action job msg.
type Action struct {
Oid int64 `json:"oid"`
Action string `json:"action"`
Data json.RawMessage `json:"data"`
}

View File

@@ -0,0 +1,42 @@
package model
// all variable used in advance dm
const (
// mode
AdvSpeMode = "sp" // mode 7
AdvMode = "advance" // mode8 mode9
AdvModeAll = "all"
// type
AdvTypeRequest = "request"
AdvTypeAccept = "accept"
AdvTypeDeny = "deny"
AdvTypeAll = "all"
)
// Advance advance dm list
type Advance struct {
ID int64 `json:"id"` //高级弹幕ID
Type string `json:"bType"` //处理结果
Mode string `json:"mode"` //"sp" or 'advance"
Mid int64 `json:"mid"` //申请人ID
Timestamp int64 `json:"timestamp"` //申请时间
Name string `json:"name"` //申请人昵称
}
// AdvanceRes advance dm list result including page info
type AdvanceRes struct {
Result []*Advance `json:"result"`
Page *PageInfo `json:"page"`
}
// PageInfo page info
type PageInfo struct {
Num int64 `json:"num"`
Size int64 `json:"size"`
Total int64 `json:"total"`
}
// ArgMids advance dm mids
type ArgMids struct {
Mids []int64
}

View File

@@ -0,0 +1,375 @@
package model
import (
"strconv"
"go-common/library/time"
"go-common/library/xstr"
)
//CondIntNil cond int nil
const CondIntNil = -10516
// batch operation deleted code
const (
StatusNormal = iota // 正常弹幕
StatusDelete // 删除弹幕
StatusProtect // 保护弹幕
DMIndexInactive = int8(0)
DMIndexActive = int8(1)
PoolNormal = int32(0) // 普通弹幕池
PoolSubtitle = int32(1) // 字幕弹幕池
PoolSpecial = int32(2) // 特殊弹幕池
AttrProtect = uint(0) // 保护弹幕
StateNormal = int32(0) // 普通状态
StateDelete = int32(1) // 删除状态
StateHide = int32(2) // 隐藏状态
StateBlock = int32(3) // 屏蔽状态
StateFilter = int32(4) // 过滤状态
StateMonitorBefore = int32(5) // 先审后发
StateMonitorAfter = int32(6) // 先发后审
StateSensBlock = int32(7) // 敏感词过滤
StateReportDelete = int32(8) // 举报删除
StateAdminDelete = int32(9) // 后台管理删除
StateUserDelete = int32(10) // 用户删除
StateRptAutoDelete = int32(11) // 举报脚本自动删除
StateTaskDelete = int32(12) // 弹幕任务删除
StateAiDelete = int32(13) // ai删除
DMLogBizID = int(31) // dm日志平台business id
// mask platform
MaskPlatWeb int8 = 0
MaskPlatMbl int8 = 1
MaskPlatAll int8 = 100
)
// StateDesc get a state description
func StateDesc(state int32) (description string) {
switch state {
case StateNormal:
description = "正常弹幕"
case StateDelete:
description = "删除状态"
case StateHide:
description = "隐藏状态"
case StateBlock:
description = "屏蔽状态"
case StateFilter:
description = "过滤状态"
case StateMonitorBefore:
description = "先审后发"
case StateMonitorAfter:
description = "先发后审"
case StateSensBlock:
description = "敏感词过滤"
case StateReportDelete:
description = "举报删除"
case StateAdminDelete:
description = "弹幕管理删除"
case StateUserDelete:
description = "用户删除"
case StateRptAutoDelete:
description = "举报脚本删除"
case StateTaskDelete:
description = "弹幕任务删除"
default:
description = "未知状态"
}
return
}
// DM dm info for new database
type DM struct {
ID int64 `json:"id"`
Type int32 `json:"type"`
Oid int64 `json:"oid"`
Mid int64 `json:"mid"`
Progress int32 `json:"progress"`
Pool int32 `json:"pool"`
Attr int32 `json:"attr"`
State int32 `json:"state"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
Content *Content `json:"content,omitempty"`
ContentSpe *ContentSpecial `json:"content_special,omitempty"`
}
// AttrVal return val of index'attr
func (d *DM) AttrVal(bit uint) int32 {
return (d.Attr >> bit) & int32(1)
}
// AttrSet set val of index'attr
func (d *DM) AttrSet(v int32, bit uint) {
d.Attr = d.Attr&(^(1 << bit)) | (v << bit)
}
// AttrNtoA convert uint to string format,eg:5-->101-->1,3.
func (d *DM) AttrNtoA() string {
if d.Attr == 0 {
return ""
}
var bits []int64
for k, v := range strconv.FormatInt(int64(d.Attr), 2) {
if v == 49 {
bits = append(bits, int64(k+1))
}
}
return xstr.JoinInts(bits)
}
// Content dm content info
type Content struct {
ID int64 `json:"id"`
FontSize int32 `json:"fontsize"`
Color int64 `json:"color"`
Mode int32 `json:"mode"`
IP int64 `json:"ip"`
Plat int32 `json:"plat"`
Msg string `json:"msg"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// ContentSpecial special dm data
type ContentSpecial struct {
ID int64 `json:"id"`
Msg string `json:"msg"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// DMVisible check dm is visible or not.
func DMVisible(state int32) bool {
if state == StateNormal || state == StateHide || state == StateMonitorAfter {
return true
}
return false
}
// SearchDMParams dm search params
type SearchDMParams struct {
Type int32 `form:"type" validate:"required"`
Oid int64 `form:"oid" validate:"required"`
Keyword string `form:"keyword"`
Mid int64 `form:"mid" default:"-10516"`
IP string `form:"ip"`
State string `form:"state"`
Pool string `form:"pool"`
Attrs string `form:"attrs"`
ProgressFrom int64 `form:"progress_from" default:"-10516"`
ProgressTo int64 `form:"progress_to" default:"-10516"`
CtimeFrom int64 `form:"ctime_from" default:"-10516"`
CtimeTo int64 `form:"ctime_to" default:"-10516"`
Page int64 `form:"page" default:"1"`
Size int64 `form:"page_size" default:"100"`
Sort string `form:"sort"`
Order string `form:"order"`
}
// SearchDMData dm meta data from search
type SearchDMData struct {
Order string `json:"order"`
Sort string `json:"sort"`
Result []*struct {
ID int64 `json:"id"`
} `json:"result"`
Page *Page `json:"page"`
}
//SearchDMResult dm list
type SearchDMResult struct {
Total int64 `json:"total"`
Count int64 `json:"count"`
MaxLimit int64 `json:"max_limit"`
Protected int64 `json:"protected"`
Deleted int64 `json:"deleted"`
Page int64 `json:"page"`
Pagesize int64 `json:"pagesize"`
Result []*DMItem `json:"result"`
}
//ListItem dm list item
type ListItem struct {
ID int64 `json:"id"`
CID int64 `json:"cid"`
PoolID int `json:"pool_id"`
Deleted int `json:"deleted"`
UID int64 `json:"uid"`
Uname string `json:"uname"`
IP string `json:"ip"`
Playtime float64 `json:"playtime"`
Model int `json:"model"`
Msg string `json:"msg"`
Fontsize int `json:"fontsize"`
Color string `json:"color"`
Ctime time.Time `json:"ctime"`
}
// DMItem dm list item from new db
type DMItem struct {
IDStr string `json:"id_str"`
ID int64 `json:"id"`
Type int32 `json:"type"`
Oid int64 `json:"oid"`
Mid int64 `json:"mid"`
Pool int32 `json:"pool"`
State int32 `json:"state"`
Attrs string `json:"attrs"`
IP int64 `json:"ip"`
Progress int32 `json:"progress"`
Mode int32 `json:"mode"`
Msg string `json:"msg"`
Fontsize int32 `json:"fontsize"`
Color string `json:"color"`
Ctime time.Time `json:"ctime"`
Uname string `json:"uname"`
}
// DMSubject dm_inid info
type DMSubject struct {
OID int64 `json:"oid"`
Type int32 `json:"type"`
AID int64 `json:"aid"`
MID int64 `json:"uid"`
ACount int64 `json:"count"`
Limit int64 `json:"limit"`
TID int64 `json:"tid"`
TName string `json:"tname"`
State int32 `json:"state"`
ETitle string `json:"ep_title"`
Title string `json:"title"`
CTime time.Time `json:"ctime"`
MTime time.Time `json:"mtime"`
}
//ArchiveResult archive list
type ArchiveResult struct {
ArcLists []*DMSubject `json:"archives"`
Page *Page `json:"page"`
}
//DMIndexInfo dm_inid index info
type DMIndexInfo struct {
CID int64 `json:"dm_inid"`
AID int64 `json:"aid"`
MID int64 `json:"mid"`
UName string `json:"u_name"`
Duration int64 `json:"duration"`
Limit int64 `json:"limit"`
Active int64 `json:"dm_active"`
ETitle string `json:"ep_title"`
Title string `json:"title"`
Cover string `json:"cover"`
CTime int64 `json:"ctime"`
MTime int64 `json:"mtime"`
}
// ArcVideo arc+video info by api
type ArcVideo struct {
Archive *struct {
AID int64 `json:"aid"`
MID int64 `json:"mid"`
TID int64 `json:"tid"`
Title string `json:"title"`
Cover string `json:"cover"`
RjReason string `json:"reject_reason"`
Tag string `json:"tag"`
Duration int64 `json:"duration"`
Copyright int64 `json:"copyright"`
Desc string `json:"desc"`
MissionID int64 `json:"mission_id"`
Attribute int64 `json:"attribute"`
State int64 `json:"state"`
Source string `json:"source"`
NoReprint int64 `json:"no_reprint"`
OrderID int64 `json:"order_id"`
DTime int64 `json:"dtime"`
PTime int64 `json:"ptime"`
CTime int64 `json:"ctime"`
} `json:"archive"`
Videos []*struct {
AID int64 `json:"aid"`
Title string `json:"title"`
Desc string `json:"desc"`
Filename string `json:"filename"`
CID int64 `json:"cid"`
Index int64 `json:"index"`
Status int64 `json:"status"`
FailCode int64 `json:"fail_code"`
XState int64 `json:"xcode_state"`
RjReason string `json:"reject_reason"`
CTime int64 `json:"ctime"`
} `json:"videos"`
}
// ArchiveType archive type info
type ArchiveType struct {
ID int64 `json:"id"`
PID int64 `json:"pid"`
Name string `json:"name"`
Desc string `json:"description"`
}
// ArchiveListReq archive list request
type ArchiveListReq struct {
IDType string
ID int64
Page int64
State int64
Attrs []int64
Pn int64
Ps int64
Sort string
Order string
}
// UptSearchDMState update search dm state
type UptSearchDMState struct {
ID int64 `json:"id"`
Oid int64 `json:"oid"`
Type int32 `json:"type"`
State int32 `json:"state"`
Mtime string `json:"mtime"`
}
// UptSearchDMPool update search dm pool
type UptSearchDMPool struct {
ID int64 `json:"id"`
Oid int64 `json:"oid"`
Type int32 `json:"type"`
Pool int32 `json:"pool"`
Mtime string `json:"mtime"`
}
// UptSearchDMAttr update search dm attr
type UptSearchDMAttr struct {
ID int64 `json:"id"`
Oid int64 `json:"oid"`
Type int32 `json:"type"`
Attr int32 `json:"attr"`
Mtime string `json:"mtime"`
AttrFormat []int64 `json:"attr_format"`
}
// MaskUp mask up info.
type MaskUp struct {
ID int64 `json:"id"`
Mid int64 `json:"mid"`
Name string `json:"name"`
State int32 `json:"state"`
Comment string `json:"comment"`
CTime time.Time `json:"ctime"`
MTime time.Time `json:"mtime"`
}
// MaskUpRes maskUp and page info
type MaskUpRes struct {
Result []*MaskUp `json:"result"`
Page *PageInfo `json:"page"`
}

View File

@@ -0,0 +1,35 @@
package model
import (
"go-common/library/time"
)
// all const variable used in dm filter
const (
FilterUnActive int8 = 0
FilterActive int8 = 1
FilterTypeAll int8 = -1 // 所有类型
FilterTypeText int8 = 0 // 文本类型
FilterTypeRegex int8 = 1 // 正则类型
FilterTypeID int8 = 2 // 用户ID类型
FilterMaxUpText = 500 // up主关键字最大条数
FilterMaxUpReg = 100 // up主正则最大条数
FilterMaxUpID = 1000 // up主黑名单最大条数
)
// UpFilter define a new struct, consistent with table "dm_filter_up_%"
type UpFilter struct {
ID int64 `json:"id"`
Oid int64 `json:"oid"`
Type int8 `json:"type"`
Filter string `json:"filter"`
Ctime time.Time `json:"ctime"`
}
// UpFilterRes return UpFilters and PageInfo
type UpFilterRes struct {
Result []*UpFilter `json:"result"`
Page *PageInfo `json:"page"`
}

View File

@@ -0,0 +1,65 @@
package model
// all const variable used in dm monitor
const (
// 监控状态
MonitorClosed = int32(0)
MonitorBefore = int32(1) // 先审后发
MonitorAfter = int32(2) // 先发后审
)
// MonitorResult dm monitor result
type MonitorResult struct {
Order string `json:"order"`
Sort string `json:"sort"`
Page int64 `json:"page"`
PageSize int64 `json:"pagesize"`
Total int64 `json:"total"`
Result []*Monitor `json:"result"`
}
// Monitor dm monitors
type Monitor struct {
ID int64 `json:"id"`
Type int32 `json:"type"`
Pid int64 `json:"pid"`
Oid int64 `json:"oid"`
State int32 `json:"state"`
MCount int64 `json:"mcount"`
Ctime string `json:"ctime"`
Mtime string `json:"mtime"`
Mid int64 `json:"mid"`
Title string `json:"title"`
Author string `json:"author"`
}
// SearchMonitor dm monitor struct
type SearchMonitor struct {
ID int64 `json:"id"`
Type int32 `json:"type"`
Pid int64 `json:"pid"`
Oid int64 `json:"oid"`
State int32 `json:"state"`
Attr int32 `json:"attr"`
MCount int64 `json:"mcount"`
Ctime string `json:"ctime"`
Mtime string `json:"mtime"`
Mid int64 `json:"mid"`
Title string `json:"title"`
Author string `json:"author"`
}
// Page search page info
type Page struct {
Num int64 `json:"num"`
Size int64 `json:"size"`
Total int64 `json:"total"`
}
// SearchMonitorResult result from search
type SearchMonitorResult struct {
Order string `json:"order"`
Sort string `json:"sort"`
Page *Page `json:"page"`
Result []*SearchMonitor `json:"result"`
}

View File

@@ -0,0 +1,29 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["oplog.go"],
importpath = "go-common/app/admin/main/dm/model/oplog",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = ["//library/log:go_default_library"],
)
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,89 @@
package oplog
import (
"go-common/library/log"
)
// Infoc operation log for administrator
type Infoc struct {
Oid int64 `json:"oid"`
Type int32 `json:"type"`
DMIds []int64 `json:"dmids"`
Subject string `json:"subject"`
OriginVal string `json:"origin_val"`
CurrentVal string `json:"current_val"`
OperationTime string `json:"optime"`
OperatorType OperatorType `json:"operator_type"`
Operator int64 `json:"operator"`
Source Source `json:"source"`
Remark string `json:"remark"`
}
// InfocResult data model for infoc type operation log storing in hbase
type InfocResult struct {
Oid string `json:"oid"`
Type string `json:"type"`
Subject string `json:"subject"`
CurrentVal string `json:"current_val"`
OperationTime string `json:"operation_time"`
OperatorType string `json:"operator_type"`
Operator string `json:"operator"`
Source string `json:"source"`
Remark string `json:"remark"`
}
// Source enum integer value
type Source int
// Source enum definition list
const (
_ Source = iota
SourceManager
SourceUp
SourcePlayer
)
// String returns the Source enmu description
func (source Source) String() string {
var text string
switch source {
case SourceManager:
text = "运营后台"
case SourceUp:
text = "创作中心"
case SourcePlayer:
text = "播放器"
default:
log.Warn("String() Unknow Source, warn(%v)")
text = "未知来源"
}
return text
}
// OperatorType enum integer value
type OperatorType int
// OperatorType enum definition list
const (
_ OperatorType = iota
OperatorAdmin
OperatorMember
OperatorSystem
)
// String returns the Source enmu description
func (opType OperatorType) String() string {
var text string
switch opType {
case OperatorAdmin:
text = "管理员"
case OperatorMember:
text = "用户"
case OperatorSystem:
text = "系统"
default:
log.Warn("String() Unknow Source, warn(%v)")
text = "未知来源"
}
return text
}

View File

@@ -0,0 +1,337 @@
package model
import (
"fmt"
"time"
)
// const const var
const (
// up主操作
StatUpperInit = int8(0) // up主未处理
StatUpperIgnore = int8(1) // up主已忽略
StatUpperDelete = int8(2) // up主已删除
// 管理员操作
StatFirstInit = int8(0) // 待一审
StatFirstDelete = int8(1) // 一审删除
StatSecondInit = int8(2) // 待二审
StatSecondDelete = int8(3) // 二审删除
StatSecondIgnore = int8(4) // 二审忽略
StatFirstIgnore = int8(5) // 一审忽略
StatSecondAutoDelete = int8(6) // 二审脚本删除
StatJudgeInit = int8(7) // 风纪委待审(二审)
StatJudgeDelete = int8(8) // 风纪委删除(二审)
StatJudgeIgnore = int8(9) // 风纪委忽略(二审)
// 处理结果通知
NoticeUnsend = int8(0) // 未通知用户
NoticeSend = int8(1) // 已通知用户
// 举报通知状态
NoticeReporter = int8(1)
NoticePoster = int8(2)
NoticeAll = int8(3)
// 举报原因
ReportReasonProhibited = int8(1) // 违禁
ReportReasonPorn = int8(2) // 色情
RptReasonFraud = int8(3) // 赌博诈骗
ReportReasonAttack = int8(4) // 人身攻击
ReportReasonPrivate = int8(5) // 隐私
ReportReasonAd = int8(6) // 广告
ReportReasonWar = int8(7) // 引战
ReportReasonSpoiler = int8(8) // 剧透
ReportReasonMeaningless = int8(9) // 刷屏
ReportReasonUnrelated = int8(10) // 视频不相关
ReportReasonOther = int8(11) // 其他
ReportReasonTeenagers = int8(12) // 青少年不良信息
)
// var const map
var (
RptTemplate = map[string]string{
"del": `您好,您在视频#{%s}{"http://www.bilibili.com/av%d"}中举报的弹幕『%s』已被删除%s原因是『%s』感谢您对bilibili社区秩序的维护哔哩哔哩 (゜-゜)つロ 干杯~`,
"ignore": `您好,非常感谢您的举报,您在视频#{%s}{"http://www.bilibili.com/av%d"}中举报的弹幕『%s』暂未认定为违规内容具体弹幕规范烦请参阅 #{《弹幕礼仪》}{"http://www.bilibili.com/blackboard/help.html#d5"},哔哩哔哩 (゜-゜)つロ 干杯~`,
}
PostTemplate = map[int8]string{
1: `您好,根据用户举报,您在视频#{%s}{"http://www.bilibili.com/av%d"}中的弹幕『%s』已被删除%s原因是『%s』请自觉遵守国家相关法律法规具体弹幕规范烦请参阅#{《弹幕礼仪》}{"http://www.bilibili.com/blackboard/help.html#d5"}bilibili良好的社区氛围需要大家一起维护`,
2: `您好,根据用户举报,您在视频#{%s}{"http://www.bilibili.com/av%d"}中的弹幕『%s』已被删除%s原因是『%s』bilibili倡导平等友善的交流具体弹幕规范烦请参阅#{《弹幕礼仪》}{"http://www.bilibili.com/blackboard/help.html#d5"},良好的社区氛围需要大家一起维护!`,
3: `您好,根据用户举报,您在视频#{%s}{"http://www.bilibili.com/av%d"}中的弹幕『%s』已被删除%s原因是『%s』弹幕是公众场所而非私人场所具体弹幕规范烦请参阅#{《弹幕礼仪》}{"http://www.bilibili.com/blackboard/help.html#d5"},良好的社区氛围需要大家一起维护!`,
4: `您好,根据用户举报,您在视频#{%s}{"http://www.bilibili.com/av%d"}中的弹幕『%s』已被删除%s原因是『%s』bilibili倡导发送与视频相关、有用的弹幕具体弹幕规范烦请参阅#{《弹幕礼仪》}{"http://www.bilibili.com/blackboard/help.html#d5"},良好的社区氛围需要大家一起维护!`,
}
AdminRptReason = map[int8]string{
1: "内容涉及传播不实信息",
2: "内容涉及非法网站信息",
3: "内容涉及怂恿教唆信息",
4: "内容涉及低俗信息",
5: "内容涉及色情",
6: "内容涉及赌博诈骗信息",
7: "内容涉及人身攻击",
8: "内容涉及侵犯他人隐私",
9: "内容涉及垃圾广告",
10: "内容涉及引战",
11: "内容涉及视频剧透",
12: "恶意刷屏",
13: "视频不相关",
14: "其他",
15: "内容涉及违禁相关",
16: "内容不适宜",
17: "内容涉及青少年不良信息",
}
BlockReason = map[int8]string{
4: "发布赌博诈骗信息",
5: "发布违禁相关信息",
6: "发布垃圾广告信息",
7: "发布人身攻击言论",
8: "发布侵犯他人隐私信息",
9: "发布引战言论",
10: "发布剧透信息",
13: "发布色情信息",
14: "发布低俗信息",
17: "发布非法网站信息",
18: "发布传播不实信息",
19: "发布怂恿教唆信息",
20: "恶意刷屏",
24: "发布青少年不良内容",
}
)
// ReportListParams .
type ReportListParams struct {
States []int64 `form:"state,split"`
UpOps []int64 `form:"upop,split"`
Tids []int64 `form:"tid,split"`
Aid int64 `form:"aid"`
Cid int64 `form:"cid"`
UID int64 `form:"uid"`
RpUID int64 `form:"rp_user"`
RpTypes []int64 `form:"rp_type,split"`
Start string `form:"start"`
End string `form:"end"`
Sort string `form:"sort"`
Order string `form:"order"`
Keyword string `form:"keyword"`
Page int32 `form:"page" default:"1"`
PageSize int32 `form:"page_size" default:"100" validate:"max=1000"`
}
// Report dm report struct.
type Report struct {
DidStr string `json:"dmid_str"` // str id
ID int64 `json:"id"`
Did int64 `json:"dmid"` // 弹幕id
Cid int64 `json:"cid"` // 视频的id
Aid int64 `json:"arc_aid"` // 稿件的id
Tid int64 `json:"arc_typeid"` // 稿件的分区id
UID int64 `json:"dm_owner_uid"` // 弹幕发送者的uid
Msg string `json:"dm_msg"` // 弹幕内容
Count int64 `json:"count"` // 被举报次数
Content string `json:"content"` // 举报内容:只有类别其他才有值
UpOP int8 `json:"up_op"` // up主操作状态
State int8 `json:"state"` // 举报状态
RpUID int64 `json:"uid"` // 最后一个举报用户id
RpTime string `json:"rp_time"` // 举报时间
RpType int64 `json:"reason"` // 举报类型
Title string `json:"arc_title"` // 稿件标题
Deleted int64 `json:"dm_deleted"` // 弹幕状态
UPUid int64 `json:"arc_mid"` // up主id
PoolID int64 `json:"pool_id"` // 弹幕池
Model int64 `json:"model"` // 弹幕model
Score int32 `json:"score"` // 举报分
SendTime string `json:"dm_ctime"` // 弹幕发送时间
Ctime string `json:"ctime"` // 插入时间
Mtime string `json:"mtime"` // 更新时间
RptUsers []*ReportUser `json:"user"` // 举报用户列表
}
// ReportMsg report message
type ReportMsg struct {
Aid int64
Uids string
Did int64
Title string
Msg string
State int8
RptReason int8
BlockReason int8
Block int64
}
// ReportJudge report judge
type ReportJudge struct {
AID int64 `json:"aid"`
MID int64 `json:"mid"`
Operator string `json:"operator"`
OperID int64 `json:"oper_id"`
OContent string `json:"origin_content"`
OTitle string `json:"origin_title"`
OType int64 `json:"origin_type"`
OURL string `json:"origin_url"`
ReasonType int64 `json:"reason_type"`
OID int64 `json:"oid"`
RPID int64 `json:"rp_id"`
TagID int64 `json:"tag_id"`
Type int64 `json:"type"`
Page int64 `json:"page"`
BTime int64 `json:"business_time"`
}
// SearchReportResult dm repost list from search
type SearchReportResult struct {
Code int64 `json:"code"`
Order string `json:"order"`
Sort string `json:"sort"`
Page *struct {
Num int64 `json:"num"`
Size int64 `json:"size"`
Total int64 `json:"total"`
} `json:"page"`
Result []*Report `json:"result"`
}
// UptSearchReport update search report
type UptSearchReport struct {
DMid int64 `json:"dmid"`
State int8 `json:"state"`
Ctime string `json:"ctime"`
Mtime string `json:"mtime"`
}
// ReportList dm report list
type ReportList struct {
Code int64 `json:"code"`
Order string `json:"order"`
Page int64 `json:"page"`
PageSize int64 `json:"pagesize"`
PageCount int64 `json:"pagecount"`
Total int64 `json:"total"`
Result []*Report `json:"result"`
}
// ReduceMoral reduce moral
type ReduceMoral struct {
UID int64
Moral int64
Origin int8
Reason int8
ReasonType int8
Operator string
IsNotify int8
Remark string
}
// BlockUser block user
type BlockUser struct {
UID int64
BlockForever int64
BlockTimeLength int64
BlockRemark string
Operator string
OriginType int64
Moral int64
ReasonType int64
OriginTitle string
OriginContent string
OriginURL string
IsNotify int64
}
// ReportUser report user
type ReportUser struct {
ID int64 `json:"id"`
Did int64 `json:"dmid"`
UID int64 `json:"uid"`
Reason int64 `json:"reason"`
State int8 `json:"state"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// ReportLog dm admin log
type ReportLog struct {
ID int64 `json:"id"`
Did int64 `json:"dmid"`
AdminID int64 `json:"admin_id"`
Reason int8 `json:"reason"`
Result int8 `json:"result"`
Remark string `json:"remark"`
Elapsed int64 `json:"elapsed"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// PosterBlockMsg return report msg template by blockReason
func PosterBlockMsg(reason int8) (str string, err error) {
var (
tmplKey int8
)
switch reason {
case 4, 5, 13, 14, 17, 18, 19, 20, 24:
tmplKey = 1
case 6, 9:
tmplKey = 2
case 7, 8, 10, 12:
tmplKey = 3
default:
err = fmt.Errorf("BlockReason %d not exist", reason)
return
}
str = PostTemplate[tmplKey]
return
}
// PosterAdminRptMsg return report msg template by adminRptReason
func PosterAdminRptMsg(reason int8) (str string, err error) {
var (
tmplKey int8
)
switch reason {
case 1, 2, 3, 4, 5, 6, 15, 17:
tmplKey = 1
case 7, 10:
tmplKey = 2
case 8, 9, 11, 12:
tmplKey = 3
case 13, 14, 16:
tmplKey = 4
default:
err = fmt.Errorf("adminRptReason %d not exist", reason)
return
}
str = PostTemplate[tmplKey]
return
}
// RpReasonToJudgeReason 修改弹幕风纪委的理由
func RpReasonToJudgeReason(r int8) (j int8) {
switch r {
case ReportReasonProhibited:
j = 5
case ReportReasonPorn:
j = 13
case RptReasonFraud:
j = 4
case ReportReasonAttack:
j = 7
case ReportReasonPrivate:
j = 8
case ReportReasonAd:
j = 6
case ReportReasonWar:
j = 9
case ReportReasonSpoiler:
j = 10
case ReportReasonMeaningless:
j = 20
}
return
}
// CheckStateBelong check state first or second check
func CheckStateBelong(state int8) string {
if state == StatFirstInit || state == StatFirstDelete || state == StatFirstIgnore {
return "弹幕举报一审"
}
return "弹幕举报二审"
}

View File

@@ -0,0 +1,111 @@
package model
import (
"go-common/library/time"
)
// All const variable used in dm subject
const (
AttrNo = int32(0) // no
AttrYes = int32(1) // yes
SubTypeVideo = int32(1) // 主题类型
SubStateOpen = int32(0) // 主题打开
SubStateClosed = int32(1) // 主题关闭
AttrSubGuest = uint(0) // 允许游客弹幕
AttrSubSpolier = uint(1) // 允许剧透弹幕
AttrSubMission = uint(2) // 允许活动弹幕
AttrSubAdvance = uint(3) // 允许高级弹幕
AttrSubMonitorBefore = uint(4) // 弹幕先审后发
AttrSubMonitorAfter = uint(5) // 弹幕先发后审
AttrSubMaskOpen = uint(6) // 开启蒙版
AttrSubMblMaskReady = uint(7) // 移动端蒙版生产完成
AttrSubWebMaskReady = uint(8) // web端蒙版生产完成
)
// Subject dm_subject
type Subject struct {
ID int64 `json:"id"`
Type int32 `json:"type"`
Oid int64 `json:"oid"`
Pid int64 `json:"pid"`
Mid int64 `json:"mid"`
State int32 `json:"state"`
Attr int32 `json:"attr"`
ACount int64 `json:"acount"`
Count int64 `json:"count"`
MCount int64 `json:"mcount"`
MoveCnt int64 `json:"move_count"`
Maxlimit int64 `json:"maxlimit"`
Childpool int32 `json:"childpool"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// SubjectLog subject log
type SubjectLog struct {
UID int64 `json:"uid"`
Uname string `json:"uname"`
Oid int64 `json:"oid"`
Action string `json:"action"`
Comment string `json:"comment"`
Ctime string `json:"ctime"`
}
// SeasonInfo season info.
type SeasonInfo struct {
Aid int64 `json:"aid"`
Cid int64 `json:"cid"`
Epid int64 `json:"ep_id"`
Ssid int64 `json:"season_id"`
State int64 `json:"is_delete"`
LTitle string `json:"long_title"`
Title string `json:"title"`
}
// SearchSubjectReq search subject request.
type SearchSubjectReq struct {
Oids, Aids, Mids, Attrs []int64
State int64
Pn, Ps int64
Sort, Order string
}
// SearchSubjectResult result from search
type SearchSubjectResult struct {
Page *Page
Result []*struct {
Oid int64 `json:"oid"`
} `json:"result"`
}
// SearchSubjectLog get subject logs
type SearchSubjectLog struct {
Page *Page
Result []*struct {
UID int64 `json:"uid"`
Uname string `json:"uname"`
Oid int64 `json:"oid"`
Action string `json:"action"`
ExtraData string `json:"extra_data"`
Ctime string `json:"ctime"`
}
}
// AttrVal return val of subject'attr
func (s *Subject) AttrVal(bit uint) int32 {
return (s.Attr >> bit) & int32(1)
}
// AttrSet set val of subject'attr
func (s *Subject) AttrSet(v int32, bit uint) {
s.Attr = s.Attr&(^(1 << bit)) | (v << bit)
}
// IsMonitoring check if the subject is monitoring or not.
func (s *Subject) IsMonitoring() bool {
return s.AttrVal(AttrSubMonitorBefore) == AttrYes ||
s.AttrVal(AttrSubMonitorAfter) == AttrYes
}

View File

@@ -0,0 +1,248 @@
package model
import (
"fmt"
)
var (
_upTpl = `由#{%s}{"http://space.bilibili.com/%d"}在您的稿件《#{%s}{"http://www.bilibili.com/video/av%d"}》下创作的%s语言版本的字幕已被管理员流转到%s。《#{查看详情}{"https://member.bilibili.com/v2#/zimu/my-zimu/zimu-editor?aid=%d&cid=%d&subtitleId=%d"}》)`
_userTpl = `您在稿件《#{%s}{"http://www.bilibili.com/video/av%d"}》下创作的%s语言版本的字幕已被管理员流转到%s状态。《#{查看详情}{"https://member.bilibili.com/v2#/zimu/my-zimu/zimu-editor?aid=%d&cid=%d&subtitleId=%d"}》)`
// StatusContent .
StatusContent = map[uint8]string{
uint8(SubtitleStatusDraft): "草稿",
uint8(SubtitleStatusToAudit): "待审核",
uint8(SubtitleStatusAuditBack): "驳回",
uint8(SubtitleStatusRemove): "删除",
uint8(SubtitleStatusPublish): "发布",
uint8(SubtitleStatusManagerBack): "管理员驳回",
uint8(SubtitleStatusManagerRemove): "管理员删除",
}
)
// WorkFlowSubtitleDispose .
const (
WorkFlowSubtitleDisposeManagerBack = int32(2) // 管理员回退
WorkFlowSubtitleDisposeManagerDelete = int32(3) // 管理员删除
)
// SubtitleStatus .
type SubtitleStatus uint8
// SubtitleStatus
const (
SubtitleStatusUnknown SubtitleStatus = iota
SubtitleStatusDraft
SubtitleStatusToAudit
SubtitleStatusAuditBack
SubtitleStatusRemove
SubtitleStatusPublish
SubtitleStatusCheckToAudit
SubtitleStatusCheckPublish
SubtitleStatusManagerBack
SubtitleStatusManagerRemove
)
// WorkFlowSubtitleArg .
type WorkFlowSubtitleArg struct {
Object *WorkFlowObject `json:"object"`
Targets []*WorkFlowTarget `json:"targets"`
}
// WorkFlowObject .
type WorkFlowObject struct {
Ids []int64 `json:"id"`
Business int64 `json:"business"`
Reason string `json:"reason"`
DisposeMode int32 `json:"dispose_mode"`
}
// WorkFlowTarget .
type WorkFlowTarget struct {
ID int64 `json:"id"`
Eid int64 `json:"eid"`
Oid int64 `json:"oid"`
}
// SearchSubtitleResult result from search
type SearchSubtitleResult struct {
Page *Page
Result []*struct {
Oid int64 `json:"oid"`
ID int64 `json:"id"`
} `json:"result"`
}
// SubtitleList .
type SubtitleList struct {
Page *Page `json:"page"`
Subtitles []*SearchSubtitle `json:"subtitles"`
}
// SearchSubtitle .
type SearchSubtitle struct {
ID int64 `json:"subtitle_id"`
Oid int64 `json:"oid"`
Aid int64 `json:"aid"`
ArchiveName string `json:"archive_name"`
VideoName string `json:"video_name"`
AuthorID int64 `json:"author_id"`
Lan string `json:"lan"`
LanDoc string `json:"lan_doc"`
Status uint8 `json:"status"`
IsSign bool `json:"is_sign"`
IsLock bool `json:"is_lock"`
SubtitleURL string `json:"subtitle_url"`
Mtime int64 `json:"mtime"`
}
// SubtitlePub .
type SubtitlePub struct {
Oid int64
Type int32
Lan uint8
SubtitleID int64
IsDelete bool
}
// Subtitle .
type Subtitle struct {
ID int64 `json:"id"`
Oid int64 `json:"oid"`
Type int32 `json:"type"`
Lan uint8 `json:"lan"`
Aid int64 `json:"aid"`
Mid int64 `json:"mid"`
AuthorID int64 `json:"author_id"`
UpMid int64 `json:"up_mid"`
IsSign bool `json:"is_sign"`
IsLock bool `json:"is_lock"`
Status SubtitleStatus `json:"status"`
PubTime int64 `json:"-"`
SubtitleURL string `json:"subtitle_url"`
Mtime int64 `json:"mtime"`
}
// SubtitleSearchArg .
type SubtitleSearchArg struct {
Aid int64
Oid int64
Mid int64
UpperMid int64
Status uint8
Lan uint8
Ps int32
Pn int32
}
// SubtitleArg .
type SubtitleArg struct {
Aid int64 `form:"aid"`
Oid int64 `form:"oid"`
Mid int64 `form:"mid"`
UpperMid int64 `form:"up_mid"`
Status uint8 `form:"status"`
Lan string `form:"lan"`
Ps int32 `form:"ps" validate:"required"`
Pn int32 `form:"pn" validate:"required"`
}
// EditSubtitleArg .
type EditSubtitleArg struct {
Oid int64 `form:"oid" validate:"required"`
SubtileID int64 `form:"subtitle_id" validate:"required"`
Status uint8 `form:"status"`
NotifyAuthor bool `form:"notify_author"`
NotifyUpper bool `form:"notify_upper"`
}
// SubtitleContext .
type SubtitleContext struct {
// UpdateStatus bool // 更新状态 无事务
DraftCache bool // 删除草稿缓存
SubtitleCache bool // 删除字幕个体缓存 (必须)
RebuildPub bool // 触发到发布状态
CheckHasDraft bool // 处罚到草稿状态
}
// Build .
func (sc *SubtitleContext) Build(origin, dst SubtitleStatus) {
sc.SubtitleCache = true
switch origin {
case SubtitleStatusDraft, SubtitleStatusToAudit:
sc.DraftCache = true
case SubtitleStatusPublish:
sc.RebuildPub = true
}
switch dst {
case SubtitleStatusDraft, SubtitleStatusToAudit:
sc.CheckHasDraft = true
case SubtitleStatusPublish:
sc.RebuildPub = true
}
}
// SubtitleLans .
type SubtitleLans []*SubtitleLan
// SubtitleLan .
type SubtitleLan struct {
Code int64 `json:"code"`
Lan string `json:"lan"`
DocZh string `json:"doc_zh"`
DocEn string `json:"-"`
}
// GetByLan .
func (ss SubtitleLans) GetByLan(lan string) (code int64) {
for _, s := range ss {
if s.Lan == lan {
return s.Code
}
}
return 0
}
// GetByID .
func (ss SubtitleLans) GetByID(lanID int64) (lan string, doc string) {
for _, s := range ss {
if s.Code == lanID {
return s.Lan, s.DocZh
}
}
return
}
// NotifySubtitleUser .
type NotifySubtitleUser struct {
Mid int64
Aid int64
Oid int64
SubtitleID int64
ArchiveName string
LanDoc string
Status string
}
// NotifySubtitleUp .
type NotifySubtitleUp struct {
Mid int64
AuthorID int64
AuthorName string
Aid int64
Oid int64
SubtitleID int64
ArchiveName string
LanDoc string
Status string
}
// Msg .
func (ns *NotifySubtitleUp) Msg() string {
return fmt.Sprintf(_upTpl, ns.AuthorName, ns.AuthorID, ns.ArchiveName, ns.Aid, ns.LanDoc, ns.Status, ns.Aid, ns.Oid, ns.SubtitleID)
}
// Msg .
func (ns *NotifySubtitleUser) Msg() string {
return fmt.Sprintf(_userTpl, ns.ArchiveName, ns.Aid, ns.LanDoc, ns.Status, ns.Aid, ns.Oid, ns.SubtitleID)
}

View File

@@ -0,0 +1,24 @@
package model
// Subtitle state
const (
AttrSubtitleClose = uint(1) // 关闭稿件字幕
)
// SubtitleSubject .
type SubtitleSubject struct {
Aid int64 `json:"aid"`
Allow bool `json:"allow"`
Attr int32 `json:"attr"`
Lan uint8 `json:"lan"`
}
// AttrVal return val of subtitle subject'attr
func (s *SubtitleSubject) AttrVal(bit uint) int32 {
return (s.Attr >> bit) & int32(1)
}
// AttrSet set val of subtitle subject'attr
func (s *SubtitleSubject) AttrSet(v int32, bit uint) {
s.Attr = s.Attr&(^(1 << bit)) | (v << bit)
}

View File

@@ -0,0 +1,113 @@
package model
// TaskStateJump dm task jump a queue
const (
TaskRegexLen = 250 // dm task regex max length
// dm task state
TaskReviewPass = int32(2)
TaskStateRun = int32(3)
TaskStateFailed = int32(4)
)
// TaskList dm task info list
type TaskList struct {
Page *PageInfo
Result []*TaskInfo `json:"result"`
}
// TaskView .
type TaskView struct {
ID int64 `json:"id"`
Title string `json:"title"`
Creator string `json:"creator"`
Reviewer string `json:"reviewer"`
Regex string `json:"regex"`
KeyWords string `json:"keywords"`
IPs string `json:"ips"`
Mids string `json:"mids"`
Cids string `json:"cids"`
Start string `json:"start"`
End string `json:"end"`
QCount int64 `json:"qcount"` //查询总数
Tcount int64 `json:"tcount"` //删除总数
State int32 `json:"state"`
Result string `json:"-"`
Ctime string `json:"ctime"`
Mtime string `json:"mtime"`
SubTask *SubTask `json:"sub,omitempty"`
}
// SubTask .
type SubTask struct {
ID int64 `json:"id"`
Operation int32 `json:"operation"`
Rate int32 `json:"rate"`
Tcount int64 `json:"tcount"` //删除总数
Start string `json:"start"`
End string `json:"end"`
}
// TaskInfo dm task info
type TaskInfo struct {
ID int64 `json:"id"`
Title string `json:"title"`
Creator string `json:"creator"`
Reviewer string `json:"reviewer"`
State int32 `json:"state"`
Result string `json:"result"`
Ctime string `json:"ctime"`
Mtime string `json:"mtime"`
}
// TaskListArg .
type TaskListArg struct {
Creator string `form:"creator"`
Reviewer string `form:"reviewer"`
Title string `form:"title"`
State int32 `form:"state" default:"-1"`
Ctime string `form:"ctime"`
Pn int64 `form:"pn" default:"1" validate:"gt=0"`
Ps int64 `form:"ps" default:"50" validate:"gt=0"`
}
// AddTaskArg .
type AddTaskArg struct {
Creator string
Title string `form:"title" validate:"required"`
Regex string `form:"regex"`
KeyWords string `form:"keywords"`
IPs string `form:"ips"`
Mids string `form:"mids"`
Cids string `form:"cids"`
Start string `form:"start" validate:"required"`
End string `form:"end" validate:"required"`
State int32 `form:"state" default:"0" validate:"gte=0"`
Operation int32 `form:"operation" default:"-1" `
OpTime string `form:"operation_time"`
OpRate int32 `form:"operation_rate" default:"100" validate:"gt=0"`
}
// ReviewTaskArg .
type ReviewTaskArg struct {
ID int64 `form:"id" validate:"required,gte=0"`
State int32 `form:"state" validate:"required,gte=0"`
Reviewer string
Topic string
}
// EditTasksStateArg .
type EditTasksStateArg struct {
IDs string `form:"ids" validate:"required"`
State int32 `form:"state" validate:"required,gte=0"`
}
// TaskViewArg .
type TaskViewArg struct {
ID int64 `form:"id" validate:"required,gte=0"`
}
// TaskCsvArg .
type TaskCsvArg struct {
ID int64 `form:"id" validate:"required,gte=0"`
}

View File

@@ -0,0 +1,40 @@
package model
import "go-common/library/time"
// all variable used in dm transfer
const (
TransferJobStateAll = int8(-1)
TransferJobStatInit = int8(0)
TransferJobStatFinished = int8(1)
TransferJobStatFailed = int8(2)
TransferJobStatTransfing = int8(3)
)
// TransList transfer list info
type TransList struct {
ID int64 `json:"id"` //弹幕转移ID
From int64 `json:"from"` //来源Cid
To int64 `json:"to"` //目标Cid
State int64 `json:"state"` //弹幕转移状态
Title string `json:"title"` //来源稿件标题
Ctime time.Time `json:"ctime"` //转移开始时间
}
// TransListRes return transfer list and page info
type TransListRes struct {
Result []*TransList `json:"result"`
Page *PageInfo `json:"page"`
}
// TransferJobInfo dm transfer info
type TransferJobInfo struct {
ID int64
FromCID int64
ToCID int64
MID int64
Offset float64
State int8
Ctime time.Time
Mtime time.Time
}