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,65 @@
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_recheck.go",
"archive_state.go",
"config.go",
"flow.go",
"forbid.go",
"history.go",
"mosaic.go",
"oper.go",
"param.go",
"staff.go",
"stats.go",
"task.go",
"task_qa_video.go",
"video.go",
"watermark.go",
],
importpath = "go-common/app/admin/main/videoup/model/archive",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/admin/main/videoup/model/message:go_default_library",
"//app/admin/main/videoup/model/utils:go_default_library",
"//library/log:go_default_library",
"//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"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
go_test(
name = "go_default_test",
srcs = [
"archive_test.go",
"history_test.go",
],
embed = [":go_default_library"],
rundir = ".",
tags = ["automanaged"],
deps = ["//vendor/github.com/smartystreets/goconvey/convey:go_default_library"],
)

View File

@@ -0,0 +1,83 @@
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"`
OrderID int64 `json:"order_id"`
Dynamic string `json:"dynamic"`
DTime time.Time `json:"dtime"`
PTime time.Time `json:"ptime"`
CTime time.Time `json:"ctime"`
MTime time.Time `json:"-"`
Tnames []string `json:"tid_names"`
}
// Addit is archive addit info
type Addit struct {
Aid int64 `json:"aid"`
MissionID int64 `json:"mission_id"`
UpFrom int8 `json:"up_from"`
FromIP int64 `json:"from_ip"`
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"`
DescFormatID int64 `json:"desc_format_id"`
Dynamic string `json:"dynamic"`
InnerAttr int64 `json:"inner_attr"`
}
// Delay is archive delay info
type Delay struct {
Aid int64
Mid int64
State int16
DTime time.Time
}
// Type is archive type info
type Type struct {
ID int16 `json:"id"`
PID int16 `json:"pid"`
Name string `json:"name"`
Desc string `json:"description"`
}
//ChannelInfo channel info
type ChannelInfo struct {
CheckBack int32 `json:"check_back"`
Channels []*Channel `json:"channels"`
}
//Channel channe & tag hit rule
type Channel struct {
TID int64 `json:"tid"` //频道id
Tname string `json:"tname"` //频道名称
HitRules []string `json:"hit_rules"` //命中的频道规则
HitTagNames []string `json:"hit_tnames"` //命中频道的所有tag名称
}

View File

@@ -0,0 +1,28 @@
package archive
import "time"
const (
//TypeChannelRecheck 频道回查
TypeChannelRecheck = 0 //频道回查
// TypeHotRecheck 热门回查
TypeHotRecheck = 1
// TypeInspireRecheck 激励回查
TypeInspireRecheck = 2
//RecheckStateWait 频道回查待回查
RecheckStateWait = -1 //待回查
//RecheckStateDone 频道回查已回查
RecheckStateDone = 0 //已回查
)
// Recheck archive recheck
type Recheck struct {
ID int64 `json:"id"`
Type int `json:"type"`
AID int64 `json:"aid"`
UID int64 `json:"uid"`
State int8 `json:"state"`
Remark string `json:"remark"`
CTime time.Time `json:"ctime"`
MTime time.Time `json:"mtime"`
}

View File

@@ -0,0 +1,354 @@
package archive
const (
// StateOpen 开放浏览
StateOpen = int8(0)
// StateOrange 橙色通过
StateOrange = int8(1)
// StateForbidWait 待审
StateForbidWait = int8(-1)
// StateForbidRecycle 被打回
StateForbidRecycle = int8(-2)
// StateForbidPolice 网警锁定
StateForbidPolice = int8(-3)
// StateForbidLock 被锁定
StateForbidLock = int8(-4)
// StateForbidFackLock 管理员锁定(可浏览)
StateForbidFackLock = int8(-5)
// StateForbidFixed 修复待审
StateForbidFixed = int8(-6)
// StateForbidLater 暂缓审核
StateForbidLater = int8(-7)
// StateForbidPatched 补档待审
StateForbidPatched = int8(-8)
// StateForbidWaitXcode 等待转码
StateForbidWaitXcode = int8(-9)
// StateForbidAdminDelay 延迟审核
StateForbidAdminDelay = int8(-10)
// StateForbidFixing 视频源待修
StateForbidFixing = int8(-11)
// StateForbidStorageFail 转储失败
StateForbidStorageFail = int8(-12)
// StateForbidOnlyComment 允许评论待审
StateForbidOnlyComment = int8(-13)
// StateForbidTmpRecicle 临时回收站
StateForbidTmpRecicle = int8(-14)
// StateForbidDispatch 分发中
StateForbidDispatch = int8(-15)
// StateForbidXcodeFail 转码失败
StateForbidXcodeFail = int8(-16)
// StateForbitUpLoad 创建未提交
StateForbitUpLoad = int8(-20) // NOTE:spell body can judge to change state
// StateForbidSubmit 创建已提交
StateForbidSubmit = int8(-30)
// StateForbidUserDelay 定时发布
StateForbidUserDelay = int8(-40)
// StateForbidUpDelete 用户删除
StateForbidUpDelete = int8(-100)
// AttrYes attribute yes
AttrYes = int32(1)
// AttrNo attribute no
AttrNo = int32(0)
// AttrBitNoRank 禁止排行
AttrBitNoRank = uint(0) // NOTE: double write for archive_forbid
// AttrBitNoDynamic 动态禁止
AttrBitNoDynamic = uint(1) // NOTE: double write for archive_forbid
// AttrBitNoWeb 禁止网页输出
AttrBitNoWeb = uint(2)
// AttrBitNoMobile 禁止客户端列表
AttrBitNoMobile = uint(3)
// AttrBitNoSearch 搜索禁止
AttrBitNoSearch = uint(4)
// AttrBitOverseaLock 海外禁止
AttrBitOverseaLock = uint(5)
// AttrBitNoRecommend 禁止推荐
AttrBitNoRecommend = uint(6) // NOTE: double write for archive_forbid
// AttrBitNoReprint 禁止转载
AttrBitNoReprint = uint(7)
// AttrBitHasHD5 是否高清
AttrBitHasHD5 = uint(8)
// AttrBitIsPGC 是否PGC稿件
AttrBitIsPGC = uint(9)
// AttrBitAllowBp 允许承包
AttrBitAllowBp = uint(10)
// AttrBitIsBangumi 是否番剧
AttrBitIsBangumi = uint(11)
// AttrBitIsPorder 是否私单
AttrBitIsPorder = uint(12)
// AttrBitLimitArea 是否限制地区
AttrBitLimitArea = uint(13)
// AttrBitAllowTag 允许其他人添加tag
AttrBitAllowTag = uint(14)
// AttrBitIsFromArcAPI useless
AttrBitIsFromArcAPI = uint(15) // TODO: delete
// AttrBitJumpURL 跳转
AttrBitJumpURL = uint(16)
// AttrBitIsMovie 是否影视
AttrBitIsMovie = uint(17)
// AttrBitBadgepay 付费
AttrBitBadgepay = uint(18)
//AttrBitPushBlog 推送动态
AttrBitPushBlog = uint(20)
//AttrBitParentMode 家长模式
AttrBitParentMode = uint(21)
//AttrBitUGCPay UGC付费
AttrBitUGCPay = uint(22)
// CopyrightUnknow 未知版权类型
CopyrightUnknow = int8(0)
// CopyrightOriginal 原创
CopyrightOriginal = int8(1)
// CopyrightCopy 转载
CopyrightCopy = int8(2)
// UpFromWeb 网页上传
UpFromWeb = int8(0)
// UpFromPGC PGC上传
UpFromPGC = int8(1)
// UpFromWindows Windows客户端上传
UpFromWindows = int8(2)
// UpFromAPP APP上传
UpFromAPP = int8(3)
// UpFromMAC Mac客户端上传
UpFromMAC = int8(4)
// UpFromSecretPGC 机密PGC上传
UpFromSecretPGC = int8(5)
// UpFromCoopera 合作方嵌套
UpFromCoopera = int8(6)
// UpFromCreator 创作姬上传
UpFromCreator = int8(7)
// UpFromAndroid 安卓上传
UpFromAndroid = int8(8)
// UpFromIOS IOS上传
UpFromIOS = int8(9)
// DelayTypeForAdmin 管理员定时发布
DelayTypeForAdmin = int8(1)
// DelayTypeForUser 用户定时发布
DelayTypeForUser = int8(2)
// RoundBegin 一审阶段
RoundBegin = int8(0)
// RoundAuditSecond 二审选定分区的多P稿件 及 PGC/活动的单P多P稿件
RoundAuditSecond = int8(10)
// RoundAuditThird 三审:选定分区/PGC/活动 的单P多P稿件
RoundAuditThird = int8(20)
// RoundReviewFlow 私单回查私单ID大于0
RoundReviewFlow = int8(21)
//RoundReviewBadgepayFlow 付费审核
RoundAuditUGCPayFlow = int8(24)
// RoundReviewFirst 分区回查:粉丝小于配置阈值 如 5000 且 指定分区
RoundReviewFirst = int8(30)
// RoundReviewFirstWaitTrigger 点击/粉丝 等待触发中间状态7天内达到阈值进列表未达到自动变99
RoundReviewFirstWaitTrigger = int8(31)
// RoundReviewSecond 社区回查:粉丝大于配置阈值 如 5000 或 优质高危up
RoundReviewSecond = int8(40)
// RoundTriggerFans 粉丝回查:粉丝量达到配置阈值
RoundTriggerFans = int8(80)
// RoundTriggerClick 点击回查:点击量达到配置阈值
RoundTriggerClick = int8(90)
// RoundEnd 结束
RoundEnd = int8(99)
// AccessDefault 非会员可见
AccessDefault = int16(0)
// AccessMember 会员可见
AccessMember = int16(10000)
// LogClientType 日志服务类型
//for buiness
//LogClientVideo 视频business id
LogClientVideo = int(2)
//LogClientArchive 稿件business id
LogClientArchive = int(3)
//LogClientUp up主business id
LogClientUp = int(4)
//LogClientPorder 私单business id
LogClientPorder = int(5)
//LogClientArchiveMusic 稿件bgm business id
LogClientArchiveMusic = int(6)
//LogClientPolicy 策略business id
LogClientPolicy = int(7) //稿件策略组
//LogClientConsumer 一审任务 business id
LogClientConsumer = int(131)
//LogClientTypePorderLog for business type
//LogClientTypePorderLog 私单type id
LogClientTypePorderLog = int(1)
//LogClientTypeVideo 视频 type id
LogClientTypeVideo = int(1)
//LogClientTypeArchive 稿件 type id
LogClientTypeArchive = int(1)
//LogClientTypePorder 私单 id
LogClientTypePorder = int(14)
//LogClientTypePolicy 策略type id
LogClientTypePolicy = int(1) //稿件策略组修改记录
//LogClientArchiveMusicTypeMusic 稿件bgm type id
LogClientArchiveMusicTypeMusic = int(1)
//LogClientArchiveMusicTypeMaterial 稿件bgm素材 type id
LogClientArchiveMusicTypeMaterial = int(2)
//LogClientArchiveMusicTypeCategory 稿件bgm分类 type id
LogClientArchiveMusicTypeCategory = int(3)
//LogClientArchiveMusicTypeMaterialRelation 稿件bgm关联 type id
LogClientArchiveMusicTypeMaterialRelation = int(4)
//LogClientArchiveMusicTypeCategoryRelation 稿件bgm分区关联 type id
LogClientArchiveMusicTypeCategoryRelation = int(5)
//InnerAttrChannelReview 内部属性-频道回查--已删除
InnerAttrChannelReview = uint(0)
//LogClientTypeConsumer 一审任务type id
LogClientTypeConsumer = int(1)
)
var (
_attr = map[int32]int32{
AttrNo: AttrNo,
AttrYes: AttrYes,
}
_access = map[int16]string{
AccessDefault: "非会员可见",
AccessMember: "会员可见",
}
_copyright = map[int8]string{
CopyrightUnknow: "未知",
CopyrightOriginal: "自制",
CopyrightCopy: "转载",
}
_bits = map[uint]string{
AttrBitNoRank: "排行禁止",
AttrBitNoDynamic: "动态禁止",
AttrBitNoWeb: "禁止web端输出",
AttrBitNoMobile: "禁止移动端输出",
AttrBitNoSearch: "禁止搜索",
AttrBitOverseaLock: "海外禁止",
AttrBitNoRecommend: "推荐禁止",
AttrBitNoReprint: "禁止转载",
AttrBitHasHD5: "高清1080P",
// AttrBitVisitorDm: AttrBitVisitorDm,
AttrBitIsPGC: "PGC",
AttrBitAllowBp: "允许承包",
AttrBitIsBangumi: "番剧",
AttrBitIsPorder: "是否私单",
AttrBitLimitArea: "是否地区限制",
AttrBitAllowTag: "允许操作TAG",
// AttrBitIsFromArcAPI: AttrBitIsFromArcAPI,
AttrBitJumpURL: "跳转",
AttrBitIsMovie: "电影",
AttrBitBadgepay: "付费", //pgc付费
AttrBitPushBlog: "禁止粉丝动态",
AttrBitParentMode: "家长模式",
AttrBitUGCPay: "UGC付费",
}
// oversea forbidden typeid
_overseaTypes = map[int16]int16{
15: 15, //'连载剧集'
29: 29, //'三次元音乐'
32: 32, //'完结动画'
33: 33, //'连载动画'
34: 34, //'完结剧集'
37: 37, //'纪录片'
51: 51, //'资讯'
54: 54, //'OP/ED/OST'
71: 71, //'综艺'
86: 86, //'特摄布袋戏'
96: 96, //'星海'
130: 130, //'音乐选集'
131: 131, //'Korea相关'
137: 137, //'明星'
145: 145, //'欧美电影'
146: 146, //'日本电影'
147: 147, //'国产电影'
152: 152, //'官方延伸'
153: 153, //'国产动画'
}
_upFromTypes = map[int8]string{
UpFromWeb: "网页上传",
UpFromPGC: "PGC上传",
UpFromWindows: "Windows客户端上传",
UpFromAPP: "APP上传",
UpFromMAC: "Mac客户端上传",
UpFromSecretPGC: "机密PGC上传",
UpFromCoopera: "合作方嵌套",
UpFromCreator: "创作姬上传",
UpFromAndroid: "安卓上传",
UpFromIOS: "IOS上传",
}
)
// UpFrom get upfrom desc
func UpFrom(ufID int8) string {
return _upFromTypes[ufID]
}
// Attr attribute
type Attr int32
// InCopyrights in correct copyrights.
func InCopyrights(cp int8) (ok bool) {
_, ok = _copyright[cp]
return
}
// CopyrightsDesc return copyrights desc.
func CopyrightsDesc(cp int8) (desc string) {
desc = _copyright[cp]
return
}
// AccessDesc return acces desc.
func AccessDesc(acces int16) (desc string) {
desc = _access[acces]
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
}
// NormalState check state.
func NormalState(state int8) bool {
return state == StateOpen || state == StateOrange
}
// NotAllowDelay check need delete dtime of state.
func NotAllowDelay(state int8) bool {
return state == StateForbidRecycle || state == StateForbidLock
}
// AttrSet set attribute.
func (arc *Archive) AttrSet(v int32, bit uint) {
arc.Attribute = arc.Attribute&(^(1 << bit)) | (v << bit)
}
// AttrVal get attribute.
func (arc *Archive) AttrVal(bit uint) int32 {
return (arc.Attribute >> bit) & int32(1)
}
// WithAttr set attribute value with a attr value.
func (arc *Archive) WithAttr(attr Attr) {
arc.Attribute = arc.Attribute | int32(attr)
}
// NotAllowUp check archive is or not allow update state.
func (arc *Archive) NotAllowUp() bool {
return arc.State == StateForbidUpDelete || arc.State == StateForbidLater || arc.State == StateForbidLock || arc.State == StateForbidPolice
}
//InnerAttrSet set inner_attr
func (addit *Addit) InnerAttrSet(v int64, bit uint) {
addit.InnerAttr = addit.InnerAttr&(^(1 << bit)) | (v << bit)
}

