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,43 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"archive.go",
"biz.go",
"desc.go",
"history.go",
"poi.go",
"type.go",
"view.go",
"viewpoint.go",
"whitelist.go",
],
importpath = "go-common/app/interface/main/creative/model/archive",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/archive/api:go_default_library",
"//app/service/main/archive/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,231 @@
package archive
import (
"go-common/app/service/main/archive/api"
a "go-common/app/service/main/archive/model/archive"
"go-common/library/time"
)
var (
// VjInfo 审核当前拥挤状态的数据映射
VjInfo = map[int8]*VideoJam{
0: {
Level: 0,
State: "状态正在计算中",
Comment: "状态正在计算中",
},
1: {
Level: 1,
State: "畅通",
Comment: "预计稿件过审时间小于20分钟剧集、活动投稿除外",
},
2: {
Level: 2,
State: "繁忙",
Comment: "预计稿件过审时间小于40分钟剧集、活动投稿除外",
},
3: {
Level: 3,
State: "拥挤",
Comment: "预计稿件过审时间小于60分钟剧集、活动投稿除外",
},
4: {
Level: 4,
State: "爆满",
Comment: "预计稿件过审时间小于120分钟剧集、活动投稿除外",
},
5: {
Level: 5,
State: "阻塞",
Comment: "预计稿件过审时间大于120分钟剧集、活动投稿除外",
},
}
)
const (
// CopyrightOrigin 自制
CopyrightOrigin = int64(1)
// CopyrightReprint 转载
CopyrightReprint = int64(2)
// TagPredictFromWeb web tag推荐
TagPredictFromWeb = int8(0)
// TagPredictFromAPP app tag推荐
TagPredictFromAPP = int8(1)
// TagPredictFromWindows windows tag推荐
TagPredictFromWindows = int8(2)
)
// Const State
const (
// 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
AttrBitIsCoop = uint(24) //联合投稿
)
// OldArchiveVideoAudit archive with audit.
// NOTE: old struct, will delete!!!
type OldArchiveVideoAudit struct {
*api.Arc
RejectReson string `json:"reject,omitempty"`
Dtime time.Time `json:"dtime,omitempty"`
VideoAudits []*OldVideoAudit `json:"video_audit,omitempty"`
StateDesc string `json:"state_desc"`
StatePanel int `json:"state_panel"`
ParentTName string `json:"parent_tname"`
Attrs *Attrs `json:"attrs"`
UgcPay int8 `json:"ugcpay"`
}
// OldVideoAudit video audit.
// NOTE: old struct, will delete!!!
type OldVideoAudit struct {
Reason string `json:"reason,omitempty"`
Eptitle string `json:"eptitle,omitempty"`
IndexOrder int `json:"index_order"`
}
// ArcVideoAudit archive video audit.
type ArcVideoAudit struct {
*ArcVideo
Stat *api.Stat `json:"stat"`
StatePanel int `json:"state_panel"`
ParentTName string `json:"parent_tname"`
TypeName string `json:"typename"`
OpenAppeal int64 `json:"open_appeal"`
}
// Flow type
type Flow struct {
ID uint `json:"id"`
Remark string `json:"remark"`
}
// Porder type
type Porder struct {
ID int64 `json:"id"`
AID int64 `json:"aid"`
IndustryID int64 `json:"industry_id"`
BrandID int64 `json:"brand_id"`
BrandName string `json:"brand_name"`
Official int8 `json:"is_official"`
ShowType string `json:"show_type"`
Advertiser string `json:"advertiser"`
Agent string `json:"agent"`
Ctime time.Time `json:"ctime,omitempty"`
Mtime time.Time `json:"mtime,omitempty"`
}
// Staff type
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"`
}
// StaffApply type
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"`
StaffState int8 `json:"staff_state"`
StaffTitle string `json:"staff_title"`
}
// Commercial type
type Commercial struct {
AID int64 `json:"aid"`
POrderID int64 `json:"porder_id"` // 私
OrderID int64 `json:"order_id"` // 商
GameID int64 `json:"game_id"`
//IndustryID int64 `json:"industry_id"` // open after mall
//BrandID int64 `json:"brand_id"`
}
// InMovieType judge type for pubdate
func InMovieType(tid int16) bool {
return tid == 83 || tid == 145 || tid == 146 || tid == 147
}
// StatePanel judge archive state for app panel.
func StatePanel(s int8) (st int) {
if s == a.StateForbidWait ||
s == a.StateForbidFixed ||
s == a.StateForbidLater ||
s == a.StateForbidAdminDelay ||
s == a.StateForbidSubmit ||
s == a.StateForbidUserDelay {
st = 1 //处理中
} else if s == a.StateForbidRecicle {
st = 2 //退回可编辑
} else if s == a.StateForbidPolice || s == a.StateForbidLock {
st = 3 //退回全部不可编辑
} else if s == a.StateForbidXcodeFail {
st = 4 //退回分区不可编辑
} else {
st = 0 //正常开放
}
return
}
// IsCloseState judge arc state.
func IsCloseState(s int) bool {
return s == -2 || s == -4 || s == -5 || s == -14
}
// ShortDesc cut down to short desc for adapter app and windows clients
func ShortDesc(desc string) string {
rs := []rune(desc)
length := len(rs)
max := 250
if length < max {
max = length
}
return string(rs[:max])
}
// AttrVal get attribute.
func (a *ArcVideoAudit) AttrVal(bit uint) int32 {
return (a.Archive.Attribute >> bit) & int32(1)
}
// IsOwner fn
func (a *ArcVideoAudit) IsOwner(mid int64) int8 {
if a.Archive.Mid == mid {
return 1
}
return 0
}

