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,56 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library(
name = "go_default_library",
srcs = [
"archive.go",
"archive_state.go",
"biz_poi.go",
"biz_vote.go",
"desc_format.go",
"flow.go",
"forbid.go",
"history.go",
"msg.go",
"param.go",
"porder.go",
"report.go",
"staff.go",
"video.go",
],
importpath = "go-common/app/service/main/videoup/model/archive",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/log:go_default_library",
"//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"],
)
go_test(
name = "go_default_test",
srcs = ["video_test.go"],
embed = [":go_default_library"],
rundir = ".",
tags = ["automanaged"],
)

View File

@@ -0,0 +1,117 @@
package archive
import (
"go-common/library/time"
)
// Archive is archive model.
type Archive struct {
Aid int64 `json:"aid"`
Mid int64 `json:"mid"`
TypeID int16 `json:"tid"`
HumanRank int `json:"-"`
Title string `json:"title"`
Author string `json:"-"`
Cover string `json:"cover"`
RejectReason string `json:"reject_reason"`
Tag string `json:"tag"`
Duration int64 `json:"duration"`
Copyright int8 `json:"copyright"`
Desc string `json:"desc"`
MissionID int64 `json:"mission_id"`
Round int8 `json:"-"`
Forward int64 `json:"-"`
Attribute int32 `json:"attribute"`
Access int16 `json:"-"`
State int8 `json:"state"`
Source string `json:"source"`
NoReprint int32 `json:"no_reprint"`
UGCPay int32 `json:"ugcpay"`
OrderID int64 `json:"order_id"`
UpFrom int8 `json:"up_from"`
Dynamic string `json:"dynamic"`
DescFormatID int64 `json:"desc_format_id"`
Porder *Porder `json:"porder"`
Staffs []*StaffApply `json:"staffs"`
POI *PoiObj `json:"poi_object"`
Vote *Vote `json:"vote"`
DTime time.Time `json:"dtime"`
PTime time.Time `json:"ptime"`
CTime time.Time `json:"ctime"`
MTime time.Time `json:"mtime"`
}
// AttrSet set attribute.
func (a *Archive) AttrSet(v int32, bit uint) {
a.Attribute = a.Attribute&(^(1 << bit)) | (v << bit)
}
// AttrVal get attribute.
func (a *Archive) AttrVal(bit uint) int32 {
return (a.Attribute >> bit) & int32(1)
}
// NotAllowUp check archive is or not allow update state.
func (a *Archive) NotAllowUp() bool {
return a.State == StateForbidUpDelete || a.State == StateForbidLock || a.State == StateForbidPolice
}
// SimpleArchive str
type SimpleArchive struct {
Aid int64 `json:"aid"`
Title string `json:"title"`
Mid int64 `json:"mid"`
Videos []*Video `json:"videos,omitempty"`
}
// Addit str
type Addit struct {
Aid int64 `json:"aid"`
MissionID int64 `json:"mission_id"`
UpFrom int8 `json:"up_from"`
FromIP int64 `json:"from_ip"`
IPv6 []byte `json:"ipv6"`
Source string `json:"source"`
OrderID int64 `json:"order_id"`
RecheckReason string `json:"recheck_reason"`
RedirectURL string `json:"redirect_url"`
FlowID int64 `json:"flow_id"`
Advertiser string `json:"advertiser"`
FlowRemark string `json:"flow_remark"`
DescFormatID int64 `json:"desc_format_id"`
Desc string `json:"desc"`
Dynamic string `json:"dynamic"`
}
// Delay str
type Delay struct {
Aid int64
State int8
DTime time.Time
}
// Type info
type Type struct {
ID int16 `json:"id"`
PID int16 `json:"pid"`
Name string `json:"name"`
Desc string `json:"description"`
}
// Alert str
type Alert struct {
Key string
Value int64
Limit int64
}
// Up str
type Up struct {
ID int64 `json:"id"`
GroupID int64 `json:"group_id"`
GroupName string `json:"group_name" `
GroupTag string `json:"group_tag"`
Mid int64 `json:"mid"`
Note string `json:"note"`
CTime time.Time `json:"ctime"`
}

View File