View File

@@ -0,0 +1,20 @@
package archive
import (
"github.com/smartystreets/goconvey/convey"
"testing"
)
func TestAddit_InnerAttrSet(t *testing.T) {
convey.Convey("InnerAttrSet", t, func() {
add := &Addit{
InnerAttr: 0,
}
add.InnerAttrSet(1, InnerAttrChannelReview)
convey.So(add.InnerAttr, convey.ShouldEqual, 1)
add.InnerAttr = 16
add.InnerAttrSet(1, 3)
convey.So(add.InnerAttr, convey.ShouldEqual, 24)
})
}

View File

@@ -0,0 +1,14 @@
package archive
const (
// ConfForClick round limit fans
ConfForClick = "round_limit_fans"
// ConfForRoundType round limit tids
ConfForRoundType = "round_limit_tids"
// ConfForThreshold threshold archive type
ConfForThreshold = "threshold_arctype"
// ConfForWaitAudit wait audit archive type
ConfForWaitAudit = "wait_audit_arctype"
// ConfForWeightVC 权重配置
ConfForWeightVC = "weight_conf_values"
)

View File

@@ -0,0 +1,39 @@
package archive
// pool .
const (
PoolArc = int8(0)
PoolUp = int8(1)
PoolPrivateOrder = int8(2)
PoolArticle = int8(3)
PoolArcForbid = int8(4)
FlowOpen = int8(0)
FlowDelete = int8(1)
FlowLogAdd = int8(1)
FlowLogUpdate = int8(2)
FlowLogDel = int8(3)
FlowGroupNoChannel = int64(23)
FlowGroupNoHot = int64(24)
)
var (
//FlowAttrMap archive submit with flow attr
FlowAttrMap = map[string]int64{
"nochannel": FlowGroupNoChannel,
"nohot": FlowGroupNoHot,
}
)
//FlowData flow_design data
type FlowData struct {
ID int64 `json:"id"`
Pool int8 `json:"pool"`
OID int64 `json:"oid"`
GroupID int64 `json:"group_id"`
Parent int8 `json:"parent"`
State int8 `json:"state"`
GroupValue []byte `json:"group_value"`
}

View File

@@ -0,0 +1,145 @@
package archive
const (
// ForbidRank 禁止排行
ForbidRank = "rank"
// ForbidDynamic 动态禁止
ForbidDynamic = "dynamic"
// ForbidRecommend 禁止推荐
ForbidRecommend = "recommend"
// ForbidShow 禁止展示
ForbidShow = "show"
// ForbidRankMain forbid rank main
ForbidRankMain = 0
// ForbidRankRecentArc forbid rank recent archive
ForbidRankRecentArc = 1
// ForbidRankAllArc forbid rank all archive
ForbidRankAllArc = 2
// ForbidDynamicMain forbid dynamic main
ForbidDynamicMain = 0
// ForbidRecommendMain forbid recomment main
ForbidRecommendMain = 0
// ForbidShowMain forbid show main
ForbidShowMain = 0
// ForbidShowMobile forbid show mobile
ForbidShowMobile = 1
// ForbidShowWeb forbid show web
ForbidShowWeb = 2
// ForbidShowOversea forbid show oversea
ForbidShowOversea = 3
// ForbidShowOnline forbid show online
ForbidShowOnline = 4
//ForbidAttrChannel forbid channel
ForbidAttrChannel = 101
//ForbidAttrHot forbid hot
ForbidAttrHot = 102
)
var (
_forbidBits = map[string]map[uint]string{
ForbidRank: map[uint]string{
ForbidRankMain: "所有排行禁止",
ForbidRankRecentArc: "近期稿件排行禁止",
ForbidRankAllArc: "全部稿件排行禁止",
},
ForbidDynamic: map[uint]string{
ForbidDynamicMain: "所有动态禁止",
},
ForbidRecommend: map[uint]string{
ForbidRecommendMain: "所有推荐禁止",
},
ForbidShow: map[uint]string{
ForbidShowMain: "移动端最新/网页端最新/热度/在线等禁止",
ForbidShowMobile: "移动端最新禁止",
ForbidShowWeb: "网页端最新禁止",
ForbidShowOversea: "海外禁止",
ForbidShowOnline: "在线列表禁止",
},
}
)
// ForbidAttr forbid attribute
type ForbidAttr struct {
Aid int64 `json:"aid"`
OnFlowID int64 `json:"on_flow_id"`
RankV int32 `json:"-"`
DynamicV int32 `json:"-"`
RecommendV int32 `json:"-"`
ShowV int32 `json:"-"`
// specific
Rank struct {
Main int32 `json:"main"`
RecentArc int32 `json:"recent_arc"`
AllArc int32 `json:"all_arc"`
} `json:"rank_attr"`
Dynamic struct {
Main int32 `json:"main"`
} `json:"dynamic_attr"`
Recommend struct {
Main int32 `json:"main"`
} `json:"recommend_attr"`
Show struct {
Main int32 `json:"main"`
Mobile int32 `json:"mobile"`
Web int32 `json:"web"`
Oversea int32 `json:"oversea"`
Online int32 `json:"online"`
} `json:"show_attr"`
}
// 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
}
// ForbidBitDesc return bit desc.
func ForbidBitDesc(name string, bit uint) (desc string) {
return _forbidBits[name][bit]
}