View File

@@ -0,0 +1,19 @@
package archive
import "go-common/library/time"
// VoteType 投票业务
const VoteType int8 = 2
// BIZ business
type BIZ struct {
ID int64 `json:"id"`
Type int32 `json:"type"`
Aid int64 `json:"aid"`
Uid int64 `json:"uid"`
State int8 `json:"state"`
Remark string `json:"remark"`
Data string `json:"data"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}

View File

@@ -0,0 +1,33 @@
package archive
// DescFormat is archive type.
type DescFormat struct {
ID int64 `json:"id"`
Copyright int8 `json:"copyright"`
TypeID int64 `json:"typeid"`
Components string `json:"components"`
Lang int8 `json:"lang"`
}
// AppFormat app format.
type AppFormat struct {
ID int64 `json:"id"`
Copyright int8 `json:"copyright"`
TypeID int64 `json:"typeid"`
}
//ToLang str to int8.
func ToLang(langStr string) (lang int8) {
if langStr == "" {
langStr = "ch"
}
switch langStr {
case "ch":
lang = 0
case "en":
lang = 1
case "jp":
lang = 2
}
return
}

View File

@@ -0,0 +1,18 @@
package archive
import (
"go-common/library/time"
)
// ArcHistory archive of history
type ArcHistory struct {
ID int64 `json:"id,omitempty"`
Aid int64 `json:"aid,omitempty"`
Mid int64 `json:"mid,omitempty"`
Tag string `json:"tag,omitempty"`
Title string `json:"title,omitempty"`
Content string `json:"content,omitempty"`
Cover string `json:"cover,omitempty"`
CTime time.Time `json:"ctime,omitempty"`
Video []*Video `json:"videos,omitempty"`
}

View File

@@ -0,0 +1,56 @@
package archive
// 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"`
}
// NeedPoi fn
func NeedPoi(s string) (needPOI int) {
if (s == PlatformAndroid) ||
(s == PlatformIOS) ||
(s == PlatformH5) {
needPOI = 1
}
return
}
// NeedVote fn
func NeedVote(s string) (needVote int) {
if (s == PlatformAndroid) ||
(s == PlatformIOS) ||
(s == PlatformWeb) ||
(s == PlatformH5) {
needVote = 1
}
return
}

View File