@@ -0,0 +1,155 @@
package archive
// Const State
const (
// open state
StateOpen = int8(0)
StateOrange = int8(1)
// forbit state
StateForbidWait = int8(-1)
StateForbidRecicle = int8(-2)
StateForbidPolice = int8(-3)
StateForbidLock = int8(-4)
StateForbidFackLock = int8(-5)
StateForbidFixed = int8(-6)
StateForbidLater = int8(-7)
// StateForbidPatched = int8(-8)
StateForbidWaitXcode = int8(-9)
StateForbidAdminDelay = int8(-10)
StateForbidFixing = int8(-11)
// StateForbidStorageFail = int8(-12)
StateForbidOnlyComment = int8(-13)
// StateForbidTmpRecicle = int8(-14)
StateForbidDispatch = int8(-15)
StateForbidXcodeFail = int8(-16)
StateForbitUpLoad = int8(-20) // NOTE:spell body can judge to change state
StateForbidSubmit = int8(-30)
StateForbidUserDelay = int8(-40)
StateForbidUpDelete = int8(-100)
// attribute yes and no
AttrYes = int32(1)
AttrNo = int32(0)
// attribute bit
AttrBitNoRank = uint(0)
AttrBitNoDynamic = uint(1)
AttrBitNoWeb = uint(2)
AttrBitNoMobile = uint(3)
AttrBitNoSearch = uint(4)
AttrBitOverseaLock = uint(5)
AttrBitNoRecommend = uint(6)
AttrBitNoReprint = uint(7)
AttrBitHasHD5 = uint(8)
AttrBitIsPGC = uint(9)
AttrBitAllowBp = uint(10)
AttrBitIsBangumi = uint(11)
AttrBitIsPorder = uint(12)
AttrBitLimitArea = uint(13)
AttrBitAllowTag = uint(14)
AttrBitIsFromArcAPI = uint(15) // TODO: delete
AttrBitJumpURL = uint(16)
AttrBitIsMovie = uint(17)
AttrBitBadgepay = uint(18)
AttrBitIsJapan = uint(19) //日文稿件
AttrBitNoPushBplus = uint(20) //是否动态禁止
AttrBitParentMode = uint(21) //家长模式
AttrBitUGCPay = uint(22) //UGC付费
AttrBitHasBGM = uint(23) //稿件带有BGM
AttrBitSTAFF = uint(24) //联合投稿
// copyright state
CopyrightUnknow = int8(0)
CopyrightOriginal = int8(1)
CopyrightCopy = int8(2)
// up_from
UpFromWeb = int8(0)
UpFromPGC = int8(1)
UpFromWindows = int8(2)
UpFromAPP = int8(3)
UpFromMAC = int8(4)
UpFromSecretPGC = int8(5)
UpFromCoopera = int8(6)
UpFromCreator = int8(7) // 创作姬
// delay
DelayTypeForAdmin = int8(1)
DelayTypeForUser = int8(2)
// flow type
FlowNotLimit = int8(1)
FlowBudgeting = int8(2)
FlowCapping = int8(3)
FlowForbid = int8(4)
// flow design type
FlowDesignAppFeed = int8(0)
FlowDesignUp = int8(1)
FlowDesignPrivate = int8(2)
// oper uid
AutoOperUID = int64(399)
CMOperUID = int64(518)
// archive list type for up
UpArcAllIn = int8(0)
UpArcOpenIn = int8(1)
UpArcUnOpenIn = int8(2)
VideoFilenameTimeout = int64(48 * 60 * 60)
)
var (
_attr = map[int32]int32{
AttrNo: AttrNo,
AttrYes: AttrYes,
}
_copyright = map[int8]int8{
CopyrightUnknow: CopyrightUnknow,
CopyrightOriginal: CopyrightOriginal,
CopyrightCopy: CopyrightCopy,
}
_bits = map[uint]string{
AttrBitNoRank: "排行禁止",
AttrBitNoDynamic: "动态禁止",
AttrBitNoWeb: "禁止web端输出",
AttrBitNoMobile: "禁止移动端输出",
AttrBitNoSearch: "禁止搜索",
AttrBitOverseaLock: "海外禁止",
AttrBitNoRecommend: "推荐禁止",
AttrBitNoReprint: "禁止转载",
AttrBitHasHD5: "高清1080P",
AttrBitIsPGC: "PGC稿件",
AttrBitAllowBp: "允许承包",
AttrBitIsBangumi: "番剧",
// AttrBitAllowDownload: AttrBitAllowDownload,
// AttrBitHideClick: AttrBitHideClick,
AttrBitAllowTag: "允许操作TAG",
// AttrBitIsFromArcApi: AttrBitIsFromArcApi,
AttrBitJumpURL: "跳转",
AttrBitIsMovie: "电影",
AttrBitBadgepay: "付费",
}
// oversea forbidden typeid
_overseaTypes = map[int16]int16{
32: 32, //'完结动画'
33: 33, //'连载动画'
}
)
// InCopyrights in correct copyrights.
func InCopyrights(cp int8) (ok bool) {
_, ok = _copyright[cp]
return
}
// BitDesc return bit desc.
func BitDesc(bit uint) (desc string) {
return _bits[bit]
}
// InAttr in correct attrs.
func InAttr(attr int32) (ok bool) {
_, ok = _attr[attr]
return
}
// InOverseaType check in oversea forbid type.
func InOverseaType(typeID int16) (ok bool) {
_, ok = _overseaTypes[typeID]
return
}

View File

@@ -0,0 +1,40 @@
package archive
// BIZPOI 1
const (
BIZPOI = int64(1)
)
// PoiObj str
type PoiObj struct {
POI string `json:"poi"`
Type int32 `json:"type"`
Addr string `json:"address"`
Title string `json:"title"`
ShowTitle string `json:"show_title"`
AdInfo *AdInfo `json:"ad_info"`
Ancestors []*Ancestor `json:"ancestors"`
Distance float64 `json:"distance"`
ShowDistrance string `json:"show_distance"`
Location *Location `json:"location"`
}
// AdInfo str
type AdInfo struct {
Nation string `json:"nation"`
Provin string `json:"province"`
Distri string `json:"district"`
City string `json:"city"`
}
// Ancestor str
type Ancestor struct {
POI string `json:"poi"`
Type int32 `json:"type"`
}
// Location str
type Location struct {
Lat float64 `json:"lat"`
Lng float64 `json:"lng"`
}

View File

@@ -0,0 +1,12 @@
package archive
const (
// BIZVote Business Type Vote
BIZVote = int64(2)
)
//Vote .
type Vote struct {
VoteID int64 `json:"vote_id"`
VoteTitle string `json:"vote_title"`
}

View File

@@ -0,0 +1,11 @@
package archive
// DescFormat is desc model.
type DescFormat struct {
ID int64 `json:"id"`
TypeID int16 `json:"typeid"`
Copyright int8 `json:"copyright"`
Components string `json:"components"`
Lang int8 `json:"lang"`
Platform int8 `json:"platform"`
}

View File

@@ -0,0 +1,80 @@
package archive
import (
"encoding/json"
"go-common/library/time"
)
// pool .
const (
PoolArc = int8(0)
PoolUp = int8(1)
PoolPorder = int8(2)
PoolArticle = int8(3)
PoolArcForbid = int8(4)
PoolArcPGC = int8(5)
FlowOpen = int8(0)
FlowDelete = int8(1)
FlowLogAdd = int8(1)
FlowLogUpdate = int8(2)
FlowLogDel = int8(3)
FlowGroupNoChannel = int64(23)
FlowGroupNoHot = int64(24)
FlowGroupNoTimeline = int64(25)
FlowGroupNoOtt = int64(26)
FlowGroupNoRecommend = int64(27)
FlowGroupNoRank = int64(28)
)
var (
//FlowAttrMap archive submit with flow attr
FlowAttrMap = map[string]int64{
"nochannel": FlowGroupNoChannel,
"nohot": FlowGroupNoHot,
"notimeline": FlowGroupNoTimeline,
"noott": FlowGroupNoOtt,
"norecommend": FlowGroupNoRecommend,
"norank": FlowGroupNoRank,
}
)
// Flow info
type Flow struct {
ID int64 `json:"id"`
Remark string `json:"remark"`
Rank int64 `json:"rank"`
Type int8 `json:"type"`
Value json.RawMessage `json:"value"`
CTime time.Time `json:"ctime"`
}
//FlowData Flow data
type FlowData struct {
ID int64 `json:"id"`
Pool int8 `json:"pool"`
OID int64 `json:"oid"`
UID int64 `json:"uid"`
Parent int8 `json:"parent"`
State int8 `json:"state"`
GroupID int64 `json:"group_id"`
Remark string `json:"remark"`
GroupValue []byte `json:"group_value"`
CTime time.Time `json:"ctime"`
MTime time.Time `json:"mtime"`
}
//FlowPagerData .
type FlowPagerData struct {
Items []*FlowData `json:"items"`
Pager *Pager `json:"pager,omitempty"`
}
//Pager .
type Pager struct {
Num int64 `json:"num"`
Size int64 `json:"size"`
Total int64 `json:"total"`
}

View File