View File

@@ -0,0 +1,98 @@
package archive
import "go-common/library/time"
//ArcHistory 稿件的用户编辑历史
type ArcHistory struct {
ID int64 `json:"id"`
AID int64 `json:"aid"`
Title string `json:"title"`
Tag string `json:"tag"`
Content string `json:"content"`
Cover string `json:"cover"`
MID int64 `json:"mid"`
CTime time.Time `json:"ctime"`
}
//VideoHistory 视频的用户编辑历史
type VideoHistory struct {
ID int64 `json:"id"`
CID int64 `json:"cid"`
EpTitle string `json:"eptitle"`
Description string `json:"description"`
Filename string `json:"filename"`
SRCType string `json:"src_type"`
CTime time.Time `json:"ctime"`
}
//EditHistory 一次完整的用户编辑历史
type EditHistory struct {
ArcHistory *ArcHistory `json:"arc_history"`
VHistory []*VideoHistory `json:"v_history"`
}
func (ah *ArcHistory) diff(one *ArcHistory) (res *ArcHistory, diff bool) {
if one == nil {
res = ah
diff = true
return
}
res = &ArcHistory{
ID: ah.ID,
AID: ah.AID,
CTime: ah.CTime,
}
if ah.Title != one.Title {
res.Title = ah.Title
diff = true
}
if ah.Tag != one.Tag {
res.Tag = ah.Tag
diff = true
}
if ah.Content != one.Content {
res.Content = ah.Content
diff = true
}
if ah.Cover != one.Cover {
res.Cover = ah.Cover
diff = true
}
if ah.MID != one.MID {
res.MID = ah.MID
diff = true
}
return
}
//Diff only show diff between next archive edit history
func (eh *EditHistory) Diff(one *EditHistory) (res *EditHistory, diff bool) {
if one == nil {
res = eh
diff = true
return
}
var ah *ArcHistory
vh := []*VideoHistory{}
oldfs := map[string]int{}
ah, diff = eh.ArcHistory.diff(one.ArcHistory)
//show those whose filenames not exist in one
for _, v := range one.VHistory {
oldfs[v.Filename] = 1
}
for _, v := range eh.VHistory {
if oldfs[v.Filename] != 1 {
vh = append(vh, v)
diff = true
}
}
res = &EditHistory{
ArcHistory: ah,
VHistory: vh,
}
return
}

View File

@@ -0,0 +1,28 @@
package archive
import (
"github.com/smartystreets/goconvey/convey"
"testing"
)
func Test_diff(t *testing.T) {
e1 := &EditHistory{
ArcHistory: &ArcHistory{Title: "haha"},
VHistory: []*VideoHistory{&VideoHistory{Filename: "hahah1"}, &VideoHistory{Filename: "hahah2"}},
}
var e2 *EditHistory
convey.Convey("diff between one and nil", t, func() {
diff, _ := e1.Diff(e2)
convey.So(diff, convey.ShouldEqual, e1)
})
e2 = &EditHistory{
ArcHistory: nil,
VHistory: []*VideoHistory{&VideoHistory{Filename: "hahah1"}},
}
convey.Convey("diff between 2 history", t, func() {
diff, _ := e1.Diff(e2)
convey.So(diff.ArcHistory.Title, convey.ShouldEqual, e1.ArcHistory.Title)
convey.So(len(diff.VHistory), convey.ShouldEqual, 1)
})
}

View File

@@ -0,0 +1,14 @@
package archive
import (
"go-common/app/admin/main/videoup/model/utils"
)
//Mosaic 马赛克
type Mosaic struct {
ID int64 `json:"id"`
AID int64 `json:"aid"`
CID int64 `json:"cid"`
Coordinate string `json:"coordinate"`
CTime utils.FormatTime `json:"ctime"`
}

View File

@@ -0,0 +1,146 @@
package archive
import (
"fmt"
"go-common/app/admin/main/videoup/model/utils"
)
// .
const (
// OperTypeMission 活动id被修改
OperTypeMission = int8(1)
// OperTypeTag tag被修改
OperTypeTag = int8(2)
// OperTypeCopyright 版权类型被修改
OperTypeCopyright = int8(3)
// OperTypeTypeID 分区ID被修改
OperTypeTypeID = int8(4)
// OperTypeRejectReason 打回理由被修改
OperTypeRejectReason = int8(5)
// OperTypeForwardID 转车跳转被修改
OperTypeForwardID = int8(6)
// OperTypeFlowID 私单类型被修改
OperTypeFlowID = int8(7)
// OperTypeDelay 定时发布被修改
OperTypeDelay = int8(8)
// OperTypePtime 发布时间被修改
OperTypePtime = int8(10)
// OperTypeAccess 可见属性被修改
OperTypeAccess = int8(11)
// OperTypeAduitReason 审核理由被修改
OperTypeAduitReason = int8(12)
// OperTypeRecicleTag 打回理由被修改
OperTypeRecicleTag = int8(13)
// OperTypeTaskID 任务ID被修改
OperTypeTaskID = int8(14)
// OperTypeOpenTag 通过Tag被修改
OperTypeOpenTag = int8(15)
// OperTypeDynamic 动态描述被修改
OperTypeDynamic = int8(16)
OperNotify = int8(17)
//私单
OperPorderIndustryID = int8(18)
OperPorderOfficial = int8(19)
OperPorderBrandID = int8(20)
OperPorderBrandName = int8(21)
OperPorderShowType = int8(22)
OperPorderAdvertiser = int8(23)
OperPorderAgent = int8(24)
OperPorderShowFront = int8(25)
//频道回查属性
OperFlowAttrNoChannel = int8(26)
OperFlowAttrNoHot = int8(27)
// OperStyleOne 操作展示类型1[%s]从[%v]设为[%v]
OperStyleOne = int8(1)
// OperStyleTwo 操作展示类型2[%s]%v:%v
OperStyleTwo = int8(2)
)
var (
//FlowOperType flow oper id
FlowOperType = map[int64]int8{
FlowGroupNoChannel: OperFlowAttrNoChannel,
FlowGroupNoHot: OperFlowAttrNoHot,
}
_operType = map[int8]string{
OperTypeMission: "活动ID",
OperTypeTag: "TAG内容",
OperTypeCopyright: "投稿类型",
OperTypeTypeID: "分区类型",
OperTypeRejectReason: "回查理由",
OperTypeForwardID: "撞车跳转",
OperTypeFlowID: "流量TAG",
OperTypeDelay: "定时发布",
OperTypePtime: "发布时间",
OperTypeAccess: "可见属性",
OperTypeAduitReason: "审核理由",
OperTypeRecicleTag: "打回Tag",
OperTypeTaskID: "任务ID",
OperTypeOpenTag: "通过Tag",
OperTypeDynamic: "动态描述",
OperNotify: "系统通知",
OperPorderIndustryID: "推广行业",
OperPorderOfficial: "是否官方",
OperPorderBrandID: "推广品牌ID",
OperPorderBrandName: "推广品牌",
OperPorderShowType: "推广形式",
OperPorderAdvertiser: "广告主",
OperPorderAgent: "代理商",
OperPorderShowFront: "是否前端展示",
OperFlowAttrNoChannel: "频道禁止",
OperFlowAttrNoHot: "热门禁止",
}
)
// ArcOper archive oper.
type ArcOper struct {
ID int64
Aid int64
UID int64
TypeID int16
State int16
Content string
Round int8
Attribute int32
LastID int64
Remark string
}
// VideoOper video oper.
type VideoOper struct {
ID int64 `json:"id"`
AID int64 `json:"aid"`
UID int64 `json:"uid"`
VID int64 `json:"vid"`
Status int16 `json:"status"`
Content string `json:"content"`
Attribute int32 `json:"attribute"`
LastID int64 `json:"last_id"`
Remark string `json:"remark"`
CTime utils.FormatTime `json:"ctime"`
}
// Operformat oper format.
func Operformat(tagID int8, old, new interface{}, style int8) (cont string) {
var template string
switch style {
case OperStyleOne:
template = "[%s]从[%v]设为[%v]"
case OperStyleTwo:
template = "[%s]%v:%v"
}
cont = fmt.Sprintf(template, _operType[tagID], old, new)
return
}
// AccessState get orange state
func AccessState(state int8, access int16) (newState int16) {
if NormalState(state) && access == AccessMember {
newState = access
return
}
newState = int16(state)
return
}

View File

