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,36 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"dm.go",
"filter.go",
"protect.go",
"report.go",
"subject.go",
"transfer.go",
],
importpath = "go-common/app/interface/main/dm/model",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = ["//library/time: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,98 @@
package model
import (
"hash/crc32"
"strconv"
"go-common/library/time"
)
// All const variable used in dm2
const (
AttrNo = int32(0) // 属性位为0
AttrYes = int32(1) // 属性位为1
AttrProtect = uint(0) // 保护弹幕
StateNormal = int32(0) // 普通状态
StateDelete = int32(1) // 删除状态
StateHide = int32(2) // 隐藏状态
StateBlock = int32(3) // 屏蔽状态
StateFilter = int32(4) // 过滤状态
StateMonitorBefore = int32(5) // 先审后发
StateMonitorAfter = int32(6) // 先发后审
StateSystemFilter = int32(7) // 敏感词过滤
StateReportDelete = int32(8) // 举报删除
StateAdminDelete = int32(9) // 弹幕管理删除
StateUserDelete = int32(10) // 用户删除
StateScriptDelete = int32(11) // 举报脚本删除
PoolNormal = int32(0) // 普通弹幕池
PoolSubtitle = int32(1) // 字幕弹幕池
PoolSpecial = int32(2) // 特殊弹幕池
NotFound = -1
)
// Hash 用户匿名弹幕uid hash
func Hash(uid int64, ip uint32) string {
var s uint32
if uid != 0 {
s = crc32.ChecksumIEEE([]byte(strconv.FormatInt(uid, 10)))
return strconv.FormatInt(int64(s), 16)
}
s = crc32.ChecksumIEEE([]byte(strconv.FormatInt(int64(ip), 10)))
return "D" + strconv.FormatInt(int64(s), 16)
}
// DM dm_index and dm_content
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)
}
// NeedDisplay 判断该条弹幕是否需要展示
func (d *DM) NeedDisplay() bool {
return d.State == StateNormal || d.State == StateMonitorAfter
}
// Content dm_content
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 dm_content_special
type ContentSpecial struct {
ID int64 `json:"id"`
Msg string `json:"msg"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}

View File

@ -0,0 +1,21 @@
package model
// IndexFilter for dm_index_filter
type IndexFilter struct {
ID int64 `json:"id"`
CID int64 `json:"cid"`
MID int64 `json:"mid"`
Filter string `json:"filter"`
Activate int8 `json:"activate"`
Regex int8 `json:"type"`
Ctime int64 `json:"ctime"`
}
// UserFilterList for member filter list
// to show global filter or video filter
type UserFilterList struct {
Top int8 `json:"accept_top"`
Bottom int8 `json:"accept_bottom"`
Reverse int8 `json:"accept_reverse"`
Filter []*IndexFilter `json:"filter_list"`
}

View File

@ -0,0 +1,111 @@
package model
import (
"time"
)
const (
// ProtectApplyLimit protect apply limit
ProtectApplyLimit = 20
)
// Pager comment
type Pager struct {
Total int `json:"total"`
Current int `json:"current"`
Size int `json:"size"`
TotalCount int `json:"total_count"`
}
// Pa 保护弹幕
type Pa struct {
ID int64
CID int64
UID int64
ApplyUID int64
AID int64
Playtime float32
DMID int64
Msg string
Status int
Ctime time.Time
Mtime time.Time
}
// Apply apply protect dm
type Apply struct {
ID int64 `json:"id"`
AID int64 `json:"aid"`
CID int64 `json:"cid"`
Title string `json:"title"`
ApplyUID int64 `json:"-"`
Pic string `json:"pic"`
Uname string `json:"uname"`
Msg string `json:"msg"`
Playtime float32 `json:"playtime"`
Ctime string `json:"ctime"`
}
// ApplySortPlaytime what
type ApplySortPlaytime []*Apply
func (c ApplySortPlaytime) Len() int {
return len(c)
}
func (c ApplySortPlaytime) Swap(i, j int) {
c[i], c[j] = c[j], c[i]
}
func (c ApplySortPlaytime) Less(i, j int) bool {
if c[i].CID == c[j].CID {
return c[i].Playtime < c[j].Playtime
}
return c[i].CID > c[j].CID
}
// ApplySortID what
type ApplySortID []*Apply
// Len get len
func (c ApplySortID) Len() int {
return len(c)
}
// Swap change dm
func (c ApplySortID) Swap(i, j int) {
c[i], c[j] = c[j], c[i]
}
// Less count
func (c ApplySortID) Less(i, j int) bool {
return c[i].ID > c[j].ID
}
// ApplyListResult get
type ApplyListResult struct {
Pager *Pager
List []*Apply
}
// Video video info
type Video struct {
Aid int64 `json:"aid"`
Title string `json:"title"`
}
// ApplyUserStat user stat
type ApplyUserStat struct {
Aid int64
UID int64
Status int
Ctime time.Time
}
// ApplyUserNotify user notify
type ApplyUserNotify struct {
Title string
Aid int64
Protect int
Unprotect int
}

View File

@ -0,0 +1,189 @@
package model
import (
"time"
)
// var const text
var (
ReportReason = map[int8]string{
1: "内容涉及违禁相关",
2: "内容涉及非法网站信息",
3: "内容涉及赌博诈骗信息",
4: "内容涉及人身攻击",
5: "内容涉及侵犯他人隐私",
6: "内容涉及垃圾广告",
7: "内容涉及引战",
8: "内容涉及视频剧透",
9: "恶意刷屏",
10: "视频不相关",
11: "其他",
12: "青少年不良信息",
}
RptMsgTitle = "举报处理结果通知"
RptMsgTemplate = `您好,您在视频#{%s}{"http://www.bilibili.com/av%d"}中举报的弹幕『%s』已被删除原因是『%s』感谢您对bilibili社区秩序的维护哔哩哔哩 (゜-゜)つロ 干杯~`
)
// 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) // 待二审
StatSecondIgnore = int8(3) // 二审忽略
StatSecondDelete = int8(4) // 二审删除
StatFirstIgnore = int8(5) // 一审忽略
StatSecondAutoDelete = int8(6) // 二审脚本删除
// 处理结果通知
NoticeUnsend = int8(0) // 未通知用户
NoticeSend = int8(1) // 已通知用户
// 举报原因
ReportReasonProhibited = int8(1) // 违禁
ReportReasonPorn = int8(2) // 色情
ReportReasonFraud = 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) // 青少年不良信息
)
// Report dm report info
type Report struct {
ID int64 `json:"id"` // 主键id
Cid int64 `json:"cid"` // 视频id
Did int64 `json:"dmid"` // 弹幕id
UID int64 `json:"uid"` // 举报用户的id
Reason int8 `json:"reason"` // 举报原因类型
Content string `json:"content"` // 举报内容reason为其它时有值
Count int64 `json:"count"` // 被举报次数
State int8 `json:"state"` // 举报状态
UpOP int8 `json:"up_op"` // up主操作
Score int32 `json:"score"` // 举报分
RpTime time.Time `json:"rp_time"` // 举报时间
Ctime time.Time `json:"ctime"` // 插入时间
Mtime time.Time `json:"mtime"` // 更新时间
}
// User report user info
type User struct {
ID int64 `json:"id"`
Did int64 `json:"dmid"`
UID int64 `json:"uid"`
Reason int8 `json:"reason"`
State int8 `json:"state"`
Content string `json:"content"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// RptLog dm admin log
type RptLog 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"`
}
// RptSearch report info from search
type RptSearch struct {
ID int64 `json:"id"`
Cid int64 `json:"cid"` // 视频的id
Did int64 `json:"dmid"` // 弹幕id
Aid int64 `json:"arc_aid"` // 稿件的id
Tid int64 `json:"arc_typeid"` // 稿件的分区id
Owner 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"` // 举报状态
UID int64 `json:"uid"` // 举报用户id
RpTime string `json:"rp_time"` // 举报时间
Reason int64 `json:"reason"` // 举报原因类型
Ctime string `json:"ctime"` // 插入时间
Mtime string `json:"mtime"` // 更新时间
Title string `json:"arc_title"` // 稿件标题
Deleted int64 `json:"dm_deleted"` // 弹幕状态
UPUid int64 `json:"arc_mid"` // up主id
Cover string `json:"arc_cover"` // 稿件的封面图
}
// RptSearchs report list
type RptSearchs struct {
Page int64 `json:"page"`
PageSize int64 `json:"pagesize"`
PageCount int64 `json:"pagecount"`
Total int64 `json:"total"`
Result []*RptSearch `json:"result"`
}
// UptSearchReport update search report
type UptSearchReport struct {
DMid int64 `json:"dmid"`
Upop int8 `json:"up_op"`
Ctime string `json:"ctime"`
Mtime string `json:"mtime"`
}
// Page search page
type Page struct {
Num int64 `json:"num"`
Size int64 `json:"size"`
Total int64 `json:"total"`
}
// SearchReportResult dm repost list from search
type SearchReportResult struct {
Page *Page `json:"page"`
Result []*RptSearch `json:"result"`
}
// SearchReportAidResult dm repost archive list from search
type SearchReportAidResult struct {
Page *Page `json:"page"`
Result map[string][]struct {
Key string `json:"key"`
} `json:"result"`
}
// RptMsg dm report message
type RptMsg struct {
Aid int64
UID int64
Did int64
Title string
Msg string
State int8
Reason int8
}
// Archives report archive list
type Archives struct {
Result []*struct {
Aid int64 `json:"aid"`
Title string `json:"title"`
} `json:"result"`
}
// ReportAction send dm info and hidetime
type ReportAction struct {
Cid int64 `json:"cid"` // 视频id
Did int64 `json:"dmid"` // 弹幕id
HideTime int64 `json:"hide_time"` // 弹幕隐藏截止时间
}