@@ -0,0 +1,106 @@
package archive
// const Forbid Enum Values
const (
// Forbid style
ForbidRank = "rank"
ForbidDynamic = "dynamic"
ForbidRecommend = "recommend"
ForbidShow = "show"
// ForbidRank style
ForbidRankMain = 0
ForbidRankRecentArc = 1
ForbidRankAllArc = 2
// ForbidDynamic style
ForbidDynamicMain = 0
// ForbidRecommend style
ForbidRecommendMain = 0
// ForbidShow style
ForbidShowMain = 0
ForbidShowMobile = 1
ForbidShowWeb = 2
ForbidShowOversea = 3
ForbidShowOnline = 4
)
// ForbidAttr forbid attribute
type ForbidAttr struct {
Aid int64 `json:"aid"`
RankV int32 `json:"rank_attr"`
DynamicV int32 `json:"dynamic_attr"`
RecommendV int32 `json:"recommend_attr"`
ShowV int32 `json:"show_attr"`
SearchV int32 `json:"search"`
PushBlogV int32 `json:"push_blog"`
// specific
Rank struct {
Main int32 `json:"main"`
RecentArc int32 `json:"recent_arc"`
AllArc int32 `json:"all_arc"`
} `json:"_"`
Dynamic struct {
Main int32 `json:"main"`
} `json:"-"`
Recommend struct {
Main int32 `json:"main"`
} `json:"-"`
Show struct {
Main int32 `json:"main"`
Mobile int32 `json:"mobile"`
Web int32 `json:"web"`
Oversea int32 `json:"oversea"`
Online int32 `json:"online"`
} `json:"-"`
}
// Convert convert db value into attr.
func (f *ForbidAttr) Convert() {
// rank
f.Rank.Main = f.RankV & 1
f.Rank.RecentArc = (f.RankV >> 1) & 1
f.Rank.AllArc = (f.RankV >> 2) & 1
// dynamic
f.Dynamic.Main = f.DynamicV & 1
// recommend
f.Recommend.Main = f.RecommendV & 1
// show
f.Show.Main = f.ShowV & 1
f.Show.Mobile = (f.ShowV >> 1) & 1
f.Show.Web = (f.ShowV >> 2) & 1
f.Show.Oversea = (f.ShowV >> 3) & 1
f.Show.Online = (f.ShowV >> 4) & 1
}
// Reverse reverse attr into db value.
func (f *ForbidAttr) Reverse() {
// rank
f.RankV = (f.Rank.AllArc << 2) | (f.Rank.RecentArc << 1) | f.Rank.Main
// dynamic
f.DynamicV = f.Dynamic.Main
// recommend
f.RecommendV = f.Recommend.Main
// show
f.ShowV = (f.Show.Online << 4) | (f.Show.Oversea << 3) | (f.Show.Web << 2) | (f.Show.Mobile << 1) | f.Show.Main
}
// SetAttr set forbid attr.
func (f *ForbidAttr) SetAttr(name string, v int32, bit uint) (change bool) {
if name == ForbidRank {
old := f.RankV
f.RankV = f.RankV&(^(1 << bit)) | (v << bit)
change = old == f.RankV
} else if name == ForbidDynamic {
old := f.DynamicV
f.DynamicV = f.DynamicV&(^(1 << bit)) | (v << bit)
change = old == f.DynamicV
} else if name == ForbidRecommend {
old := f.RecommendV
f.RecommendV = f.RecommendV&(^(1 << bit)) | (v << bit)
change = old == f.RecommendV
} else if name == ForbidShow {
old := f.ShowV
f.ShowV = f.ShowV&(^(1 << bit)) | (v << bit)
change = old == f.ShowV
}
return
}

View File

@@ -0,0 +1,27 @@
package archive
import "go-common/library/time"
// ArcHistory archive edit history.
type ArcHistory struct {
ID int64 `json:"id,omitempty"`
Aid int64 `json:"aid,omitempty"`
Title string `json:"title,omitempty"`
Tag string `json:"tag,omitempty"`
Content string `json:"content,omitempty"`
Cover string `json:"cover,omitempty"`
Mid int64 `json:"mid,omitempty"`
CTime time.Time `json:"ctime,omitempty"`
VideoHistory []*VideoHistory `json:"videos,omitempty"`
}
// VideoHistory video edit history.
type VideoHistory struct {
ID int64 `json:"-"`
Aid int64 `json:"-"`
Cid int64 `json:"cid"`
Hid int64 `json:"-"`
Title string `json:"title"`
Desc string `json:"desc"`
Filename string `json:"filename"`
}

View File