@@ -0,0 +1,205 @@
package archive
import (
"go-common/app/admin/main/videoup/model/message"
"go-common/library/time"
)
const (
// ActionVideoSubmit 视频提交
ActionVideoSubmit = "videoSubmit"
// ActionArchiveSubmit 稿件提交
ActionArchiveSubmit = "archiveSubmit"
// ActionArchiveSecondRound 无稿件信息修改的补发二审消息
ActionArchiveSecondRound = "archiveSecondRound"
// ActionArchiveAttr 稿件属性修改
ActionArchiveAttr = "archiveAttr"
// ActionArchiveTypeID 稿件分区修改
ActionArchiveTypeID = "archiveTypeID"
//ActionArchiveTag 保存稿件标签
ActionArchiveTag = "archiveTag"
//ActionArchiveTagRecheck 保存稿件标签,并频道回查
ActionArchiveTagRecheck = "archiveTagRecheck"
//FromListChannelReview 提交来源列表 频道回查
FromListChannelReview = "channel_review"
)
// VideoParam video struct
type VideoParam struct { // TODO: batch param
ID int64 `json:"id"`
Filename string `json:"filename"`
Aid int64 `json:"aid"`
Mid int64 `json:"mid"`
RegionID int16 `json:"region_id"`
VideoDesign *message.VideoDesign `json:"video_design,omitempty"`
Status int16 `json:"status"`
CTime time.Time `json:"ctime"`
Cid int64 `json:"cid,omitempty"`
Title string `json:"title,omitempty"`
Desc string `json:"desc,omitempty"`
Index int `json:"index,omitempty"`
SrcType string `json:"src_type,omitempty"`
Playurl string `json:"playurl,omitempty"`
FailCode int8 `json:"failinfo,omitempty"`
Duration int64 `json:"duration,omitempty"`
XcodeState int8 `json:"xcode_state,omitempty"`
Attribute int32 `json:"attribute,omitempty"`
Filesize int64 `json:"filesize,omitempty"`
WebLink string `json:"weblink,omitempty"`
Resolutions string `json:"resolutions,omitempty"`
Encoding int8 `json:"encoding"`
EncodePurpose string `json:"encode_purpose,omitempty"`
UID int64 `json:"uid,omitempty"`
TaskID int64 `json:"task_id,omitempty"`
Oname string `json:"oname,omitempty"`
TagID int64 `json:"tag_id,omitempty"`
Reason string `json:"reason,omitempty"`
ReasonID int64 `json:"reject_reason_id,omitempty"`
Note string `json:"note,omitempty"`
Attrs *AttrParam `json:"attrs,omitempty"`
}
// ArcParam sencond round param
type ArcParam struct {
Aid int64 `json:"id"`
Mid int64 `json:"mid"`
UID int64 `json:"uid"`
UName string `json:"uname"`
CanCelMission bool `json:"cancel_mission"`
Cover string `json:"cover"`
Source string `json:"source"`
URL string `json:"redirecturl"`
Forward int64 `json:"forward"`
PTime time.Time `json:"pubtime"`
DTime time.Time `json:"delaytime"`
CTime time.Time `json:"ctime"`
Delay bool `json:"delay"`
Tag string `json:"tag,omitempty"`
IsUpBind bool `json:"is_up_bind"`
SyncHiddenTag bool `json:"sync_hidden_tag"`
Copyright int8 `json:"copyright"`
FlagCopyright bool `json:"flag_copyright"`
Access int16 `json:"access"`
State int8 `json:"state"`
Round int8 `json:"round"`
Title string `json:"title,omitempty"`
TypeID int16 `json:"typeid"`
Content string `json:"content"`
Note string `json:"note"`
Attrs *AttrParam `json:"attrs,omitempty"`
Forbid *ForbidAttr `json:"forbid"`
Author string `json:"author"`
RejectReason string `json:"reject_reason"`
ReasonID int64 `json:"reason_id"`
ChangeDelay bool `json:"change_delay"`
Notify bool `json:"notify"`
NoEmail bool `json:"no_email"`
ForceSync bool `json:"force_sync"`
OnFlowID int64 `json:"on_flow_id"`
Dynamic string `json:"dynamic"`
Porder
UpNote string `json:"highrisk_note"`
// AdminChange
AdminChange bool `json:"admin_change"`
PolicyID int64 `json:"policy_id"`
ApplyUID int64 `json:"apply_uid"`
FromList string `json:"from_list"`
FlowAttribute map[string]int32 `json:"flow_attribute"`
}
//Porder table
type Porder struct {
IndustryID int64 `json:"industry_id"`
BrandID int64 `json:"brand_id"`
BrandName string `json:"brand_name"`
Official int8 `json:"official"`
ShowType string `json:"show_type"`
ShowFront int8 `json:"show_front"`
Advertiser string `json:"advertiser"`
Agent string `json:"agent"`
GroupID int64 `json:"group_id"`
State int8 `json:"state"`
PorderAction string `json:"porder_action"`
}
//PorderConfig table
type PorderConfig struct {
ID int64 `json:"id"`
Type int8 `json:"type"`
Name string `json:"name"`
State int8 `json:"state"`
Code string `json:"code"`
Rank int8 `json:"rank"`
}
// AttrParam bit
type AttrParam struct {
NoRank int32 `json:"no_rank,omitempty"` // 0
NoDynamic int32 `json:"no_dynamic,omitempty"` // 1
NoWeb int32 `json:"no_web,omitempty"` // 2
NoMobile int32 `json:"no_mobile,omitempty"` // 3
NoSearch int32 `json:"no_search,omitempty"` // 4
OverseaLock int32 `json:"oversea_block,omitempty"` // 5
NoRecommend int32 `json:"no_recommend,omitempty"` // 6
NoReprint int32 `json:"no_reprint,omitempty"` // 7
HasHD5 int32 `json:"is_hd,omitempty"` // 8
IsPGC int32 `json:"is_pgc,omitempty"` // 9
AllowBp int32 `json:"allow_bp,omitempty"` // 10
IsBangumi int32 `json:"is_bangumi,omitempty"` // 11
IsPorder int32 `json:"is_porder,omitempty"` // 12
LimitArea int32 `json:"limit_area,omitempty"` // 13
AllowTag int32 `json:"allow_tag,omitempty"` // 14
JumpURL int32 `json:"is_jumpurl,omitempty"` // 16
IsMovie int32 `json:"is_movie,omitempty"` // 17
BadgePay int32 `json:"is_pay,omitempty"` // 18
PushBlog int32 `json:"push_blog,omitempty"` // 20
ParentMode int32 `json:"parent_mode,omitempty"` // 21
UGCPay int32 `json:"ugcpay,omitempty"` // 22
}
// IndexParam index_order.
type IndexParam struct {
Aid int64 `json:"aid"`
ListOrder []*struct {
ID int64 `json:"id"`
Index int `json:"index"`
} `json:"list_order"`
}
// MultSyncParam bath sync.
type MultSyncParam struct {
Action string `json:"action"`
VideoParam *VideoParam `json:"videoParam,omitempty"`
ArcParam *ArcParam `json:"archiveParam,omitempty"`
}
// SyncAction sync action.
type SyncAction struct {
Action string `json:"action"`
}
//TagParam update archive tag
type TagParam struct {
AID int64 `form:"aid" validate:"required"`
Tags string `form:"tags"`
FromChannelReview string `form:"channel_review"`
}
//BatchTagParam update batch archives' tag
type BatchTagParam struct {
AIDs []int64 `form:"aids,split" validate:"gt=0,dive,gt=0"`
Action string `form:"action"`
Tags string `form:"tags"`
Note string `form:"note"`
IsUpBind bool `form:"is_up_bind"`
SyncHiddenTag bool `form:"sync_hidden_tag"`
FromList string `form:"from_list"`
}
//ChannelReviewInfo 频道回查检查
type ChannelReviewInfo struct {
AID int64
ChannelIDs string
NeedReview bool
CanOperRecheck bool
}

View File

@@ -0,0 +1,26 @@
package archive
//StaffParam .
type StaffParam struct {
MID int64 `json:"mid"`
Title string `json:"title"`
}
//StaffBatchParam 批量提交的staff参数
type StaffBatchParam struct {
AID int64 `json:"aid"`
SyncAttr bool `json:"sync_attr"`
Staffs []*StaffParam `json:"staffs"`
}
//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"`
}

View File