@@ -0,0 +1,116 @@
package archive
import (
"sort"
)
// RulesForApp var
var RulesForApp = map[int16]int16{
160: 1, // 生活
4: 2, // 游戏
129: 3, // 舞蹈
3: 4, // 音乐
155: 5, // 时尚
5: 6, // 娱乐
36: 7, // 科技
188: 8, // 数码
1: 9, // 动画
181: 10, // 影视
119: 11, // 鬼畜
167: 12, // 国创
165: 13, // 广告
177: 14, // 纪录片
11: 15, // 电视剧
13: 16, // 番剧
23: 17, // 电影
}
// RulesForWeb var
var RulesForWeb = map[int16]int16{
4: 1, // 游戏
160: 2, // 生活
5: 3, // 娱乐
181: 4, // 影视
3: 5, // 音乐
36: 6, // 科技
188: 7, // 数码
1: 8, // 动画
155: 9, // 时尚
129: 10, // 舞蹈
13: 11, // 番剧
177: 12, // 纪录片
119: 13, // 鬼畜
165: 14, // 广告
167: 15, // 国创
11: 16, // 电视剧
23: 17, // 电影
}
// const client type values
const (
WebType = int8(1)
AppType = int8(2)
)
// Type is archive type.
type Type struct {
ID int16 `json:"id"`
Lang string `json:"-"`
Parent int16 `json:"parent"`
Name string `json:"name"`
Desc string `json:"description"`
Descapp string `json:"desc"`
Count int64 `json:"-"` // top type count
Original string `json:"intro_original"` // second type original
IntroCopy string `json:"intro_copy"` // second type copy
Notice string `json:"notice"` // second type notice
AppNotice string `json:"-"` // app notice
CopyRight int8 `json:"copy_right"`
Show bool `json:"show"`
Rank int16 `json:"-"`
Children []*Type `json:"children,omitempty"`
}
// ForbidSubTypesForAppAdd fn
// 不允许投稿的分区: 连载剧集->15,完结剧集->34,电视剧相关->128,电影相关->82
// 原不能投多P的分区创作姬统一不允许投稿: 欧美电影->145,日本电影->146,国产电影->147,其他国家->83
func ForbidSubTypesForAppAdd(tid int16) bool {
return tid == 15 || tid == 34 || tid == 128 || tid == 82 || tid == 145 || tid == 146 || tid == 147 || tid == 83
}
// ForbidTopTypesForAll fn 175=>ASMR
func ForbidTopTypesForAll(tid int16) bool {
return tid == 175
}
// ForbidTopTypesForAppAdd fn
// 不允许APP投稿顶级分区: 纪录片->177,电视剧->11,番剧->13
func ForbidTopTypesForAppAdd(tid int16) bool {
return tid == 177 || tid == 11 || tid == 13
}
// CopyrightForCreatorAdd fn 0,不限制1,只允许自制2,只允许转载
// 音乐-OP/ED/OST 54 番剧-完结动画 32 番剧-连载动画 33 番剧-资讯 51 电影-其他国家 83 电影-欧美电影 145 电影-日本电影 146 电影-国产电影 147 纪录片-人文历史 37
func CopyrightForCreatorAdd(tid int16) bool {
return tid == 54 || tid == 32 || tid == 33 || tid == 51 || tid == 83 || tid == 145 || tid == 146 || tid == 147 || tid == 37
}
// SortRulesForTopTypes fn
func SortRulesForTopTypes(types []*Type, clientType int8) {
var rules map[int16]int16
if clientType == WebType {
rules = RulesForWeb
} else if clientType == AppType {
rules = RulesForApp
}
for _, t := range types {
if rank, ok := rules[t.ID]; ok {
t.Rank = rank
} else {
t.Rank = 32767
}
}
sort.Slice(types, func(i, j int) bool {
return types[i].Rank < types[j].Rank
})
}

View File