@@ -0,0 +1,105 @@
package archive
import (
"fmt"
)
// const .
const (
MSG_1 = int(1)
MSG_2 = int(2)
MSG_3 = int(3)
MSG_4 = int(4)
MSG_5 = int(5)
MSG_6 = int(6)
MSG_7 = int(7)
MSG_8 = int(8)
MSG_9 = int(9)
MSG_10 = int(10)
MSG_11 = int(11)
MSG_12 = int(12)
MSG_13 = int(13)
)
// MSG .
type MSG struct {
To string
MSGID int
Code string
Title string
Content string
}
// ArgMsg .
type ArgMsg struct {
MSGID int
Apply *ApplyParam
}
// MsgInfo .
func (arg *ArgMsg) MsgInfo(msg *MSG) (mids []int64, title, content, code string) {
switch arg.MSGID {
/*
1up主xxxx邀请您作为xxxx参与稿件《xxxx》avxxxxx的多人合作在网页端创作中心查看吧点击查看
2参与者xxxx已接受您的邀请作为xxxx参与稿件《xxxx》avxxxxx的多人合作在网页端创作中心查看吧点击查看
3参与者xxxx已拒绝您的邀请作为xxxx参与稿件《xxxx》avxxxxx的多人合作在网页端创作中心查看吧点击查看
4up主xxxx申请您参与稿件《xxxx》avxxxx的参与类型由xxxx变更为xxxx在网页端创作中心查看吧点击查看
5参与者已同意您申请其参与稿件《xxxx》avxxxx的参与类型由xxxx变更为xxxx在网页端创作中心查看吧点击查看
6参与者已拒绝您申请其参与稿件《xxxx》avxxxx的参与类型由xxxx变更为xxxx在网页端创作中心查看吧点击查看
7合作者xxxx申请终止其作为稿件《xxxx》avxxxxx的xxxx的多人合作在网页端创作中心查看吧点击查看
8up主xxxx已终止参与者xxxx作为稿件《xxxx》avxxxx的xxxx的多人合作在网页端创作中心查看吧点击查看
9up主xxxx申请终止您作为稿件xxxxxxaidxxxxx的xxx的多人合作在网页端创作中心查看吧点击查看
10 up主xxxx已终止参与者xxxx作为稿件《xxxx》avxxxx的xxxx的多人合作在网页端创作中心查看吧点击查看
11 up主xxxx未能终止参与者xxxx作为稿件《xxxx》avxxxx的xxxx的多人合作在网页端创作中心查看吧点击查看
12 管理员解除了您与参与者xxx在稿件《xxxx》《avxxxx》中合作关系在网页端创作中心查看吧点击查看
13 管理员解除了您与up主xxxx在稿件《xxxx》《avxxxx》中合作关系在网页端创作中心查看吧点击查看
*/
case MSG_1:
//content = 'up主%s邀请您作为%s参与稿件《%s》av%d的多人合作在网页端创作中心查看吧#{点击查看}{"https://member.bilibili.com/v2#/upload-manager/article/cooperation"}”'
return []int64{arg.Apply.ApplyStaffMID}, msg.Title, fmt.Sprintf(msg.Content, arg.Apply.UpName, arg.Apply.ApplyTitle, arg.Apply.Archive.Title, arg.Apply.Archive.Aid), msg.Code
case MSG_2:
//content = '参与者%s已接受您的邀请作为%s参与稿件《%s》av%d的多人合作在网页端创作中心查看吧#{点击查看}{"https://member.bilibili.com/v2#/upload-manager/article"}”'
return []int64{arg.Apply.ApplyUpMID}, msg.Title, fmt.Sprintf(msg.Content, arg.Apply.StaffName, arg.Apply.ApplyTitle, arg.Apply.Archive.Title, arg.Apply.Archive.Aid), msg.Code
case MSG_3:
//content = '参与者%s已拒绝您的邀请作为%s参与稿件《%s》av%d的多人合作在网页端创作中心查看吧#{点击查看}{"https://member.bilibili.com/v2#/upload-manager/article"}”'
return []int64{arg.Apply.ApplyUpMID}, msg.Title, fmt.Sprintf(msg.Content, arg.Apply.StaffName, arg.Apply.ApplyTitle, arg.Apply.Archive.Title, arg.Apply.Archive.Aid), msg.Code
case MSG_4:
//content = 'up主%s申请您参与稿件《%s》av%d的参与类型由%s变更为%s在网页端创作中心查看吧#{点击查看}{"https://member.bilibili.com/v2#/upload-manager/article/cooperation"}”'
return []int64{arg.Apply.ApplyStaffMID}, msg.Title, fmt.Sprintf(msg.Content, arg.Apply.UpName, arg.Apply.Archive.Title, arg.Apply.Archive.Aid, arg.Apply.StaffTitle, arg.Apply.ApplyTitle), msg.Code
case MSG_5:
//content = '参与者%s已同意您申请其参与稿件《%s》av%d的参与类型由%s变更为%s在网页端创作中心查看吧#{点击查看}{"https://member.bilibili.com/v2#/upload-manager/article"}”'
return []int64{arg.Apply.ApplyUpMID}, msg.Title, fmt.Sprintf(msg.Content, arg.Apply.StaffName, arg.Apply.Archive.Title, arg.Apply.Archive.Aid, arg.Apply.StaffTitle, arg.Apply.ApplyTitle), msg.Code
case MSG_6:
//content = '参与者%s已拒绝您申请其参与稿件《%s》av%d的参与类型由%s变更为%s在网页端创作中心查看吧#{点击查看}{"https://member.bilibili.com/v2#/upload-manager/article"}”'
return []int64{arg.Apply.ApplyUpMID}, msg.Title, fmt.Sprintf(msg.Content, arg.Apply.StaffName, arg.Apply.Archive.Title, arg.Apply.Archive.Aid, arg.Apply.StaffTitle, arg.Apply.OldTitle), msg.Code
case MSG_7:
// content = '合作者%s申请终止其作为稿件《%s》av%d的%s的多人合作在网页端创作中心查看吧#{点击查看}{"https://member.bilibili.com/v2#/upload-manager/article"}”'
return []int64{arg.Apply.ApplyUpMID}, msg.Title, fmt.Sprintf(msg.Content, arg.Apply.StaffName, arg.Apply.Archive.Title, arg.Apply.Archive.Aid, arg.Apply.ApplyTitle), msg.Code
case MSG_8:
//content = 'up主%s已终止参与者%s作为稿件《%s》av%d的%s的多人合作在网页端创作中心查看吧#{点击查看}{"https://member.bilibili.com/v2#/upload-manager/article/cooperation"}”'
return []int64{arg.Apply.ApplyStaffMID}, msg.Title, fmt.Sprintf(msg.Content, arg.Apply.UpName, arg.Apply.StaffName, arg.Apply.Archive.Title, arg.Apply.Archive.Aid, arg.Apply.StaffTitle), msg.Code
case MSG_9:
//content = 'up主%s申请终止您作为稿件%said%d的%s的多人合作在网页端创作中心查看吧#{点击查看}{"https://member.bilibili.com/v2#/upload-manager/article/cooperation"}”'
return []int64{arg.Apply.ApplyStaffMID}, msg.Title, fmt.Sprintf(msg.Content, arg.Apply.UpName, arg.Apply.Archive.Title, arg.Apply.Archive.Aid, arg.Apply.StaffTitle), msg.Code
case MSG_10:
//content = 'up主%s已终止参与者%s作为稿件《%s》av%d的%s的多人合作在网页端创作中心查看吧#{点击查看}{"https://member.bilibili.com/v2#/upload-manager/article"}”'
return []int64{arg.Apply.ApplyUpMID}, msg.Title, fmt.Sprintf(msg.Content, arg.Apply.UpName, arg.Apply.StaffName, arg.Apply.Archive.Title, arg.Apply.Archive.Aid, arg.Apply.StaffTitle), msg.Code
case MSG_11:
// content = 'up主%s未能终止参与者%s作为稿件《%s》av%d的%s的多人合作在网页端创作中心查看吧#{点击查看}{"https://member.bilibili.com/v2#/upload-manager/article"}”'
return []int64{arg.Apply.ApplyUpMID}, msg.Title, fmt.Sprintf(msg.Content, arg.Apply.UpName, arg.Apply.StaffName, arg.Apply.Archive.Title, arg.Apply.Archive.Aid, arg.Apply.StaffTitle), msg.Code
case MSG_12:
//content = '管理员解除了您与参与者%s在稿件《%s》《av%d》中合作关系在网页端创作中心查看吧#{点击查看}{"https://member.bilibili.com/v2#/upload-manager/article"}”'
return []int64{arg.Apply.ApplyUpMID}, msg.Title, fmt.Sprintf(msg.Content, arg.Apply.StaffsName, arg.Apply.Archive.Title, arg.Apply.Archive.Aid), msg.Code
case MSG_13:
//content = '管理员解除了您与UP主%s在稿件《%s》《av%d》中合作关系在网页端创作中心查看吧#{点击查看}{"https://member.bilibili.com/v2#/upload-manager/article"}”'
return []int64{arg.Apply.ApplyStaffMID}, msg.Title, fmt.Sprintf(msg.Content, arg.Apply.UpName, arg.Apply.Archive.Title, arg.Apply.Archive.Aid), msg.Code
}
return nil, "", "", ""
}