@@ -0,0 +1,19 @@
package archive
import "time"
// StatsPoint points struct for stats
type StatsPoint struct {
ID int64 `json:"id"`
Type int8 `json:"type"`
Content string `json:"content"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// ArcStayCount .
type ArcStayCount struct {
Round int8 `json:"round"`
State int8 `json:"state"`
Count int64 `json:"count"`
}

View File

@@ -0,0 +1,391 @@
package archive
import (
"time"
"go-common/app/admin/main/videoup/model/utils"
"go-common/library/log"
"go-common/library/xstr"
)
const (
// ActionHandsUP 0签入
ActionHandsUP = int8(0)
// ActionHandsOFF 1签出
ActionHandsOFF = int8(1)
// ActionSubmit 2提交
ActionSubmit = int8(2)
// ActionDelay 3延迟
ActionDelay = int8(3)
// ActionClose 4关闭
ActionClose = int8(4)
//ActionOldSubmit 5旧一审提交
ActionOldSubmit = int8(5)
//ActionTaskDelete 10任务删除
ActionTaskDelete = int8(10)
//ActionDispatch 分配
ActionDispatch = int8(6)
//ActionRelease 释放(拒审)
ActionRelease = int8(7)
// WConfMid 按照mid配置权重
WConfMid = int8(0)
// WConfTaskID 按照taskid配置权重
WConfTaskID = int8(1)
// WConfType 按照分区配置权重
WConfType = int8(2)
// WConfUpFrom 按照投稿来源配置权重
WConfUpFrom = int8(3)
// WConfRelease 指派任务释放
WConfRelease = int8(4)
// TimeFormatSec 时间格式化
TimeFormatSec = "2006-01-02 15:04:05"
)
var (
// TookTypeMinute 一审耗时每分钟打点
TookTypeMinute = int8(1)
// TookTypeHalfHour 一审耗时半小时打点
TookTypeHalfHour = int8(2)
// PoolForFirst 一审任务池
PoolForFirst = int8(0)
// PoolForSecond 二审任务池
PoolForSecond = int8(1)
// TypeRealTime 实时任务
TypeRealTime = int8(0)
// TypeDispatched 已分发任务
TypeDispatched = int8(1)
// TypeFinished 结束任务
TypeFinished = int8(2)
// TypeDelay 延时任务
TypeDelay = int8(3)
// TypeClosed 停滞任务
TypeClosed = int8(4)
// TypeSpecial 特殊任务
TypeSpecial = int8(5)
// TypeUpDelete 已删除任务
TypeUpDelete = int8(6)
// TypeSpecialWait 特殊停滞任务
TypeSpecialWait = int8(7)
// SubjectForNormal 普通任务
SubjectForNormal = int8(0) //normal task subject
// SubjectForTask 指派任务
SubjectForTask = int8(1) //specified task subject
_taskdispatchstate = map[int8]struct{}{
TypeRealTime: struct{}{},
TypeDispatched: struct{}{},
TypeFinished: struct{}{},
TypeDelay: struct{}{},
TypeClosed: struct{}{},
TypeSpecial: struct{}{},
TypeUpDelete: struct{}{},
TypeSpecialWait: struct{}{},
}
// WLVConf 默认值
WLVConf = &WeightVC{
MaxWeight: int64(200000), //最大权重值
SubRelease: int64(18), //指派再释放的任务
//特殊任务参数
Slv1: int64(8), // 普通用户>=1W粉
Slv2: int64(10), // 普通用户>=10W粉
Slv3: int64(12), // 优质用户<1W粉
Slv4: int64(15), // 优质用户>=1W粉
Slv5: int64(18), // 优质用户>=10W粉
Slv6: int64(6), // 高危用户>=10W粉
Slv7: int64(0), // 其他高危
//普通任务参数
Nlv1: int64(3), // 等待时长 9-15
Nlv2: int64(6), // 等待时长 15-27
Nlv3: int64(9), // 等待时长 27-45
Nlv4: int64(12), // 等待时长 >45
Nlv5: int64(0), // 等待时长 <=9
//定时任务参数
Tlv1: int64(3), // 距离发布2h-4h
Tlv2: int64(9), // 距离发布1-2h
Tlv3: int64(21), // 距离发布 <1h
Tlv4: int64(0), // 距离发布 > 4h
}
)
// CfWeightDesc 权重配置文字描述
func CfWeightDesc(radio int8) (desc string) {
switch radio {
case WConfMid:
desc = "mid配置"
case WConfTaskID:
desc = "taskid配置"
case WConfType:
desc = "分区配置"
case WConfUpFrom:
desc = "投稿来源"
case WConfRelease:
desc = "指派释放"
default:
desc = "其他配置"
}
return
}
// IsDispatch 判断任务状态
func IsDispatch(st int8) bool {
if _, ok := _taskdispatchstate[st]; ok {
return true
}
return false
}
// ParseWeightConf 解析权重配置
func ParseWeightConf(twc *WeightConf, uid int64, uname string) (mcases map[int64]*WCItem, IsTaskID bool, err error) {
var (
ids []int64
)
mcases = make(map[int64]*WCItem)
if ids, err = xstr.SplitInts(twc.Ids); err != nil {
log.Error("ParseWeightConfig Config(%v) parse error(%v) Idlist(%s)", twc, err)
return nil, false, err
}
for _, id := range ids {
wci := &WCItem{
CID: id,
Radio: twc.Radio,
Rule: twc.Rule,
Weight: twc.Weight,
Uname: uname,
Desc: twc.Desc,
Bt: twc.Bt,
Et: twc.Et,
Mtime: utils.NewFormatTime(time.Now()),
}
if twc.Radio == WConfTaskID {
IsTaskID = true
}
mcases[id] = wci
}
return
}
// WeightVC Weight Value Config 权重分值配置
type WeightVC struct {
MaxWeight int64 `json:"maxweight" form:"maxweight" default:"20000"`
SubRelease int64 `json:"subrelease" form:"subrelease" default:"18"`
Slv1 int64 `json:"slv1" form:"slv1" default:"8"`
Slv2 int64 `json:"slv2" form:"slv2" default:"10"`
Slv3 int64 `json:"slv3" form:"slv3" default:"12"`
Slv4 int64 `json:"slv4" form:"slv4" default:"15"`
Slv5 int64 `json:"slv5" form:"slv5" default:"18"`
Slv6 int64 `json:"slv6" form:"slv6" default:"6"`
Slv7 int64 `json:"slv7" form:"slv7" default:"0"`
Nlv1 int64 `json:"nlv1" form:"nlv1" default:"3"`
Nlv2 int64 `json:"nlv2" form:"nlv2" default:"6"`
Nlv3 int64 `json:"nlv3" form:"nlv3" default:"9"`
Nlv4 int64 `json:"nlv4" form:"nlv4" default:"12"`
Nlv5 int64 `json:"nlv5" form:"nlv5" default:"0"`
Tlv1 int64 `json:"tlv1" form:"tlv1" default:"3"`
Tlv2 int64 `json:"tlv2" form:"tlv2" default:"9"`
Tlv3 int64 `json:"tlv3" form:"tlv3" default:"21"`
Tlv4 int64 `json:"tlv4" form:"tlv4" default:"0"`
}
// Task 审核任务
type Task struct {
ID int64 `json:"id"`
Pool int8 `json:"pool"`
Subject int8 `json:"subject"`
AdminID int64 `json:"adminid"`
Aid int64 `json:"aid"`
Cid int64 `json:"cid"`
UID int64 `json:"uid"`
State int8 `json:"state"`
UTime int64 `json:"utime"`
CTime utils.FormatTime `json:"ctime"`
MTime utils.FormatTime `json:"mtime"`
DTime utils.FormatTime `json:"dtime"`
GTime utils.FormatTime `json:"gtime"`
PTime utils.FormatTime `json:"ptime"`
Weight int64 `json:"weight"`
Mid int64 `json:"mid"`
}
// TaskWeightLog 权重变更日志
type TaskWeightLog struct {
TaskID int64 `json:"taskid"`
Mid int64 `json:"mid"`
Weight int64 `json:"weight"`
CWeight int64 `json:"cweight"`
NWeight int64 `json:"nweight"`
SWeight int64 `json:"sweight"`
TWeight int64 `json:"tweight"`
Uptime utils.FormatTime `json:"uptime"`
Creator string `json:"creator"` //创作者
UpSpecial []int8 `json:"upspecial"` //标记是否优质,劣质用户
Fans int64 `json:"fans"` //粉丝数
Wait float64 `json:"wait"` //等待时长
Ptime string `json:"ptime,omitempty"`
CfItems []*WCItem `json:"cfitems,omitempty"`
Desc string `json:"desc,omitempty"` // 配置描述
}
// TaskPriority 审核任务权重的相关参数
type TaskPriority struct {
TaskID int64 `json:"taskid"`
Weight int64 `json:"weight"` //权重总值
State int8 `json:"state"` //任务状态
Mid int64 `json:"mid"`
Special int8 `json:"special"` //特殊任务
Ctime utils.FormatTime `json:"ctime"` //任务生成时间
Ptime utils.FormatTime `json:"ptime"` //定时发布时间
CfItems []*WCItem `json:"cfitems,omitempty"`
// 兼容videoup-task-admin 用于判断复审的参数
/*
TODO:
目前前端v1版本使用videoup-admin接口 v2版本使用videoup-task-admin接口
待前端迁移完成再将videoup-admin中任务代码删除
*/
Fans int64 `json:"fans"` //粉丝数
AccFailed bool `json:"accfaild"` //账号查询是否失败
UpGroups []int8 `json:"ugs"` //分组
UpFrom int8 `json:"upfrom"` //来源
TypeID int16 `json:"typeid"` //分区
}
// WeightConf 任务权重配置
type WeightConf struct {
Radio int8 `form:"radio"` // 0,mid1taskid2分区, 3, 投稿来源
Ids string `form:"ids" validate:"required"` // id列表逗号分隔
Rule int8 `form:"rule"` // 0,动态权重1静态权重
Weight int64 `form:"weight" validate:"required"` // 配置的权重
Desc string `form:"desc" validate:"required"` // 描述信息
Bt utils.FormatTime `form:"bt"` //配置生效开始时间
Et utils.FormatTime `form:"et"` //配置生效结束时间
}
// WCItem task weight config item
type WCItem struct {
Radio int8 `json:"radio"`
ID int64 `json:"id,omitempty"`
CID int64 `json:"cid"` // config id 四种配置通用
UID int64 `json:"uid,omitempty"`
Uname string `json:"user,omitempty"`
TypeName string `json:"typename,omitempty"`
UpFrom string `json:"upfrom,omitempty"`
Rule int8 `json:"rule"`
State int8 `json:"state"`
Weight int64 `json:"weight,omitempty"`
Mtime utils.FormatTime `json:"mtime,omitempty"`
Desc string `json:"desc,omitempty"`
FileName string `json:"filename,omitempty"`
Title string `json:"title,omitempty"`
Vid int64 `json:"vid,omitempty"`
Creator string `json:"creator,omitempty"`
Fans int64 `json:"fans,omitempty"`
Bt utils.FormatTime `json:"bt,omitempty"`
Et utils.FormatTime `json:"et,omitempty"`
}
// Confs 权重配置筛选参数
type Confs struct {
Radio int8 `form:"radio" default:"1"`
Cid int64 `form:"cid" default:"-1"`
Operator string `form:"operator"`
Bt utils.FormatTime `form:"bt"`
Et utils.FormatTime `form:"et"`
Rule int8 `form:"rule" default:"-1"`
State int `form:"state"`
Pn int `form:"page" default:"1"`
Ps int `form:"ps" default:"20"`
}
// TaskTook 一审耗时
type TaskTook struct {
ID int64 `json:"id"`
M90 int `json:"m90"`
M80 int `json:"m80"`
M60 int `json:"m60"`
M50 int `json:"m50"`
TypeID int8 `json:"type"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"-"`
}
// AuthRole 一审任务角色
type AuthRole struct {
ID int64 `json:"id"`
UID int64 `json:"uid"`
Role int8 `json:"role"`
UserName string `json:"username"`
NickName string `json:"nickname"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// Consumers 组员信息
type Consumers struct {
ID int64 `json:"id"`
UID int64 `json:"uid"`
UserName string `json:"username"`
State int8 `json:"state"`
Ctime utils.FormatTime `json:"ctime"`
Mtime utils.FormatTime `json:"mtime"`
LastOut string `json:"lastout,omitempty"`
}
// ConsumerLog 组员日志
type ConsumerLog struct {
UID int64 `json:"uid"`
Uname string `json:"uname"`
Action int8 `json:"action"`
Ctime string `json:"ctime"`
Desc string `json:"desc"`
}
// InQuit 组员日志
type InQuit struct {
Date string `json:"date"`
UID int64 `json:"uid"`
Uname string `json:"uname"`
InTime string `json:"inTime"`
OutTime string `json:"quitTime"`
}
// SearchLogResult is.
type SearchLogResult struct {
Code int `json:"code"`
Data struct {
Order string `json:"order"`
Sort string `json:"sort"`
Result []struct {
UID int64 `json:"uid"`
Uname string `json:"uname"`
OID int64 `json:"oid"`
Type int8 `json:"type"`
Action string `json:"action"`
Str0 string `json:"str_0"`
Str1 string `json:"str_1"`
Str2 string `json:"str_2"`
Int0 int `json:"int_0"`
Int1 int `json:"int_1"`
Int2 int `json:"int_2"`
Ctime string `json:"ctime"`
Extra string `json:"extra_data"`
} `json:"result"`
Page struct {
Num int `json:"num"`
Size int `json:"size"`
Total int `json:"total"`
} `json:"page"`
} `json:"data"`
}
// TaskForLog 释放任务
type TaskForLog struct {
ID int64
Cid int64
Subject int8
Mtime time.Time
}

View File

@@ -0,0 +1,85 @@
package archive
import (
"go-common/app/admin/main/videoup/model/utils"
)
const (
//QATypeVideo 视频质检任务
QATypeVideo = int8(1)
)
//QAVideo 质检视频详情
type QAVideo struct {
UID int64 `json:"uid"`
Oname string `json:"username"`
AID int64 `json:"aid"`
CID int64 `json:"cid"`
TaskID int64 `json:"task_id"`
TaskUTime int64 `json:"task_utime"`
Attribute int32 `json:"attribute"`
TagID int64 `json:"tag_id"`
ArcTitle string `json:"arc_title"`
ArcTypeid int64 `json:"arc_typeid"`
AuditStatus int16 `json:"audit_status"`
AuditSubmit string `json:"audit_submit"`
AuditDetails string `json:"audit_details"`
MID int64 `json:"mid"`
UPGroups []int64 `json:"up_groups"`
Fans int64 `json:"fans"`
}
//AuditSubmit 提交的审核内容
type AuditSubmit struct {
Encoding string `json:"encoding"`
Attribute string `json:"attribute"`
ReasonID string `json:"reason_id"`
Reason string `json:"reason"`
Note string `json:"note"`
}
//AuditDetails 提交详情
type AuditDetails struct {
UserInfo map[string]interface{} `json:"user_info"`
RelationVideos []*RelationVideo `json:"relation_videos"`
Task []*Task `json:"task"`
Video *VideoInfo `json:"video"`
Watermark []*Watermark `json:"watermark"`
Mosaic []*Mosaic `json:"mosaic"`
}
//RelationVideo related video
type RelationVideo struct {
Filename string `json:"filename"`
Status int16 `json:"status"`
AID int64 `json:"aid"`
IndexOrder int `json:"index_order"`
Title string `json:"title"`
Ctime utils.FormatTime `json:"ctime"`
}
//VideoInfo video info
type VideoInfo struct {
ID int64 `json:"id"`
MID int64 `json:"mid"`
CID int64 `json:"cid"`
Eptitle string `json:"eptitle"`
Filename string `json:"filename"`
Epctime utils.FormatTime `json:"epctime"`
AID int64 `json:"aid"`
Ctime utils.FormatTime `json:"ctime"`
Description string `json:"description"`
Title string `json:"-"`
Tag string `json:"tag"`
Content string `json:"content"`
Dynamic string `json:"dynamic"`
Author string `json:"author"`
Copyright string `json:"copyright"`
Source string `json:"source"`
Typename string `json:"typename"`
Cover string `json:"cover"`
XcodeState int8 `json:"xcode_state"`
XcodeStateName string `json:"xcode_state_name"`
Playurl string `json:"playurl"`
Typeid int64 `json:"-"`
}

View File

@@ -0,0 +1,82 @@
package archive
import "go-common/library/time"
const (
// VideoUploadInfo 视频上传完成
VideoUploadInfo = int8(0)
// VideoXcodeSDFail 视频转码失败
VideoXcodeSDFail = int8(1)
// VideoXcodeSDFinish 一转完成
VideoXcodeSDFinish = int8(2)
// VideoXcodeHDFail 二转失败
VideoXcodeHDFail = int8(3)
// VideoXcodeHDFinish 二转完成
VideoXcodeHDFinish = int8(4)
// VideoDispatchRunning 正在分发
VideoDispatchRunning = int8(5)
// VideoDispatchFinish 分发完成
VideoDispatchFinish = int8(6)
// VideoStatusOpen 视频开放浏览
VideoStatusOpen = int16(0)
// VideoStatusAccess 视频会员可见
VideoStatusAccess = int16(10000)
// VideoStatusWait 视频待审
VideoStatusWait = int16(-1)
// VideoStatusRecycle 视频被打回
VideoStatusRecycle = int16(-2)
// VideoStatusLock 视频被锁定
VideoStatusLock = int16(-4)
// VideoStatusXcodeFail 视频转码失败
VideoStatusXcodeFail = int16(-16)
// VideoStatusSubmit 视频创建已提交
VideoStatusSubmit = int16(-30)
// VideoStatusDelete 视频被删除
VideoStatusDelete = int16(-100)
// XcodeFailZero 转码失败
XcodeFailZero = 0
)
//XcodeStateNames xcode name.
var (
XcodeStateNames = map[int8]string{
VideoUploadInfo: "上传成功",
VideoXcodeSDFail: "一转失败",
VideoXcodeSDFinish: "一转成功",
VideoXcodeHDFail: "二转失败",
VideoXcodeHDFinish: "二转成功",
VideoDispatchRunning: "分发中",
VideoDispatchFinish: "分发完成",
}
)
// 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:"-"`
Cid int64 `json:"cid"`
Duration int64 `json:"-"`
Filesize int64 `json:"-"`
Resolutions string `json:"-"`
Index int `json:"index"`
Playurl string `json:"-"`
Status int16 `json:"status"`
StatusDesc string `json:"status_desc"`
FailCode int8 `json:"fail_code"`
FailDesc string `json:"fail_desc"`
XcodeState int8 `json:"xcode"`
Attribute int32 `json:"-"`
RejectReason string `json:"reject_reason"`
WebLink string `json:"weblink"`
CTime time.Time `json:"ctime"`
MTime time.Time `json:"-"`
}
// AttrSet video Attr set
func (v *Video) AttrSet(attr int32, bit uint) {
v.Attribute = v.Attribute&(^(1 << bit)) | (attr << bit)
}