@@ -0,0 +1,237 @@
package archive
import (
"go-common/library/time"
)
//Platform const
const (
PlatformWeb = "web"
PlatformWindows = "windows"
PlatformH5 = "h5"
PlatformAndroid = "android"
PlatformIOS = "ios"
)
// 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:"author"`
Cover string `json:"cover"`
RejectReason string `json:"reject_reason"`
Tag string `json:"tag"`
Duration int64 `json:"duration"`
Copyright int8 `json:"copyright"`
NoReprint int8 `json:"no_reprint"`
UgcPay int8 `json:"ugcpay"`
OrderID int64 `json:"order_id"`
OrderName string `json:"order_name"`
Desc string `json:"desc"`
MissionID int64 `json:"mission_id"`
MissionName string `json:"mission_name"`
Round int8 `json:"-"`
Forward int64 `json:"-"`
Attribute int32 `json:"attribute"`
Access int16 `json:"-"`
State int8 `json:"state"`
StateDesc string `json:"state_desc"`
StatePanel int `json:"state_panel"`
Source string `json:"source"`
DescFormatID int64 `json:"desc_format_id"`
Attrs *Attrs `json:"attrs"`
// feature: private orders
Porder *ArcPorder `json:"porder"`
Dynamic string `json:"dynamic"`
PoiObj *PoiObj `json:"poi_object"`
// time
DTime time.Time `json:"dtime"`
PTime time.Time `json:"ptime"`
CTime time.Time `json:"ctime"`
MTime time.Time `json:"-"`
UgcPayInfo *UgcPayInfo `json:"ugcpay_info"`
Staffs []*StaffView `json:"staffs"`
Vote *Vote `json:"vote"`
}
// Attrs str
type Attrs struct {
IsCoop int8 `json:"is_coop"`
IsOwner int8 `json:"is_owner"`
}
// Vote str
type Vote struct {
VoteID int64 `json:"vote_id"`
VoteTitle string `json:"vote_title"`
}
// PayAct str
type PayAct struct {
Reason string `json:"reason"`
State int8 `json:"state"`
}
// PayAsset str
type PayAsset struct {
Price int `json:"price"`
PlatformPrice map[string]int `json:"platform_price"`
}
// UgcPayInfo str
type UgcPayInfo struct {
Acts map[string]*PayAct `json:"acts"`
Asset *PayAsset `json:"asset"`
}
// NilPoiObj fn 防止非APP端的地理位置信息泄露
func (arc *Archive) NilPoiObj(platform string) {
if (platform != PlatformAndroid) &&
(platform != PlatformIOS) &&
(platform != PlatformH5) {
arc.PoiObj = nil
}
}
// NilVote fn
func (arc *Archive) NilVote() {
if arc.Vote != nil && arc.Vote.VoteID == 0 {
arc.Vote = nil
}
}
// ArcPorder str
type ArcPorder struct {
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"`
}
// Video is videos 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:"duration"`
Filesize int64 `json:"-"`
Resolutions string `json:"-"`
Index int `json:"index"`
Playurl string `json:"-"`
Status int16 `json:"status"`
StatusDesc string `json:"status_desc"`
RejectReason string `json:"reject_reason"`
FailCode int8 `json:"fail_code"`
FailDesc string `json:"fail_desc"`
XcodeState int8 `json:"-"`
Attribute int32 `json:"-"`
CTime time.Time `json:"ctime"`
MTime time.Time `json:"-"`
}
// ArcVideo str
type ArcVideo struct {
Archive *Archive
Videos []*Video
}
// StaffView Archive staff
type StaffView struct {
ID int64 `json:"id"`
ApMID int64 `json:"apply_staff_mid"`
ApName string `json:"apply_staff_name"`
ApTitle string `json:"apply_title"`
ApAID int64 `json:"apply_aid"`
ApType int `json:"apply_type"`
ApState int `json:"apply_state"`
ApStaffID int64 `json:"apply_asid"` //Staff表的主键ID
StaffState int `json:"staff_state"`
StaffTitle string `json:"staff_title"`
}
// ViewBGM bgm view
type ViewBGM struct {
SID int64 `json:"sid"`
MID int64 `json:"mid"`
Title string `json:"title"`
Author string `json:"author"`
JumpURL string `json:"jump_url"`
}
// Vcover muti cover for video.
type Vcover struct {
Filename string `json:"filename"`
BFSPath string `json:"bfs_path"`
}
// SimpleArchive is simple model for videos
type SimpleArchive struct {
Aid int64 `json:"aid"`
Title string `json:"title"`
}
// SimpleVideo is simple model for videos
type SimpleVideo struct {
Cid int64 `json:"cid"`
Index int `json:"index"`
Title string `json:"title"`
}
// RecoArch is simple archive information for recommend
type RecoArch struct {
Aid int64 `json:"aid"`
Title string `json:"title"`
Owner string `json:"owner"`
}
// SpVideo is a simple model with danmu status
type SpVideo struct {
Cid int64 `json:"cid"`
Index int `json:"part_id"`
Title string `json:"part_name"`
Status int16 `json:"status"`
DmActive int `json:"dm_active"`
DmModified time.Time `json:"dm_modified"`
}
// SpArchive str
type SpArchive struct {
Aid int64 `json:"aid"`
Title string `json:"title"`
Mid int64 `json:"mid,omitempty"`
}
// SimpleArchiveVideos str
type SimpleArchiveVideos struct {
Archive *SpArchive `json:"archive"`
SpVideos []*SpVideo `json:"part_list"`
AcceptAss bool `json:"accept_ass"`
}
// VideoJam is video traffic jam info for frontend
type VideoJam struct {
Level int8 `json:"level"`
State string `json:"state"`
Comment string `json:"comment"`
}
// Dpub str
type Dpub struct {
Deftime time.Time `json:"deftime"`
DeftimeEnd time.Time `json:"deftime_end"`
DeftimeMsg string `json:"deftime_msg"`
}

View File

@@ -0,0 +1,21 @@
package archive
// ViewPointRow video highlight viewpoint
type ViewPointRow struct {
ID int64 `json:"id"`
AID int64 `json:"aid"`
CID int64 `json:"cid"`
Points []*ViewPoint `json:"points"`
State int32 `json:"state"`
CTime string `json:"ctime"`
MTime string `json:"mtime"`
}
// ViewPoint viewpoint struct
type ViewPoint struct {
Type int8 `json:"type"`
From int `json:"from"`
To int `json:"to"`
Content string `json:"content"`
State int8 `json:"state"`
}

View File

@@ -0,0 +1,7 @@
package archive
// WhiteList str
type WhiteList struct {
Mid int64 `json:"mid"`
Tp int `json:"type"`
}