View File

@@ -0,0 +1,142 @@
package archive
import (
"encoding/json"
"go-common/library/time"
)
// ArcVideos 稿件及其所属视频
type ArcVideos struct {
Archive *Archive `json:"archive"`
Videos []*Video `json:"videos"`
}
//UpArchives upper主的稿件ID和个数
type UpArchives struct {
Count int64 `json:"count"`
Aids []int64 `json:"aids"`
}
// ArcMissionParam str
type ArcMissionParam struct {
AID int64 `form:"aid" validate:"required"`
MID int64 `form:"mid" validate:"required"`
MissionID int64 `form:"mission_id" validate:"required"`
Tag string `form:"tag"`
}
// ArcDynamicParam str
type ArcDynamicParam struct {
AID int64 `form:"aid" validate:"required"`
MID int64 `form:"mid" validate:"required"`
}
//ArcParam 提交的稿件参数
type ArcParam struct {
Aid int64 `json:"aid"`
Mid int64 `json:"mid"`
Author string `json:"author"`
TypeID int16 `json:"tid"`
Title string `json:"title"`
Cover string `json:"cover"`
Tag string `json:"tag"`
Copyright int8 `json:"copyright"`
Desc string `json:"desc"`
AllowTag int32 `json:"allow_tag"`
NoReprint int32 `json:"no_reprint"`
UGCPay int32 `json:"ugcpay"`
MissionID int64 `json:"mission_id"`
FromIP int64 `json:"from_ip"`
IPv6 []byte `json:"ipv6"`
UpFrom int8 `json:"up_from"`
Source string `json:"source"`
DTime time.Time `json:"dtime"`
Videos []*VideoParam `json:"videos"`
Staffs []*StaffParam `json:"staffs"`
HandleStaff bool `json:"handle_staff"`
CodeMode bool `json:"code_mode"`
OrderID int64 `json:"order_id"`
FlowRemark string `json:"flow_remark"`
Dynamic string `json:"dynamic"`
IsDRM int8 `json:"is_drm"`
DescFormatID int64 `json:"desc_format_id"`
Porder *Porder `json:"porder"`
POI *PoiObj `json:"poi_object"`
Vote *Vote `json:"vote"`
Lang string `json:"lang"`
}
//Porder str
type Porder struct {
// for user operation
FlowID int64 `json:"flow_id"`
IndustryID int64 `json:"industry_id"`
BrandID int64 `json:"brand_id"`
BrandName string `json:"brand_name"`
Official int8 `json:"official"`
ShowType string `json:"show_type"`
// for admin operation
Advertiser string `json:"advertiser"`
Agent string `json:"agent"`
//state 0 自首 1 审核添加
State int8 `json:"state"`
}
//VideoParam 提交的视频参数
type VideoParam struct {
Title string `json:"title"`
Desc string `json:"desc"`
Filename string `json:"filename"`
Cid int64 `json:"cid"`
Sid int64 `json:"sid"`
SrcType string `json:"src_type"`
IsDRM int8 `json:"is_drm"`
Editor *Editor `json:"editor"`
}
// Editor str
type Editor struct {
CID int64 `json:"cid"`
UpFrom int8 `json:"upfrom"` // filled by backend
// ids set
Filters interface{} `json:"filters"` // 滤镜
Fonts interface{} `json:"fonts"` //字体
Subtitles interface{} `json:"subtitles"` //字幕
Bgms interface{} `json:"bgms"` //bgm
Stickers interface{} `json:"stickers"` //3d拍摄贴纸
VideoupStickers interface{} `json:"videoup_stickers"` //2d投稿贴纸
Transitions interface{} `json:"trans"` //视频转场特效
// switch env 0/1
Split int8 `json:"split"` //视频切片
Cut int8 `json:"cut"` //拿时间窗口切子集
VideoRotate int8 `json:"rotate"` //画面坐标轴变换
AudioRecord int8 `json:"audio_record"` //录音
Camera int8 `json:"camera"` //拍摄
Speed int8 `json:"speed"` //变速
Beauty int8 `json:"beauty"` //美颜特效
Flashlight int8 `json:"flashlight"` //闪光灯
CameraRotate int8 `json:"camera_rotate"` //摄像头翻转
CountDown int8 `json:"countdown"` //拍摄倒计时
}
// UnmarshalJSON fn
func (vp *VideoParam) UnmarshalJSON(data []byte) (err error) {
type VpAlias VideoParam
tmp := &VpAlias{SrcType: "vupload"}
if err = json.Unmarshal(data, tmp); err != nil {
return err
}
*vp = VideoParam(*tmp)
return
}
//PubAgentParam 提交的视频参数
type PubAgentParam struct {
Route string `json:"route"`
Timestamp string `json:"timestamp"`
Filename string `json:"filename"`
Xcode int8 `json:"xcode"`
VideoDesign string `json:"video_design"`
Submit int8 `json:"submit"`
}

View File

@@ -0,0 +1,26 @@
package archive
import xtime "go-common/library/time"
// Pconfig str
type Pconfig struct {
ID int64 `json:"id"`
Tp int8 `json:"type"`
Name string `json:"name"`
}
// PorderArc str
type PorderArc struct {
AID int64 `json:"aid"`
IndustryID int64 `json:"industry_id"`
BrandID int64 `json:"brand_id"`
BrandName string `json:"brand_name"`
Official int8 `json:"official"`
ShowType string `json:"show_type"`
Advertiser string `json:"advertiser"`
Agent string `json:"agent"`
State int8 `json:"state"`
ShowFront int8 `json:"show_front"`
Ctime xtime.Time `json:"ctime"`
Mtime xtime.Time `json:"mtime"`
}

View File

@@ -0,0 +1,22 @@
package archive
import xtime "go-common/library/time"
// const ArcReport
const (
ArcReportNew = int8(0)
ArcReportReject = int8(1)
ArcReportAccept = int8(2)
)
// ArcReport archive_report
type ArcReport struct {
Mid int64 `json:"mid"`
Aid int64 `json:"aid"`
Type int8 `json:"type"`
Reason string `json:"reason"`
Pics string `json:"pics"`
State int8 `json:"state"`
CTime xtime.Time `json:"ctime"`
MTime xtime.Time `json:"-"`
}

View File