View File

@@ -0,0 +1,17 @@
package archive
import "go-common/app/admin/main/videoup/model/utils"
//Watermark 水印
type Watermark struct {
ID int64 `json:"id"`
Info string `json:"info"`
MD5 string `json:"m5"`
MID string `json:"mid"`
Position string `json:"position"`
Type string `json:"type"`
Uname string `json:"uname"`
URL string `json:"url"`
State string `json:"state"`
MTime utils.FormatTime `json:"mtime"`
}

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/admin/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,59 @@
package manager
const (
// UpperTypeWhite 白名单UP主
UpperTypeWhite int8 = 1
// UpperTypeBlack 黑名单UP主
UpperTypeBlack int8 = 2
// UpperTypePGC PGC UP主
UpperTypePGC int8 = 3
// UpperTypeUGCX UGC UP主
UpperTypeUGCX int8 = 4
// UpperTypePolity 时政 Up主
UpperTypePolity int8 = 5
// UpperTypeDanger 高危UP主
UpperTypeDanger int8 = 6
// UpperTypeTwoForbid 二禁UP主
UpperTypeTwoForbid int8 = 10
// UpperTypePGCWhite 视频自动锁定 PGC白名单
UpperTypePGCWhite int8 = 11
// ReasonLogTypeArc 审核理由类型:稿件
ReasonLogTypeArc int8 = 1
// ReasonLogTypeVideo 审核理由类型:视频
ReasonLogTypeVideo int8 = 2
// TaskLeader 组长
TaskLeader int8 = 1
// TaskMember 组员
TaskMember int8 = 2
)
// User manager user struct
type User struct {
ID int64 `json:"id"`
UserName string `json:"username"`
NickName string `json:"nickname"`
State int8 `json:"state"`
}
// UpGroupData uper group api return data
type UpGroupData struct {
Code int `json:"code"`
Data []*UpGroup `json:"data"`
}
// UpGroup UP user group struct
type UpGroup struct {
ID int64 `json:"id"`
Name string `json:"name"`
Tag string `json:"tag"`
ShortTag string `json:"short_tag"`
//Remark string `json:"remark"`
//State int8 `json:"state"`
}
// UpGroup2 为了统一列表返回的up_group
type UpGroup2 struct {
GroupID int64 `json:"group_id"`
GroupName string `json:"group_name"`
GroupTag string `json:"group_tag"`
}

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 = ["message.go"],
importpath = "go-common/app/admin/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,80 @@
package message
// videoup route
const (
// videoup
RouteSyncCid = "sync_cid"
RouteFirstRound = "first_round"
RouteUGCFirstRound = "ugc_first_round"
RouteSecondRound = "second_round"
RouteAddArchive = "add_archive"
RouteModifyArchive = "modify_archive"
RouteDeleteVideo = "delete_video"
RouteDeleteArchive = "delete_archive"
RouteForceSync = "force_sync"
)
// Videoup msg
type Videoup struct {
Route string `json:"route"`
Fans int64 `json:"fans,omitempty"`
Filename string `json:"filename"`
Timestamp int64 `json:"timestamp"`
// cid
Cid int64 `json:"cid,omitempty"`
DMIndex string `json:"dm_index,omitempty"`
// encode
Xcode int8 `json:"xcode"`
EncodePurpose string `json:"encode_purpose,omitempty"`
EncodeRegionID int16 `json:"encode_region_id,omitempty"`
EncodeTypeID int16 `json:"encode_type_id,omitempty"`
VideoDesign *VideoDesign `json:"video_design,omitempty"`
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"`
SendEmail bool `json:"send_email"`
// ChangeTypeID
ChangeTypeID bool `json:"change_typeid"`
// ChangeCopyright
ChangeCopyright bool `json:"change_copyright"`
// ChangeCover
ChangeCover bool `json:"change_cover"`
// ChangeTitle
ChangeTitle bool `json:"change_title"`
// Notify
Notify bool `json:"send_notify"`
// MissionID
MissionID int64 `json:"mission_id,omitempty"`
// AdminChange
AdminChange bool `json:"admin_change,omitempty"`
FromList string `json:"from_list"`
}
//VideoDesign video design
type VideoDesign struct {
Mosaic []*Mosaic `json:"mosaic,omitempty"`
WaterMark []*WaterMark `json:"watermark,omitempty"`
}
//Mosaic mosaic
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 watermark
type WaterMark struct {
LOC int8 `json:"loc,omitempty"`
URL string `json:"url,omitempty"`
MD5 string `json:"md5,omitempty"`
Start int64 `json:"start,omitempty"`
End int64 `json:"end,omitempty"`
X int64 `json:"x,omitempty"`
Y int64 `json:"y,omitempty"`
}