View File

@ -0,0 +1,50 @@
package model
import (
"go-common/library/time"
)
// All const variable used in dm subject
const (
SubTypeVideo = int32(1) // 主题类型
SubStateOpen = int32(0) // 主题打开
SubStateClosed = int32(1) // 主题关闭
AttrSubGuest = uint(0) // 允许游客弹幕
AttrSubSpolier = uint(1) // 允许剧透弹幕
AttrSubMission = uint(2) // 允许活动弹幕
AttrSubAdvance = uint(3) // 允许高级弹幕
// StateProtect protected dm
StateProtect = 2
)
// 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"`
}
// 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)
}

View File

@ -0,0 +1,50 @@
package model
import (
"time"
xtime "go-common/library/time"
)
// all variable used in dm transfer
const (
TransferJobStatInit = int8(0)
TransferJobStatFinished = int8(1)
TransferJobStatFailed = int8(2)
)
// TransferJob dm transfer
type TransferJob struct {
ID int64
FromCID int64
ToCID int64
MID int64
Offset float64
State int8
Ctime time.Time
Mtime time.Time
}
// TransferHistory transfer list item
type TransferHistory struct {
ID int64 `json:"id"`
PartID int32 `json:"part_id"`
CID int64 `json:"cid"`
Title string `json:"title"`
CTime xtime.Time `json:"ctime"`
State int8 `json:"state"`
}
// CidInfo is archive_video model.
type CidInfo struct {
Aid int64 `json:"aid"`
Title string `json:"title"`
Desc string `json:"desc"`
Filename string `json:"filename"`
Index int `json:"index"`
Status int16 `json:"status"`
StatusDesc string `json:"status_desc"`
FailCode int8 `json:"fail_code"`
FailDesc string `json:"fail_desc"`
CTime xtime.Time `json:"ctime"`
}