@@ -0,0 +1,169 @@
package archive
// staff state .
const (
APPLYSTATEOPEN = int8(0)
APPLYSTATEACCEPT = int8(1)
APPLYSTATEREFUSE = int8(2)
//场景是 staff未上线前 up直接删除
APPLYSTATEDEL = int8(3)
APPLYSTATEIGNORE = int8(4)
DEALSTATEOPEN = int8(1)
DEALSTATEDONE = int8(2)
DEALSTATEIGNORE = int8(3)
STATEON = int8(1)
STATEOFF = int8(2)
TYPEUPADD = int8(1)
TYPEUPDEL = int8(2)
TYPEUPMODIFY = int8(3)
TYPESTAFFDEL = int8(4)
TYPEADMINDEL = int8(5)
STAFFLogBizID = int(84)
STAFFLogBizType1 = int(1)
STAFFLogBizType2 = int(2)
STAFFLogBizType3 = int(3)
STAFFLogBizType4 = int(4)
UPRELATIONBLACK = int64(128)
)
//Staff . 正式staff
type Staff struct {
ID int64 `json:"id"`
AID int64 `json:"aid"`
MID int64 `json:"mid"`
StaffMID int64 `json:"staff_mid"`
StaffTitle string `json:"staff_title"`
StaffName string `json:"staff_name"`
StaffTitleID int64 `json:"staff_title_id"`
State int8 `json:"state"`
}
//StaffParam 提交的staff参数
type StaffParam struct {
//apply_id 建议前端传 为后面预留
ApplyID int64 `json:"apply_id"`
Title string `json:"title"`
MID int64 `json:"mid"`
TitleID int64 `json:"title_id"`
}
//StaffBatchParam 批量提交的staff参数
type StaffBatchParam struct {
AID int64 `json:"aid"`
SyncAttr bool `json:"sync_attr"`
Staffs []*StaffParam `json:"staffs"`
}
//ApplyParam 提交申请单参数
type ApplyParam struct {
ID int64 `form:"id"`
Type int8 `form:"type"`
ASID int64 `form:"as_id"`
ApplyAID int64 `form:"apply_aid"`
ApplyStaffMID int64 `form:"apply_staff_mid" validate:"required"`
ApplyUpMID int64 `form:"apply_up_mid"`
ApplyTitle string `form:"apply_title"`
OldTitle string `form:"old_title"`
ApplyTitleID int64 `form:"apply_title_id"`
State int8 `form:"state"`
DealState int8 `form:"deal_state"`
RefuseMid int64 `form:"refuse_mid"`
FlagRefuse bool `form:"flag_refuse"`
FlagAddBlack bool `form:"flag_add_black"`
NoNotify bool `form:"no_notify"`
SyncStaff bool `form:"sync_staff"`
CleanCache bool `form:"clean_cache"`
SyncDynamic bool `form:"sync_dynamic"`
MsgId int `form:"msg_id"`
StaffState int8 `json:"staff_state"`
StaffTitle string `json:"staff_title"`
Archive *Archive `json:"archive"`
UpName string `json:"up_name"`
StaffName string `json:"staff_name"`
StaffsName string `json:"staffs_name"`
NotifyUp bool `json:"notify_up"`
}
type SearchApplyIndex struct {
Indexs []*Index `json:"creative_archive"`
}
type Index struct {
ID int64 `json:"id"`
Item []*IndexItem `json:"apply_staff"`
}
type IndexItem struct {
DealState int8 `json:"deal_state"`
ApplyStaffMID int64 `json:"apply_staff_mid"`
}
//StaffApply 申请单
type StaffApply struct {
ID int64 `json:"id"`
Type int8 `json:"apply_type"`
ASID int64 `json:"apply_as_id"`
ApplyAID int64 `json:"apply_aid"`
ApplyUpMID int64 `json:"apply_up_mid"`
ApplyStaffMID int64 `json:"apply_staff_mid"`
ApplyTitle string `json:"apply_title"`
ApplyTitleID int64 `json:"apply_title_id"`
State int8 `json:"apply_state"`
DealState int8 `json:"deal_state"`
StaffState int8 `json:"staff_state"`
StaffTitle string `json:"staff_title"`
}
//Copy . apply转化成staff
func (s *Staff) Copy(v *ApplyParam) {
s.AID = v.ApplyAID
s.MID = v.ApplyUpMID
s.StaffMID = v.ApplyStaffMID
s.ID = v.ASID
s.StaffTitle = v.ApplyTitle
s.StaffTitleID = v.ApplyTitleID
switch v.State {
case APPLYSTATEACCEPT:
switch v.Type {
case TYPEUPADD:
s.State = STATEON
case TYPEUPMODIFY:
s.State = STATEON
case TYPEUPDEL, TYPEADMINDEL, TYPESTAFFDEL:
s.State = STATEOFF
}
case APPLYSTATEREFUSE:
switch v.Type {
case TYPEUPADD:
s.State = STATEOFF
case TYPEUPMODIFY:
s.State = STATEON
case TYPEUPDEL, TYPEADMINDEL, TYPESTAFFDEL:
s.State = STATEON
}
case APPLYSTATEDEL:
switch v.Type {
case TYPEADMINDEL, TYPESTAFFDEL:
s.State = STATEOFF
}
default:
s.State = STATEOFF
}
}
//Copy . 稿件编辑时用
func (s *ApplyParam) Copy(v *StaffApply) {
s.ApplyAID = v.ApplyAID
s.ApplyStaffMID = v.ApplyStaffMID
s.ASID = v.ASID
s.ApplyTitle = v.ApplyTitle
s.ApplyTitleID = v.ApplyTitleID
s.State = v.State
s.Type = v.Type
}

View File