View File

@@ -0,0 +1,32 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["monitor.go"],
importpath = "go-common/app/admin/main/videoup/model/monitor",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/admin/main/videoup/model/archive:go_default_library",
"//app/admin/main/videoup/model/manager: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,123 @@
package monitor
import (
"fmt"
"go-common/app/admin/main/videoup/model/archive"
"go-common/app/admin/main/videoup/model/manager"
)
const (
// RedisPrefix 参数:business。
BusPrefix = "monitor_stats_%d_"
// SuffixVideo 视频停留统计。参数:state
SuffixVideo = "%d"
// SuffixArc 稿件停留统计。参数:round。参数:state。
SuffixArc = "%d_%d"
RulesKey = "monitor_rules"
RuleIDIncKey = "monitor_rule_inc_id"
BusVideo int8 = 1
BusArc int8 = 2
RuleStateOK = 1
RuleStateDisable = 0
NotifyTypeEmail = 1
NotityTypeSms = 2
CompGT = ">"
CompLT = "<"
CompGET = ">="
CompLET = "<="
CompNE = "!="
CompE = "="
)
var (
// RedisKeyConf 监控业务的Redis Key配置
RedisKeyConf = map[int8]*KeyConf{
BusVideo: {
KeyFormat: fmt.Sprintf(BusPrefix, BusVideo) + SuffixVideo,
KFields: map[string][]int64{
"state": {
int64(archive.VideoStatusSubmit),
int64(archive.VideoStatusWait),
},
},
},
BusArc: {
KeyFormat: fmt.Sprintf(BusPrefix, BusArc) + SuffixArc,
KFields: map[string][]int64{
"round": {
int64(archive.RoundAuditSecond),
int64(archive.RoundAuditThird),
int64(archive.RoundReviewFlow),
int64(archive.RoundReviewFirst),
int64(archive.RoundReviewFirstWaitTrigger),
int64(archive.RoundReviewSecond),
int64(archive.RoundTriggerClick),
},
"state": {
int64(archive.StateForbidFixed),
int64(archive.StateForbidWait),
int64(archive.StateOpen),
int64(archive.StateOrange),
},
},
},
}
)
type KeyConf struct {
KeyFormat string
KFields map[string][]int64
}
type RuleResultParams struct {
Type int8 `form:"type" validate:"required"`
Business int8 `form:"business" validate:"required"`
//STime utils.FormatTime `form:"stime"`
//ETime utils.FormatTime `form:"etime"`
}
type RuleResultData struct {
Rule *Rule `json:"rule"`
User *manager.User `json:"user"`
Stats *Stats `json:"stats"`
}
// Rule 监控规则信息
type Rule struct {
ID int64 `json:"id"`
Type int8 `json:"type"`
Business int8 `json:"business"`
Name string `json:"name"`
State int8 `json:"state"`
STime string `json:"s_time"`
ETime string `json:"e_time"`
RuleConf *RuleConf `json:"rule_conf"`
UID int64 `json:"uid"`
CTime string `json:"ctime"`
}
// RuleConf 监控方案配置结构体
type RuleConf struct {
Name string `json:"name"`
MoniCdt map[string]struct { //监控方案的监控条件
Comp string `json:"comparison"`
Value int64 `json:"value"`
} `json:"moni_cdt"`
NotifyCdt map[string]struct { //达到发送通知的条件
Comp string `json:"comparison"`
Value int64 `json:"value"`
} `json:"notify_cdt"`
Notify struct { //通知类型配置
Way int8 `json:"way"`
Member []string `json:"member"`
} `json:"notify"`
}
type Stats struct {
TotalCount int `json:"total_count"`
MoniCount int `json:"moni_count"`
MaxTime int `json:"max_time"`
}

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 = ["music.go"],
importpath = "go-common/app/admin/main/videoup/model/music",
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,74 @@
package music
import (
xtime "go-common/library/time"
)
// consts for workflow event
const (
MusicDelete = -100
MusicOpen = 0
)
// Music model is the model for music
type Music struct {
ID int64 `json:"id" gorm:"column:id"`
Sid int64 `json:"sid" gorm:"column:sid"`
Name string `json:"name" gorm:"column:name"`
Musicians string `json:"musicians" gorm:"column:musicians"`
Mid int64 `json:"mid" gorm:"column:mid"`
Tid int64 `json:"tid" gorm:"-"`
Rid int64 `json:"rid" gorm:"-"`
Pid int64 `json:"pid" gorm:"-"`
Cover string `json:"cover" gorm:"column:cover"`
MaterialName string `json:"material_name" gorm:"-"`
CategoryName string `json:"category_name" gorm:"-"`
Stat string `json:"stat" gorm:"column:stat"`
Categorys string `json:"categorys" gorm:"column:categorys"`
Playurl string `json:"playurl" gorm:"column:playurl"`
State int8 `json:"state" gorm:"column:state"`
Duration int32 `json:"duration" gorm:"column:duration"`
Filesize int32 `json:"filesize" gorm:"column:filesize"`
PubTime xtime.Time `json:"pubtime" gorm:"column:pubtime"`
SyncTime xtime.Time `json:"synctime" gorm:"column:synctime"`
CTime xtime.Time `json:"ctime" gorm:"column:ctime"`
MTime xtime.Time `json:"mtime" gorm:"column:mtime"`
}
// TableName is used to identify table name in gorm
func (Music) TableName() string {
return "music"
}
// Param is used to parse user request
type Param struct {
ID int64 `form:"id" gorm:"column:id"`
Sid int64 `form:"sid" validate:"required"`
Name string `form:"name" validate:"required"`
Musicians string `form:"musicians"`
Mid int64 `form:"mid" validate:"required"`
Cover string `form:"cover" validate:"required"`
Stat string `form:"stat" `
Categorys string `form:"categorys" `
Playurl string `form:"playurl" `
State int8 `form:"state"`
Duration int32 `form:"duration" `
Filesize int32 `form:"filesize" `
UID int64 `form:"uid" `
PubTime xtime.Time `form:"pubtime"`
SyncTime xtime.Time `form:"synctime"`
}
// TableName is used to identify table name in gorm
func (Param) TableName() string {
return "music"
}
// LogParam is used to parse user request
type LogParam struct {
ID int64 `json:"id"`
UID int64 `json:"uid"`
UName string `json:"uname"`
Action string `json:"action"`
Name string `json:"name"`
}

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 = ["oversea.go"],
importpath = "go-common/app/admin/main/videoup/model/oversea",
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,84 @@
package oversea
import (
"go-common/library/time"
)
const (
StateOK = 1
StateDeleted = 0
)
type ArchiveRelation struct {
ID int64 `json:"id" gorm:"column:id"`
GroupID int64 `json:"policy_id" gorm:"column:policy_id"`
Aid int64 `json:"aid" gorm:"column:aid"`
}
func (ArchiveRelation) TableName() string {
return "archive_relation"
}
type PolicyGroup struct {
ID int64 `json:"id" gorm:"column:id"`
IsGlobal int8 `json:"is_global" gorm:"column:is_global"`
Aid int64 `json:"aid" gorm:"column:aid"`
Name string `json:"name" gorm:"column:name"`
Type int8 `json:"type" gorm:"column:type"`
State int8 `json:"state" gorm:"column:state"`
UserName string `json:"username" gorm:"-"`
UID int64 `json:"uid" gorm:"column:uid"`
Remark string `json:"remark" gorm:"column:remark;size:140"`
CTime time.Time `json:"ctime" gorm:"column:ctime"`
MTime time.Time `json:"mtime" gorm:"column:mtime"`
Items []*PolicyItem `json:"items" gorm:"-"`
}
func (PolicyGroup) TableName() string {
return "policy_group"
}
type PolicyGroupData struct {
Items []*PolicyGroup `json:"items"`
Pager *Pager `json:"pager"`
}
type Pager struct {
Num int64 `json:"num"`
Size int64 `json:"size"`
Total int64 `json:"total"`
}
type PolicyItem struct {
ID int64 `json:"id" gorm:"column:id"`
GroupID int64 `json:"group_id" gorm:"column:group_id"`
PlayAuth int8 `json:"play_auth" gorm:"column:play_auth"`
DownAuth int8 `json:"down_auth" gorm:"column:down_auth"`
AreaID string `json:"area_id" gorm:"column:area_id"`
ZoneID string `json:"zone_id" gorm:"column:zone_id"`
State int8 `json:"state" gorm:"column:state"`
}
func (PolicyItem) TableName() string {
return "policy_item"
}
type PolicyParams struct {
ID int64 `json:"id"`
DownAuth int8 `json:"down_auth"`
PlayAuth int8 `json:"play_auth"`
AreaIds []int64 `json:"area_id"`
}
type Zone struct {
ID int64 `json:"id"`
Name string `json:"name"`
Pid int64 `json:"pid"`
Ppid int64 `json:"ppid"`
ZoneID int64 `json:"zone_id"`
Status int8 `json:"status"`
}
func (Zone) TableName() string {
return "locality"
}

View File