@@ -0,0 +1,290 @@
package archive
import (
"sync"
xtime "time"
"go-common/library/log"
"go-common/library/time"
)
// const Video Status
const (
// video xcode and dispatch state.
VideoUploadInfo = int8(0)
VideoXcodeSDFail = int8(1)
VideoXcodeSDFinish = int8(2)
VideoXcodeHDFail = int8(3)
VideoXcodeHDFinish = int8(4)
VideoDispatchRunning = int8(5)
VideoDispatchFinish = int8(6)
// video status.
VideoStatusOpen = int16(0)
VideoStatusAccess = int16(10000)
VideoStatusWait = int16(-1)
VideoStatusRecicle = int16(-2)
VideoStatusLock = int16(-4)
VideoStatusXcodeFail = int16(-16)
VideoStatusSubmit = int16(-30)
VideoStatusUploadSubmit = int16(-50)
VideoStatusDelete = int16(-100)
// xcode fail
XcodeFailZero = 0
)
// Video is archive_video model.
type Video struct {
ID int64 `json:"-"`
Aid int64 `json:"aid"`
Title string `json:"title"`
Desc string `json:"desc"`
Filename string `json:"filename"`
SrcType string `json:"src_type"`
Cid int64 `json:"cid"`
Sid int64 `json:"-"`
Duration int64 `json:"duration"`
Filesize int64 `json:"-"`
Resolutions string `json:"-"`
Index int `json:"index"`
Playurl string `json:"-"`
Status int16 `json:"status"`
FailCode int8 `json:"fail_code"`
XcodeState int8 `json:"xcode_state"`
Attribute int32 `json:"-"`
RejectReason string `json:"reject_reason"`
CTime time.Time `json:"ctime"`
MTime time.Time `json:"-"`
Dimension *Dimension `json:"dimension"`
}
// Dimension Archive video dimension
type Dimension struct {
Width int64 `json:"width"`
Height int64 `json:"height"`
Rotate int64 `json:"rotate"`
}
// SimpleVideo for Archive History
type SimpleVideo struct {
Cid int64 `json:"cid"`
Index int `json:"part_id"`
Title string `json:"part_name"`
Status int16 `json:"status"`
MTime time.Time `json:"dm_modified"`
}
// VideoFn for Archive Video table filename check
type VideoFn struct {
Cid int64 `json:"cid"`
Filename string `json:"filename"`
CTime time.Time `json:"ctime"`
MTime time.Time `json:"mtime"`
}
type param struct {
undoneCount int // 待完成数总和
failCount int // 错误数总和
timeout *xtime.Timer
}
/*VideosEditor 处理超多分p的稿件编辑
* 0.对该稿件的编辑操作加锁
* 1.将所有视频分组分事务更新
* 2.全部更新成功后发送成功信号量
* 3.更新错误的分组多次尝试,超时或超过次数后失败
* 4.收到更新成功信号量进行回调-1.同步信息给视频云 2.解锁该稿件编辑)
* 5.收到更新失败信号量进行回调- (1.记录错误日志信息 2.推送错误消息 3.解锁该稿件编辑)
*/
type VideosEditor struct {
sync.Mutex
failTH int
closeFlag bool
wg sync.WaitGroup
params map[int64]*param
cbSuccess map[int64]func()
cbFail map[int64]func()
sigSuccess chan int64
sigFail chan int64
chanRetry chan func() (int64, int, int, error)
closechan, cbclose chan struct{}
}
// NewEditor new VideosEditor
func NewEditor(failTH int) *VideosEditor {
editor := &VideosEditor{
failTH: failTH,
wg: sync.WaitGroup{},
params: make(map[int64]*param),
cbSuccess: make(map[int64]func()),
cbFail: make(map[int64]func()),
sigSuccess: make(chan int64, 10),
sigFail: make(chan int64, 10),
chanRetry: make(chan func() (int64, int, int, error), 100),
closechan: make(chan struct{}, 1),
cbclose: make(chan struct{}),
}
editor.wg.Add(1)
go editor.consumerRetry(&editor.wg)
editor.wg.Add(1)
go editor.consumercb(&editor.wg)
return editor
}
// Close 等待所有消息消费完才退出
func (m *VideosEditor) Close() {
m.closeFlag = true
m.closechan <- struct{}{}
m.wg.Wait()
}
// Add add to editor
func (m *VideosEditor) Add(aid int64, cbSuccess, cbFail func(), timeout xtime.Duration, retrys ...func() (int64, int, int, error)) {
if m.closeFlag {
log.Warn("VideosEditor closed")
return
}
log.Info("VideosEditor Add(%d) len(%d)", aid, len(retrys))
timer := xtime.AfterFunc(timeout, func() { m.notifyTimeout(aid) })
m.params[aid] = &param{
undoneCount: len(retrys),
failCount: 0,
timeout: timer,
}
m.cbSuccess[aid] = cbSuccess
m.cbFail[aid] = cbFail
for _, ry := range retrys {
m.addRetry(ry, 0)
}
}
// NotifySuccess notify success
func (m *VideosEditor) notifySuccess(aid int64) {
m.Lock()
defer m.Unlock()
param, ok := m.params[aid]
if ok {
param.undoneCount--
if param.undoneCount <= 0 {
log.Info("notifySuccess(%d) undoneCount(%d)", aid, param.undoneCount)
m.sigSuccess <- aid
}
}
}
// NotifyFail 返回值表示达到触发阈值
func (m *VideosEditor) notifyFail(aid int64) (retry bool) {
m.Lock()
defer m.Unlock()
param, ok := m.params[aid]
if ok {
retry = true
param.failCount++
if param.failCount >= m.failTH {
log.Warn("notifyFail(%d) failCount(%d)", aid, param.failCount)
retry = false
if _, ok := m.cbFail[aid]; ok {
m.sigFail <- aid
}
}
}
return
}
func (m *VideosEditor) notifyTimeout(aid int64) {
log.Warn("notifyTimeout(%d)", aid)
m.Lock()
defer m.Unlock()
_, ok := m.params[aid]
if ok {
if _, ok := m.cbFail[aid]; ok {
m.sigFail <- aid
}
}
}
func (m *VideosEditor) consumercb(g *sync.WaitGroup) {
defer g.Done()
for {
select {
case aid, ok := <-m.sigSuccess:
if !ok {
log.Info("consumercb close")
return
}
if f, ok := m.cbSuccess[aid]; ok {
f()
m.release(aid)
}
case aid, ok := <-m.sigFail:
if !ok {
log.Info("consumercb close")
return
}
if f, ok := m.cbFail[aid]; ok {
f()
m.release(aid)
}
case <-m.closechan:
if len(m.cbFail) == 0 && len(m.cbSuccess) == 0 {
m.cbclose <- struct{}{}
log.Info("consumercb closechan")
return
}
xtime.Sleep(50 * xtime.Millisecond)
m.closechan <- struct{}{}
}
}
}
func (m *VideosEditor) consumerRetry(g *sync.WaitGroup) {
defer g.Done()
for {
log.Info("consumerRetry")
select {
case <-m.cbclose:
log.Info("consumerRetry closed")
return
case f, ok := <-m.chanRetry:
if !ok {
log.Info("m.chanRetry closed")
break
}
id, head, tail, err := f()
log.Info("consumerRetry(%d) head(%d) tail(%d) err(%v) ", id, head, tail, err)
if err != nil {
if m.notifyFail(id) {
go func() {
xtime.Sleep(3 * xtime.Second)
m.addRetry(f, 3)
}()
}
} else {
m.notifySuccess(id)
}
}
}
}
func (m *VideosEditor) addRetry(f func() (int64, int, int, error), asynctime int) {
if asynctime == 0 {
m.chanRetry <- f
return
}
go func() {
xtime.Sleep(3 * xtime.Second)
m.chanRetry <- f
}()
}
func (m *VideosEditor) release(aid int64) {
if p, ok := m.params[aid]; ok {
p.timeout.Stop()
}
delete(m.cbFail, aid)
delete(m.cbSuccess, aid)
}

View File

@@ -0,0 +1,33 @@
package archive
import (
"fmt"
"testing"
"time"
)
func Test_VideoEditor(t *testing.T) {
edit := NewEditor(3)
edit.Add(10,
func() { fmt.Println("WOW!10 SUCCESS") },
func() { fmt.Println("WOW!10 FAIL") },
time.Duration(20*time.Second),
[]func() (int64, int, int, error){
func() (int64, int, int, error) { return 10, 0, 1, nil },
func() (int64, int, int, error) { return 10, 2, 3, fmt.Errorf("boom") },
}...)
edit.Add(11,
func() { fmt.Println("WOW!11 SUCCESS") },
func() { fmt.Println("WOW!11 FAIL") },
time.Duration(5*time.Second),
[]func() (int64, int, int, error){
func() (int64, int, int, error) { return 11, 0, 1, nil },
func() (int64, int, int, error) { return 11, 0, 1, nil },
}...)
time.Sleep(time.Second)
edit.Close()
t.Fail()
}

View File

@@ -0,0 +1,28 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["dede.go"],
importpath = "go-common/app/service/main/videoup/model/dede",
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
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,12 @@
package dede
type PadInfo struct {
Aid int64 `json:"aid"`
Mid int64 `json:"mid"`
Fnm map[string]int64 `json:"fnm"`
Paded bool `json:"paded"`
OK chan bool `json:"-"`
IsUpload bool `json:"is_upload"`
CodeMode bool `json:"code_mode"`
IsUGC bool `json:"is_ugc"`
}

View File

@@ -0,0 +1,28 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["manager.go"],
importpath = "go-common/app/service/main/videoup/model/manager",
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
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,8 @@
package manager
const (
// upper type
UpperTypeBlack int8 = 1
UpperTypeWhite int8 = 2
UpperTypePGC int8 = 3
)

View File

@@ -0,0 +1,31 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"message.go",
"message_staff.go",
],
importpath = "go-common/app/service/main/videoup/model/message",
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
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,82 @@
package message
const (
//RouteSyncCid cid同步
RouteSyncCid = "sync_cid"
//RouteFirstRound 一审
RouteFirstRound = "first_round"
//RoutePGCSubmit pgc提交
RoutePGCSubmit = "pgc_submit"
//RouteDRMSubmit drm提交
RouteDRMSubmit = "drm_submit"
//RouteUGCSubmit ugc提交
RouteUGCSubmit = "ugc_submit"
//RouteSecondRound 二审
RouteSecondRound = "second_round"
//RouteAddArchive 投稿
RouteAddArchive = "add_archive"
//RouteModifyArchive 编辑稿件
RouteModifyArchive = "modify_archive"
//RouteModifyVideo 编辑视频
RouteModifyVideo = "modify_video"
//RouteUserDelete 用户删除 NOTE: after change this route by delete_video
RouteUserDelete = "user_delete"
//RouteDeleteVideo 删除视频
RouteDeleteVideo = "delete_video"
//RouteDeleteArchive 删除稿件
RouteDeleteArchive = "delete_archive"
//RouteForceSync 同步稿件库
RouteForceSync = "force_sync"
)
//Videoup messgae
type Videoup struct {
Route string `json:"route"`
Filename string `json:"filename"`
Timestamp int64 `json:"timestamp"`
// cid
Cid int64 `json:"cid,omitempty"`
DMIndex string `json:"dm_index,omitempty"`
UpFrom int8 `json:"up_from"`
// encode
Xcode int8 `json:"xcode"`
EncodePurpose string `json:"encode_purpose,omitempty"`
EncodeRegionID int16 `json:"encode_region_id,omitempty"`
VideoDesign struct {
Mosaic []*Mosaic `json:"mosaic,omitempty"`
WaterMark *WaterMark `json:"watermark,omitempty"`
} `json:"video_design"`
Status int16 `json:"status,omitempty"`
// add or modify archive
Aid int64 `json:"aid,omitempty"`
EditArchive bool `json:"edit_archive,omitempty"`
EditVideo bool `json:"edit_video,omitempty"`
// MissionID
MissionID int64 `json:"mission_id,omitempty"`
// pgc submit
Submit int `json:"submit"`
TagChange bool `json:"tag_change,omitempty"`
AddVideos bool `json:"add_videos,omitempty"`
ChangeTypeID bool `json:"change_typeid,omitempty"`
StaffBox *StaffBox `json:"staff_box,omitempty"`
}
//Mosaic message
type Mosaic struct {
X int64 `json:"x"`
Y int64 `json:"y"`
W int64 `json:"w"`
H int64 `json:"h"`
Start int64 `json:"start"`
End int64 `json:"end"`
}
//WaterMark message
type WaterMark struct {
URL string `json:"url"`
MD5 string `json:"md5"`
Start int64 `json:"start"`
End int64 `json:"end"`
X int64 `json:"x"`
Y int64 `json:"y"`
}

View File

@@ -0,0 +1,23 @@
package message
const (
//RouteBplusStaff pgc提交
RouteBplusStaff = "bplus_staff"
)
type StaffBox struct {
RID int64 `json:"rid"`
Type int8 `json:"type"`
ADDStaff []*StaffItem `json:"added_staffs"`
DelStaff []*StaffItem `json:"removed_staffs"`
}
type StaffItem struct {
Type int8 `json:"uid_type"`
UID int64 `json:"uid"`
}
// BplusCardMsg 粉丝动态databus消息
type BplusCardMsg struct {
Outbox *StaffBox `json:"outbox"`
}

View File

@@ -0,0 +1,28 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["prom.go"],
importpath = "go-common/app/service/main/videoup/model/prom",
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
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,29 @@
package prom
import (
"fmt"
)
const (
RouteNormalMode = "normal_mode"
RouteCodeMode = "code_mode"
RouteUpFrom = "upfrom_"
RouteNumFormatVids = "%s_%dp"
RouteStrFormatVids = "%s_%sp"
RouteDmIndexTry = "dm_index_retry"
RouteDatabusTry = "databus_retry"
)
// FormatVideoKey format videos prom key
func FormatVideoKey(count int, tp string) (key string) {
if count >= 0 && count <= 5 {
key = fmt.Sprintf(RouteNumFormatVids, tp, count)
} else if count >= 6 && count <= 10 {
key = fmt.Sprintf(RouteStrFormatVids, tp, "6_10")
} else {
key = fmt.Sprintf(RouteStrFormatVids, tp, "above_10")
}
return
}