@@ -0,0 +1,32 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["search.go"],
importpath = "go-common/app/admin/main/videoup/model/search",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/admin/main/videoup/model/manager:go_default_library",
"//app/service/main/account/api: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,172 @@
package search
import (
"go-common/app/admin/main/videoup/model/manager"
account "go-common/app/service/main/account/api"
)
// VideoResultData search video return struct
type VideoResultData struct {
Page struct {
Num int `json:"num"`
Size int `json:"size"`
Total int `json:"total"`
} `json:"page"`
Result []*Video `json:"result"`
}
type ArchiveResultData struct {
Page struct {
Num int `json:"num"`
Size int `json:"size"`
Total int `json:"total"`
} `json:"page"`
Result []*Archive `json:"result"`
Tips string `json:"_tips"`
MoniAids map[int64]int `json:"moni_aids"`
}
// CopyrightResultData search copyright return struct
type CopyrightResultData struct {
Page struct {
Num int `json:"num"`
Size int `json:"size"`
Total int `json:"total"`
} `json:"page"`
Result []*Copyright `json:"result"`
}
// Video search return video item struct
type Video struct {
ID int64 `json:"id"`
Aid int64 `json:"aid"`
Cid int64 `json:"cid"`
Vid int64 `json:"vid"`
ArcTitle string `json:"arc_title"`
ArcState int `json:"arc_state"` //稿件状态。
RelationState int `json:"relation_state"`
State int `json:"state"`
Status int `json:"status"` //视频状态。如果archive_video_relation的state被删除则此Status为-100否则此Status为video表的status
ArcTypeID int64 `json:"arc_typeid"`
ArcMid int64 `json:"arc_mid"`
ArcAuthor string `json:"arc_author"`
ArcSendDate string `json:"arc_senddate"`
Duration int64 `json:"duration"`
Filename string `json:"filename"`
MTime string `json:"mtime"`
TagID int64 `json:"tag_id"`
TagName string `json:"tag_name"`
UserType []int64 `json:"user_type"`
UserGroup []*manager.UpGroup `json:"user_group"`
CTime string `json:"ctime"`
VCTime string `json:"v_ctime"`
VMTime string `json:"v_mtime"`
XcodeState int8 `json:"xcode_state"`
}
type Archive struct {
ID int64 `json:"id"`
Mid int64 `json:"mid"`
Official account.OfficialInfo `json:"official_verify"`
TagNames []string `json:"tid_names"`
Access int16 `json:"access"`
Attribute []int `json:"attribute"`
Attrs []int `json:"attrs"`
State int8 `json:"state"`
Author string `json:"author"`
Cover string `json:"cover"`
CTime string `json:"ctime"`
MTime string `json:"mtime"`
PubDate string `json:"pubtime"`
Copyright int8 `json:"copyright"`
FlowID int64 `json:"flow_id"`
MissionID int64 `json:"mission_id"`
OrderID int64 `json:"order_id"`
Round int `json:"round"`
Title string `json:"title"`
Content string `json:"content"`
TypeID int64 `json:"typeid"`
UpFrom int8 `json:"up_from"`
UserType []int64 `json:"user_type"`
UserGroup []*manager.UpGroup2 `json:"user_group"`
}
// Copyright search return copyright item struct
type Copyright struct {
ID int64 `json:"id"`
Name string `json:"name"`
OName string `json:"oname"`
AkaNames string `json:"aka_names"`
Level string `json:"level"`
Avoid string `json:"avoid"`
Plan string `json:"plan"`
Desc string `json:"description"`
URL string `json:"url"`
}
// VideoParams search video params
type VideoParams struct {
Action string `form:"action"`
Status string `form:"status"`
ArcTitle string `form:"arc_title"`
ArcMids string `form:"arc_mids"`
Order string `form:"order"`
Sort int8 `form:"sort_order"`
Keywords string `form:"keywords"`
Aids string `form:"aids"`
Cids string `form:"cids"`
Vids string `form:"vids"`
TypeID string `form:"typeid"`
Filename string `form:"filename"`
TagID string `form:"tag_id"`
Pn int `form:"pn"`
Ps int `form:"ps"`
Xcode string `form:"xcode_state"`
UserType string `form:"user_type"`
OrderType string `form:"order_type"`
DurationFrom string `form:"duration_from"`
DurationTo string `form:"duration_to"`
MonitorList string `form:"monitor_list"`
}
// ArchiveParams search archive params
type ArchiveParams struct {
TypeID string `form:"typeid"`
SpecialType string `form:"special_arctype"`
Round string `form:"round"`
Aids string `form:"aids"`
Mids string `form:"mids"`
Pn int `form:"page"`
Ps int `form:"pagesize"`
OrderType string `form:"order_type"`
Keywords string `form:"keywords"`
KwFields string `form:"kw_fields"`
IsFirst string `form:"is_first"`
IsOrder int8 `form:"execute_order"`
State string `form:"state"`
Access string `form:"access"`
UpFroms string `form:"up_froms"`
PGCList string `form:"pgc_list"`
OrderId string `form:"order_id"`
Attr string `form:"attribute"`
//ChannelReview string `form:"channel_review"`
//HotReview string `form:"hot_review"`
Review string `form:"review"`
ReviewState string `form:"review_state"`
MissionID string `form:"mission_id"`
NoMission string `form:"no_mission"`
UserType string `form:"user_type"`
Copyright string `form:"copyright"`
Order string `form:"order"`
ScoreFirst string `form:"score_first"` //是否按关键字匹配优先
Sort string `form:"sort_order"`
MonitorList string `form:"monitor_list"`
}
// ArcPGCConfig
type ArcPGCConfig struct {
UPFrom []int8
Rounds []int8
States []int8
InState bool
Auth string
}

View File

@@ -0,0 +1,32 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["track.go"],
importpath = "go-common/app/admin/main/videoup/model/track",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/admin/main/videoup/model/archive: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"],
)

View File

@@ -0,0 +1,46 @@
package track
import (
"go-common/app/admin/main/videoup/model/archive"
"go-common/library/time"
)
const ()
var ()
type Archive struct {
// common values
Timestamp time.Time `json:"timestamp"`
// archive stat
State int `json:"state"`
Round int `json:"round"`
// AID int64 `json:"aid,omitempty"`
Remark string `json:"remark,omitempty"`
Attribute int32 `json:"attribute"`
}
type Video struct {
// common values
Timestamp time.Time `json:"timestamp"`
XCodeState int8 `json:"xcode_state"`
// video status
Status int16 `json:"status"`
AID int64 `json:"aid,omitempty"`
Remark string `json:"remark,omitempty"`
Attribute int32 `json:"attribute"`
}
// Archives Archive sorted.
type Archives []*Archive
func (a Archives) Len() int { return len(a) }
func (a Archives) Less(i, j int) bool { return int64(a[i].Timestamp) > int64(a[j].Timestamp) }
func (a Archives) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
//ArcTrackInfo 稿件追踪信息
type ArcTrackInfo struct {
EditHistory []*archive.EditHistory `json:"edit_history"`
Track []*Archive `json:"track"`
Relation [][]int `json:"relation"`
}

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 = ["credit.go"],
importpath = "go-common/app/admin/main/videoup/model/up",
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,20 @@
package up
// .
const (
CreditBusinessTypeArchive = int8(1)
)
//CreditLog .
type CreditLog struct {
Type int8 `json:"type"`
Optyte int8 `json:"optype"`
Reason int64 `json:"reason"`
BusinessType int8 `json:"business_type"`
MID int64 `json:"mid"`
OID int64 `json:"oid"`
UID int64 `json:"uid"`
Content string `json:"content"`
Ctime int64 `json:"ctime"`
Extra interface{}
}

View File

@@ -0,0 +1,37 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library(
name = "go_default_library",
srcs = ["time.go"],
importpath = "go-common/app/admin/main/videoup/model/utils",
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"],
)
go_test(
name = "go_default_test",
srcs = ["time_test.go"],
embed = [":go_default_library"],
rundir = ".",
tags = ["automanaged"],
)

View File

@@ -0,0 +1,58 @@
package utils
import (
"database/sql/driver"
"time"
)
// FormatTime format time
type FormatTime string
// NewFormatTime net formatTime
func NewFormatTime(t time.Time) FormatTime {
ft := new(FormatTime)
ft.Scan(t)
return *ft
}
// Scan scan time.
func (jt *FormatTime) Scan(src interface{}) (err error) {
switch sc := src.(type) {
case time.Time:
*jt = FormatTime(sc.Format("2006-01-02 15:04:05"))
case string:
*jt = FormatTime(sc)
}
return
}
// Value get string value.
func (jt FormatTime) Value() (driver.Value, error) {
return string(jt), nil
}
// TimeValue get time value.
func (jt FormatTime) TimeValue() time.Time {
t, _ := time.ParseInLocation("2006-01-02 15:04:05", string(jt), time.Local)
if t.Unix() <= 0 {
t, _ = time.ParseInLocation("2006-01-02 15:04:05", "0000-00-00 00:00:00", time.Local)
}
return t
}
// UnmarshalJSON implement Unmarshaler
func (jt *FormatTime) UnmarshalJSON(data []byte) error {
if data == nil || len(data) <= 1 {
*jt = FormatTime("0000-00-00 00:00:00")
return nil
}
str := string(data[1 : len(data)-1])
st, err := time.Parse(time.RFC3339, str)
if err == nil {
*jt = FormatTime(st.Format("2006-01-02 15:04:05"))
} else {
*jt = FormatTime(str)
}
return nil
}

View File

@@ -0,0 +1,55 @@
package utils
import (
"encoding/json"
"fmt"
"testing"
"time"
)
func Test_format(t *testing.T) {
type A struct {
Ct FormatTime `json:"ct"`
}
a := &A{Ct: ""}
if !a.Ct.TimeValue().IsZero() {
t.Fatal("1")
}
a = &A{Ct: "0000-00-00 00:00:00"}
fmt.Println("ct:", a.Ct)
fmt.Println("value:", a.Ct.TimeValue())
fmt.Println("zero:", a.Ct.TimeValue().IsZero())
if !a.Ct.TimeValue().IsZero() {
t.Fatal("2")
}
a = &A{Ct: "0001-01-01 00:00:00"}
fmt.Println("ct:", a.Ct)
fmt.Println("value:", a.Ct.TimeValue())
fmt.Println("zero:", a.Ct.TimeValue().IsZero())
if !a.Ct.TimeValue().IsZero() {
t.Fatal("3")
}
Tt, _ := time.ParseInLocation("2006-01-02 15:04:05", "2018-06-01 22:59:16", time.Local)
a = &A{}
J := `{"ct":"2018-06-01 22:59:16"}`
err := json.Unmarshal([]byte(J), a)
if err != nil || string(a.Ct) != "2018-06-01 22:59:16" || a.Ct.TimeValue() != Tt {
t.Fatal("4")
}
fmt.Println("ct:", a.Ct)
fmt.Println("value:", a.Ct.TimeValue())
fmt.Println("zero:", a.Ct.TimeValue().IsZero())
J = `{"ct":"2018-06-01T22:59:16.437367789+08:00"}`
err = json.Unmarshal([]byte(J), a)
if err != nil || string(a.Ct) != "2018-06-01 22:59:16" || a.Ct.TimeValue() != Tt {
t.Fatal("5")
}
fmt.Println("ct:", a.Ct)
fmt.Println("value:", a.Ct.TimeValue())
fmt.Println("zero:", a.Ct.TimeValue().IsZero())
}