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,54 @@
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"archive.go",
"audit_result.go",
"channel.go",
"content_repo.go",
"full.go",
"intervs.go",
"label.go",
"modules.go",
"order.go",
"panel.go",
"region.go",
"sear_inter.go",
"season_repo.go",
"tv_content.go",
"uplayurl.go",
"upper.go",
"user.go",
"version_update.go",
"video.go",
"water_mark.go",
],
importpath = "go-common/app/admin/main/tv/model",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/archive/api:go_default_library",
"//library/database/elastic:go_default_library",
"//library/time:go_default_library",
"//vendor/github.com/jinzhu/gorm:go_default_library",
"//vendor/github.com/siddontang/go-mysql/mysql: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,159 @@
package model
import (
"go-common/library/time"
"github.com/siddontang/go-mysql/mysql"
)
// SimpleArc is the simple struct of archive
type SimpleArc struct {
ID int `gorm:"column:id"`
AID int64 `gorm:"column:aid"`
MID int `gorm:"column:mid"`
TypeID int32 `gorm:"column:typeid"`
Title string
Content string
Cover string
Deleted int
Result int
Valid int
Mtime time.Time
Pubtime time.Time
}
// Archive archive def. corresponding to our table structure
type Archive struct {
ID int `gorm:"column:id" json:"id"`
AID int64 `gorm:"column:aid" json:"aid"`
MID int `gorm:"column:mid" json:"mid"`
TypeID int32 `gorm:"column:typeid" json:"typeid"`
Videos int `gorm:"column:videos" json:"videos"`
Title string `gorm:"column:title" json:"title"`
Cover string `gorm:"column:cover" json:"cover"`
Content string `gorm:"column:content" json:"content"`
Duration int `gorm:"column:duration" json:"duration"`
Copyright int `gorm:"column:copyright" json:"copyright"`
Pubtime time.Time `gorm:"column:pubtime" json:"pubtime"`
InjectTime time.Time `gorm:"column:inject_time" json:"inject_time"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"mtime"`
State int `gorm:"column:state" json:"state"`
Manual int `gorm:"column:manual" json:"manual"`
Valid uint8 `gorm:"column:valid" json:"valid"`
Submit uint8 `gorm:"column:submit" json:"submit"`
Retry int `gorm:"column:retry" json:"retry"`
Result uint8 `gorm:"column:result" json:"result"`
Deleted uint8 `gorm:"column:deleted" json:"deleted"`
Reason string `gorm:"column:reason" json:"reason"`
}
// ArcPager is the result and page of archive query.
type ArcPager struct {
Items []*ArcList `json:"items"`
Page *Page `json:"page"`
}
// ArcListParam is archive list request params
type ArcListParam struct {
ID string `form:"id" json:"id"`
Title string `form:"title" json:"title"`
CID string `form:"cid" json:"cid"`
Typeid int32 `form:"typeid" json:"typeid"`
Valid string `form:"valid" json:"valid"`
Pid int32 `form:"pid" json:"-"`
Order int `form:"order" json:"order" default:"2"`
Mid int64 `form:"mid" json:"mid"`
UpName string `form:"up_name"`
PageCfg
}
// AddResp is for the response for adding archives/uppers
type AddResp struct {
Succ []int64 `json:"succ"` // successfully added ids
Exist []int64 `json:"exist"` // the ids already exist in our DB
Invalids []int64 `json:"invalids"` // the invalid ids ( not exist in archives/uppers )
}
// ArcType arctype
type ArcType struct {
ID int16 `json:"id"`
Pid int16 `json:"pid"`
Name string `json:"name"`
}
// ArcDB is the archive query result
type ArcDB struct {
ArcCore
Pubdate time.Time `gorm:"column:pubtime"`
}
// ArcCore is the archive core struct
type ArcCore struct {
ID string `json:"id"`
CID string `json:"cid" gorm:"column:aid"`
TypeID int32 `json:"typeid" gorm:"column:typeid"`
Title string `json:"title"`
Valid string `json:"valid" gorm:"column:valid"`
Mtime time.Time `json:"mtime"`
Content string `json:"content"`
Cover string `json:"cover"`
MID int64 `json:"mid" gorm:"column:mid"`
}
// ArcList def.
type ArcList struct {
ArcCore
PTypeID int32 `json:"parent_typeid"`
Pubdate string `json:"pubdate"`
UpName string `json:"up_name"`
}
// ToList def.
func (v *ArcDB) ToList(pid int32) (res *ArcList) {
return &ArcList{
ArcCore: v.ArcCore,
PTypeID: pid,
Pubdate: v.Pubdate.Time().Format(mysql.TimeFormat),
}
}
// UgcType ugc archive category typelist
type UgcType struct {
ID int32 `json:"id"`
Name string `json:"name"`
Children []UgcCType `json:"children"`
}
// UgcCType ugc archive children category type
type UgcCType struct {
Pid int32 `json:"pid"`
ID int32 `json:"id"`
Name string `json:"name"`
}
// Category is for getting pid and name from archive category
type Category struct {
Pid, Name string
}
// AvailTps structure in memory
type AvailTps struct {
PassedTps []UgcType
AllTps []UgcType
}
// TableName ugc_archive
func (v ArcDB) TableName() string {
return "ugc_archive"
}
// TableName ugc_archive
func (a SimpleArc) TableName() string {
return "ugc_archive"
}
// TableName ugc_archive
func (a Archive) TableName() string {
return "ugc_archive"
}

View File

@@ -0,0 +1,294 @@
package model
import (
"fmt"
"strconv"
"go-common/library/database/elastic"
"go-common/library/time"
)
const (
_TimeFormat = ("2006-01-02 15:04:05")
_mtimeDesc = "2"
_pubtimeDesc = "1"
_pagesize = 20
)
// EPRes def.
type EPRes struct {
ID int64 `json:"id"`
Title string `json:"title"`
Subtitle string `json:"subtitle"`
STitle string `json:"season_title" gorm:"column:stitle"`
Category int `json:"category"`
SeasonID int `json:"season_id"`
EPID int `json:"epid" gorm:"column:epid"`
State int `json:"state"`
Valid int `json:"valid"`
Reason string `json:"reason"`
}
// EPResDB defines the result structure of ep audit
type EPResDB struct {
EPRes
InjectTime time.Time `json:"inject_time" gorm:"column:inject_time"`
CTime time.Time `json:"ctime" gorm:"column:ctime"`
}
// EPResItem def.
type EPResItem struct {
EPRes
InjectTime string `json:"inject_time"`
CTime string `json:"ctime"`
}
// ToItem def.
func (v *EPResDB) ToItem() *EPResItem {
res := &EPResItem{
EPRes: v.EPRes,
CTime: v.CTime.Time().Format(_TimeFormat),
}
switch v.State {
case 3: // passed
res.State = 1
case 4: // rejected
res.State = 2
default:
res.State = 0
}
if v.InjectTime > 0 {
res.InjectTime = v.InjectTime.Time().Format(_TimeFormat)
}
return res
}
// Page represents the standard page structure
type Page struct {
Num int `json:"num"`
Size int `json:"size"`
Total int `json:"total"`
}
// SnCount def.
type SnCount struct {
Count int
}
// TableName tv_content
func (*EPResDB) TableName() string {
return "tv_content"
}
// EPResultPager def.
type EPResultPager struct {
Items []*EPResItem `json:"items"`
Page *Page `json:"page"`
}
// SeasonRes def.
type SeasonRes struct {
ID int64 `json:"id"`
Title string `json:"title"`
Check int `json:"check"`
Category int `json:"category"`
Valid int `json:"valid"`
Reason string `json:"reason"`
}
// SeasonResDB defines the result structure of ep audit
type SeasonResDB struct {
SeasonRes
InjectTime time.Time `json:"inject_time" gorm:"column:inject_time"`
CTime time.Time `json:"ctime" gorm:"column:ctime"`
}
// SeasonResItem def.
type SeasonResItem struct {
SeasonRes
InjectTime string `json:"inject_time"`
CTime string `json:"ctime"`
}
// ToItem Transforms to item
func (v *SeasonResDB) ToItem() *SeasonResItem {
res := &SeasonResItem{
CTime: v.CTime.Time().Format(_TimeFormat),
SeasonRes: v.SeasonRes,
}
switch v.Check {
case 0: // reject
res.Check = 2
case 1: // passed
res.Check = 1
default:
res.Check = 0
}
if v.InjectTime > 0 {
res.InjectTime = v.InjectTime.Time().Format(_TimeFormat)
}
return res
}
// TableName tv_content
func (*SeasonResDB) TableName() string {
return "tv_ep_season"
}
// SeasonResultPager def.
type SeasonResultPager struct {
Items []*SeasonResItem `json:"items"`
Page *Page `json:"page"`
}
// ReqArcCons def.
type ReqArcCons struct {
Order int `form:"order" json:"order;Min(1)" default:"1"` // 1 default, desc; 2 asc
FirstCat int32 `form:"first_cat"`
SecondCat int32 `form:"second_cat"`
Status string `form:"status"`
Title string `form:"title"`
AVID int64 `form:"avid"`
Pn int `form:"pn" default:"1"`
}
// ReqVideoCons def.
type ReqVideoCons struct {
AVID int64 `form:"avid" validate:"required"`
Order int `form:"order" json:"order;Min(1)" default:"1"` // 1 default, desc; 2 asc
Title string `form:"title"`
CID int64 `form:"cid"`
Status string `form:"status"`
Pn int `form:"pn"`
}
// PageCfg def.
type PageCfg struct {
Pn int `form:"pn" default:"1" json:"pn"`
Ps int `form:"ps" default:"20" json:"ps"`
}
// ReqArcES def.
type ReqArcES struct {
AID string
Mids []int64
Title string
Typeids []int32
Valid string
Result string
MtimeOrder string
PubtimeOrder string
PageCfg
}
// MtimeSort def.
func (v *ReqArcES) MtimeSort() string {
if v.MtimeOrder == _mtimeDesc {
return elastic.OrderDesc
}
return elastic.OrderAsc
}
// PubtimeSort def.
func (v *ReqArcES) PubtimeSort() string {
if v.PubtimeOrder == _pubtimeDesc {
return elastic.OrderDesc
}
return elastic.OrderAsc
}
// FromArcListParam build
func (v *ReqArcES) FromArcListParam(param *ArcListParam, tids []int32) {
v.Title = param.Title
v.Valid = param.Valid
v.MtimeOrder = strconv.Itoa(param.Order)
v.PageCfg = param.PageCfg
v.AID = param.CID
v.Typeids = tids
v.Result = "1"
}
// FromAuditConsult def.
func (v *ReqArcES) FromAuditConsult(param *ReqArcCons, tids []int32) {
v.PubtimeOrder = strconv.Itoa(param.Order)
v.Typeids = tids
v.Result = param.Status
v.Title = param.Title
if param.AVID != 0 {
v.AID = fmt.Sprintf("%d", param.AVID)
}
v.Pn = param.Pn
v.Ps = _pagesize
}
// ArcRes def.
type ArcRes struct {
AVID int64 `json:"avid"`
Title string `json:"title"`
FirstCat string `json:"first_cat"`
SecondCat string `json:"second_cat"`
Status int `json:"status"`
InjectTime string `json:"inject_time"`
PubTime string `json:"pubtime"`
Reason string `json:"reason"`
}
// VideoRes def.
type VideoRes struct {
CID int64 `json:"cid"`
Title string `json:"title"`
Page int `json:"page"`
Status int `json:"status"`
Ctime string `json:"ctime"`
InjectTime string `json:"inject_time"`
Reason string `json:"reason"`
}
// ArcResPager def.
type ArcResPager struct {
Items []*ArcRes `json:"items"`
Page *Page `json:"page"`
}
// VideoResPager def.
type VideoResPager struct {
Items []*VideoRes `json:"items"`
Page *Page `json:"page"`
}
// EsUgcConsult def.
type EsUgcConsult struct {
Fields []string `json:"fields"`
From string `json:"from"`
Highlight bool `json:"highlight"`
Pn int `json:"pn"`
Ps int `json:"ps"`
Where *Where `json:"where,omitempty"`
Order []map[string]string `json:"order"`
}
// Where def.
type Where struct {
Eq map[string]string `json:"eq,omitempty"`
Or map[string][]interface{} `json:"or,omitempty"`
In map[string][]int32 `json:"in,omitempty"`
Range map[string]string `json:"range,omitempty"`
}
// EsArc def.
type EsArc struct {
AID int64 `json:"aid"`
MID int64 `json:"mid"`
Deleted int `json:"deleted"`
Mtime string `json:"mtime"`
Pubtime string `json:"pubtime"`
Result int `json:"result"`
Typeid int32 `json:"typeid"`
Valid int `json:"valid"`
}
// EsUgcResult def.
type EsUgcResult struct {
Result []*EsArc
Page *Page
}

View File

@@ -0,0 +1,52 @@
package model
import "go-common/library/time"
// Channel represents the table TV_RANK
type Channel struct {
ID int64 `json:"id"`
Title string `json:"title"`
Desc string `json:"desc"`
Splash string `json:"splash"`
Deleted int8 `json:"deleted"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime_nb"`
}
// ChannelFmt , mtimeFormat transforms the mtime timestamp
type ChannelFmt struct {
ID int64 `json:"id"`
Title string `json:"title"`
Desc string `json:"desc"`
Splash string `json:"splash"`
Deleted int8 `json:"deleted"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime_nb,omitempty"`
MtimeFormat string `json:"mtime"`
}
//ChannelPager def.
type ChannelPager struct {
TotalCount int64 `json:"total_count"`
Pn int `json:"pn"`
Ps int `json:"ps"`
Items []*ChannelFmt `json:"items"`
}
// ReqChannel def.
type ReqChannel struct {
Page int `form:"page" default:"1"`
Order int `form:"order" default:"1"` // 1=desc,2=asc
Title string `form:"title"` // english name, precise search
Desc string `form:"desc"` // chinese name, fuzzy search
}
// TableName tv_rank
func (c Channel) TableName() string {
return "tv_channel"
}
// TableName tv_rank
func (c ChannelFmt) TableName() string {
return "tv_channel"
}

View File

@@ -0,0 +1,44 @@
package model
import (
"go-common/library/time"
)
// ContentRepo def.
type ContentRepo struct {
ID int64 `json:"id"`
Title string `json:"title"`
Subtitle string `json:"subtitle"`
Desc string `json:"desc"`
Cover string `json:"cover"`
SeasonID int `json:"season_id"`
CID int `json:"cid" gorm:"column:cid"`
EPID int `json:"epid" gorm:"column:epid"`
MenuID int `json:"menu_id"`
State int `json:"state"`
Valid int `json:"valid"`
PayStatus int `json:"pay_status"`
IsDeleted int `json:"is_deleted"`
AuditTime int `json:"audit_time"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime_nb,omitempty"`
MtimeFormat string `json:"mtime"`
InjectTime time.Time `json:"inject_time"`
// InjectTimeFormat string `json:"inject_time"`
Reason string `json:"reason"`
SeasonTitle string `json:"season_title" gorm:"column:season_title"`
Category int8 `json:"category" gorm:"column:category"`
}
// TableName tv_content
func (*ContentRepo) TableName() string {
return "tv_content"
}
// ContentRepoPager def.
type ContentRepoPager struct {
TotalCount int64 `json:"total_count"`
Pn int `json:"pn"`
Ps int `json:"ps"`
Items []*ContentRepo `json:"items"`
}

View File

@@ -0,0 +1,111 @@
package model
import (
"go-common/library/time"
)
// APKInfo .
type APKInfo struct {
ID int64 `json:"id"`
CDNAddr string `json:"cdn_addr"`
CreatedAt time.Time `json:"created_at"`
FileMd5 string `json:"file_md5"`
InetAddr string `json:"inet_addr"`
IsDeleted bool `json:"is_deleted"`
IsGray bool `json:"is_gray"`
LocalPath string `json:"local_path"`
MappingAddr string `json:"mapping_addr"`
SignMd5 string `json:"sign_md5"`
Size int `json:"size"`
UpdatedAt time.Time `json:"updated_at"`
VersionCode int `json:"version_code"`
VersionID string `json:"version_id"`
VersionName string `json:"version_name"`
}
// MangoRecom is mango recom table structure
type MangoRecom struct {
ID int64 `json:"id" gorm:"column:id"`
RID int64 `json:"rid" gorm:"column:rid"`
Rtype int `json:"rtype"`
Title string `json:"title"`
Cover string `json:"cover"`
Category int `json:"category"`
Playcount int64 `json:"playcount"`
JID int64 `json:"jid" gorm:"column:jid"`
Content string `json:"content"`
Staff string `json:"staff"`
Rorder int `json:"rorder"`
}
// MangoListResp is the mango list response structure
type MangoListResp struct {
List []*MangoRecom `json:"list"`
Pubtime string `json:"pubtime"`
Message string `json:"message"` // 文案提示: rid, p213,u367 ...
}
// MangoAdd is the response of mango add function
type MangoAdd struct {
Succ []int64 `json:"succ"`
Invalids []int64 `json:"invalids"`
}
// TableName def.
func (*MangoRecom) TableName() string {
return "mango_recom"
}
// ToMango def.
func (sn *TVEpSeason) ToMango() *MangoRecom {
return &MangoRecom{
RID: sn.ID,
Rtype: 1,
Title: sn.Title,
Cover: sn.Cover,
Category: int(sn.Category),
Content: sn.Desc,
Staff: sn.Staff,
}
}
// ToMango def.
func (arc *SimpleArc) ToMango(cat int) *MangoRecom {
return &MangoRecom{
RID: arc.AID,
Rtype: 2,
Title: arc.Title,
Cover: arc.Cover,
Category: cat,
Content: arc.Content,
}
}
// ReqMangoEdit is the request for mango edit
type ReqMangoEdit struct {
ID int64 `form:"id" validate:"required"`
Title string `form:"title" validate:"required"`
Cover string `form:"cover" validate:"required"`
Playcount int64 `form:"playcount"`
JID int64 `form:"jid"`
Content string `form:"content" validate:"required"`
Staff string `form:"staff"`
}
// MRecomMC is mango recom struct in MC
type MRecomMC struct {
RIDs []int64
Pubtime time.Time
}
// ReqUnshelve is request for unshelve
type ReqUnshelve struct {
IDs []int64 `form:"ids,split" validate:"required,min=1,dive,gt=0"`
Type int `form:"type" validate:"required,min=1,max=4"`
}
// RespUnshelve is response for unshelve
type RespUnshelve struct {
SuccIDs []int64 `json:"succ_ids"`
FailIDs []int64 `json:"fail_ids"`
}

View File

@@ -0,0 +1,227 @@
package model
import (
"encoding/json"
"go-common/library/time"
"github.com/jinzhu/gorm"
"github.com/siddontang/go-mysql/mysql"
)
// Tv_rank table related const params
const (
_RankCategory = 5 // _RankCategory 模块干预
RankIdxBase = 5 // index page intervention base, pgc=5+1, ugc=5+2
)
// SimpleRank represents the table TV_RANK, but with only necessary fields for the front-end
type SimpleRank struct {
Title string `json:"title"`
Source int `json:"source"`
SourceName string `json:"source_name"`
Mtime string `json:"mtime"`
Pubdate string `json:"pubdate"`
RankCore
}
// RankCore def
type RankCore struct {
Rank int64 `json:"rank"`
ID int64 `json:"id"`
ContID int64 `json:"cid" gorm:"column:cont_id"`
ContType int `json:"cont_type"`
Position int `json:"position"`
}
// RankError represents the invalid season info
type RankError struct {
ID int `json:"id"`
SeasonID int `json:"season_id"`
}
// RankList is the output format for intervention list
type RankList struct {
List []*SimpleRank `json:"list"`
}
// Rank represents the table TV_RANK
type Rank struct {
Title string
ModuleID int64 `gorm:"column:module_id"`
Category int8
IsDeleted int8
Mtime time.Time
RankCore
}
// TableName tv_rank
func (c SimpleRank) TableName() string {
return "tv_rank"
}
// TableName tv_rank
func (v Rank) TableName() string {
return "tv_rank"
}
// BeComplete transforms a simpleRank to Complete rank in order to create it in DB
func (c SimpleRank) BeComplete(req *IntervPubReq, title string, position int) (res *Rank) {
res = &Rank{
Title: title,
RankCore: c.RankCore,
}
res.Position = position
if req.ModuleID > 0 {
res.Category = _RankCategory
res.ModuleID = req.ModuleID
return
}
if req.Rank > 0 {
res.Rank = req.Rank
}
if req.Category > 0 {
res.Category = int8(req.Category)
}
return
}
type catName func(int) string // translate pgc category to CN name
type tpParName func(int32) (string, int32, error) // translate ugc type to its parent tid and parent's name
// BeSimpleSn def.
func (v *Rank) BeSimpleSn(sn *TVEpSeason, translate catName) *SimpleRank {
return &SimpleRank{
RankCore: v.RankCore,
Title: sn.Title,
Source: sn.Category,
SourceName: translate(sn.Category),
Pubdate: sn.PlayTime.Time().Format(mysql.TimeFormat),
Mtime: v.Mtime.Time().Format(mysql.TimeFormat),
}
}
// BeSimpleArc def.
func (v *Rank) BeSimpleArc(arc *SimpleArc, translate tpParName) (res *SimpleRank) {
res = &SimpleRank{
RankCore: v.RankCore,
Title: arc.Title,
Mtime: v.Mtime.Time().Format(mysql.TimeFormat),
Pubdate: arc.Pubtime.Time().Format(mysql.TimeFormat),
}
if pname, pid, err := translate(arc.TypeID); err == nil {
res.Source = int(pid)
res.SourceName = pname
}
return
}
//BeError transforms a rank to rankError
func (v Rank) BeError() *RankError {
return &RankError{
ID: int(v.ID),
SeasonID: int(v.ContID),
}
}
// RankListReq is rank list request
type RankListReq struct {
Rank int64 `form:"rank" validate:"min=0"`
Category int64 `form:"category" validate:"required,min=1"`
}
// RankPubReq is rank publish request
type RankPubReq struct {
RankListReq
Intervs string `form:"intervs" validate:"required"`
}
// ModListReq is mod list request
type ModListReq struct {
ModuleID int64 `form:"module_id" validate:"required,min=1"`
}
// ModPubReq is mod publish request
type ModPubReq struct {
ModListReq
Intervs string `form:"intervs" validate:"required"`
}
// IdxListReq is index list request
type IdxListReq struct {
TypeID int64 `form:"type_id" validate:"required,min=1"`
RankType int64 `form:"rank_type" validate:"required,min=1,max=2"` // 1=pgc, 2=ugc
}
// IdxPubReq is index publish request.
type IdxPubReq struct {
IdxListReq
Intervs string `form:"intervs" validate:"required"`
}
// IntervListReq is common request for interv list.
type IntervListReq struct {
Rank int64
Category int64
ModuleID int64
}
// IntervPubReq is common request for interv publish.
type IntervPubReq struct {
IntervListReq
Items []*SimpleRank
}
// FromRank builds the request with rank & category params
func (v *IntervListReq) FromRank(rank *RankListReq) {
v.Rank = rank.Rank
v.Category = rank.Category
v.ModuleID = 0
}
// FromRank def.
func (v *IntervPubReq) FromRank(rank *RankPubReq) (err error) {
v.IntervListReq.FromRank(&rank.RankListReq)
return json.Unmarshal([]byte(rank.Intervs), &v.Items)
}
// FromMod builds the request with module params
func (v *IntervListReq) FromMod(mod *ModListReq) {
v.Rank = 0
v.Category = _RankCategory
v.ModuleID = mod.ModuleID
}
// FromMod builds the request with module params
func (v *IntervPubReq) FromMod(mod *ModPubReq) (err error) {
v.IntervListReq.FromMod(&mod.ModListReq)
return json.Unmarshal([]byte(mod.Intervs), &v.Items)
}
// FromIndex builds the request with index params
func (v *IntervListReq) FromIndex(idx *IdxListReq) {
v.Rank = idx.TypeID // category id, pgc or ugc type id
v.Category = idx.RankType + RankIdxBase // 6 or 7
v.ModuleID = 0
}
// IsIdx tells whether this request is from index
func (v *IntervListReq) IsIdx() bool {
return v.Category > RankIdxBase
}
// FromIndex def.
func (v *IntervPubReq) FromIndex(idx *IdxPubReq) (err error) {
v.IntervListReq.FromIndex(&idx.IdxListReq)
return json.Unmarshal([]byte(idx.Intervs), &v.Items)
}
// BuildDB builds the db from the intervention request
func (v *IntervListReq) BuildDB(db *gorm.DB) (newDB *gorm.DB) {
newDB = db.Model(Rank{}).Where("is_deleted = 0")
if v.ModuleID == 0 { // index or rank
newDB = newDB.Where("rank = ?", v.Rank).Where("category = ?", v.Category)
} else {
newDB = newDB.Where("module_id = ?", v.ModuleID)
}
return
}

View File

@@ -0,0 +1,179 @@
package model
import (
"encoding/json"
"fmt"
xtime "time"
arccli "go-common/app/service/main/archive/api"
"go-common/library/time"
"github.com/siddontang/go-mysql/mysql"
)
// label related params
const (
ParamTypeid = "typeid"
ParamUgctime = "pubtime"
UgcLabel = 2
PgcLabel = 1
)
// TpLabel def.
type TpLabel struct {
Category int `json:"-"`
Param string `json:"param"`
ParamName string `json:"param_name"`
}
// ReqLabel def.
type ReqLabel struct {
Category int `form:"category" validate:"required"`
Param string `form:"param" validate:"required"` // pubtime for time labels, typeid for type labels
Title string `form:"title"`
ID int `form:"id"`
}
// LabelDB is the index label in DB
type LabelDB struct {
LabelCore
Mtime time.Time `json:"Mtime"`
}
// SameType tells whether the given label has the exact same type with the V
func (v *LabelDB) SameType(given *LabelDB) bool {
return v.Category == given.Category && v.Param == given.Param && v.CatType == given.CatType
}
// LabelCore is core of Label
type LabelCore struct {
ID int64 `json:"id"`
Name string `json:"name"`
Param string `json:"param"`
ParamName string `json:"param_name"`
Value string `json:"value"`
Category int32 `json:"category"`
CatType int `json:"cat_type"`
Valid int `json:"valid"`
Position int `json:"position"`
}
// LabelList is used to list in TV CMS
type LabelList struct {
LabelCore
Mtime string `json:"mtime"`
Stime string `json:"stime,omitempty"`
Etime string `json:"etime,omitempty"`
}
// PgcCondResp is pgc condition response structure
type PgcCondResp struct {
Code int `json:"code"`
Message string `json:"message"`
Result *PgcCond `json:"result"`
}
// PgcCond def.
type PgcCond struct {
Filter []*Cond `json:"filter"`
}
// Cond def.
type Cond struct {
ID string `json:"id"`
Name string `json:"name"`
Value []*CondV `json:"value"`
}
// CondV def.
type CondV struct {
ID string `json:"id"`
Name string `json:"name"`
}
// UgcTime is used to add time labels for ugc
type UgcTime struct {
UTime
Category int32 `form:"category" validate:"required"`
Name string `form:"name" validate:"required"`
}
// EditUgcTime def.
type EditUgcTime struct {
ID int64 `form:"id" validate:"required"`
Name string `form:"name" validate:"required"`
UTime
}
// UTime is used for storage in DB by json
type UTime struct {
Stime int64 `form:"stime" validate:"required" json:"stime"`
Etime int64 `form:"etime" validate:"required" json:"etime"`
}
// TimeV picks time value in Json
func (tm *UTime) TimeV() string {
timeV, _ := json.Marshal(tm)
return string(timeV)
}
// ToList transforms LabelDB to LabelList
func (v *LabelDB) ToList() *LabelList {
res := &LabelList{
LabelCore: v.LabelCore,
Mtime: v.Mtime.Time().Format(mysql.TimeFormat),
}
if v.CatType == UgcLabel && v.Param == ParamUgctime && v.Value != "" {
utime := UTime{}
if err := json.Unmarshal([]byte(v.Value), &utime); err != nil {
return res
}
res.Stime = xtime.Unix(utime.Stime, 0).Format(mysql.TimeFormat)
res.Etime = xtime.Unix(utime.Etime, 0).Format(mysql.TimeFormat)
}
return res
}
// TableName tv_rank
func (v LabelDB) TableName() string {
return "tv_label"
}
// FromArcTp def.
func (v *LabelDB) FromArcTp(tp *arccli.Tp, paramName string) {
v.LabelCore = LabelCore{
Name: tp.Name,
Value: fmt.Sprintf("%d", tp.ID),
Category: tp.Pid,
Param: ParamTypeid,
ParamName: paramName,
CatType: UgcLabel,
Valid: 1,
}
}
// FromPgcCond def.
func (v *LabelDB) FromPgcCond(value *CondV, cond *Cond, category int32) {
v.LabelCore = LabelCore{
Name: value.Name,
Value: value.ID,
Category: category,
Param: cond.ID,
ParamName: cond.Name,
CatType: PgcLabel,
Valid: 1,
}
}
// FromUgcTime def.
func (v *LabelDB) FromUgcTime(tm *UgcTime, paramName string) {
v.LabelCore = LabelCore{
Name: tm.Name,
Value: tm.TimeV(),
Category: tm.Category,
Param: ParamUgctime,
ParamName: paramName,
CatType: UgcLabel,
Valid: 1,
}
}

View File

@@ -0,0 +1,166 @@
package model
import (
"fmt"
"go-common/library/time"
)
const (
//ModulesNotDelete module not delete
ModulesNotDelete = 0
//ModulesDelete module delete
ModulesDelete = 1
//ModulesValid module is valid
ModulesValid = 1
//ModulesPublishYes module is publish status in MC
ModulesPublishYes = 1
//ModulesPublishNo module is not publish status in MC
ModulesPublishNo = 0
//PageMain 主页
PageMain = 0
//PageJP 追番
PageJP = 1
//PageMovie 电影
PageMovie = 2
//PageDocumentary 纪录片
PageDocumentary = 3
//PageCN 国创
PageCN = 4
//PageSoapopera 电视剧
PageSoapopera = 5
//TypeSevenFocus 首页七格焦点图
TypeSevenFocus = 1
//TypeFiveFocus 5格焦点
TypeFiveFocus = 2
//TypeSixFocus 6格焦点
TypeSixFocus = 3
//TypeVertListFirst 竖图1列表
TypeVertListFirst = 4
//TypeVertListSecond 竖图2列表
TypeVertListSecond = 5
//TypeHorizList 横图列表
TypeHorizList = 6
//TypeZhuiFan 追番模块
TypeZhuiFan = 7
)
// Modules is use for Modular
type Modules struct {
ID uint64 `json:"id"`
PageID string `json:"page_id" form:"page_id" validate:"required"`
Flexible string `json:"flexible" form:"flexible" validate:"required"`
Icon string `json:"icon" form:"icon"`
Title string `json:"title" form:"title" validate:"required"`
Capacity uint64 `json:"capacity" form:"capacity" validate:"required"`
More string `json:"more" form:"more" validate:"required"`
Order uint8 `json:"order"`
Moretype string `json:"moretype" form:"moretype"`
Morepage int64 `json:"morepage" form:"morepage"`
Deleted uint8 `json:"-"`
Valid uint8 `json:"valid"`
ModCore
}
// ModulesAddParam is use for Modular add param
type ModulesAddParam struct {
ID uint64 `form:"id" validate:"required"`
PageID string `form:"page_id" validate:"required"`
Flexible string `form:"flexible" validate:"required"`
Icon string `form:"icon"`
Title string `form:"title" validate:"required"`
Capacity uint64 `form:"capacity" validate:"required"`
More string `form:"more" validate:"required"`
Moretype string `json:"moretype" form:"moretype"`
Morepage int64 `json:"morepage" form:"morepage"`
Order uint8
ModCore
}
// ModCore def.
type ModCore struct {
Type string `json:"type" form:"type" validate:"required"`
Source string `json:"source" form:"source" validate:"required"`
SrcType int `json:"src_type" form:"src_type" validate:"required"`
}
//ModPub is used for store publish status
type ModPub struct {
Time string
State uint8
}
//ModulesList is used for function module list
type ModulesList struct {
Items []*Modules `json:"items"`
PubState uint8 `json:"pubstate"`
PubTime string `json:"pubtime"`
}
// TableName tv modules
func (a Modules) TableName() string {
return "tv_modules"
}
//CommonCat , PGC types or ugc second level types
type CommonCat struct {
ID int32 `json:"id"`
PID int32 `json:"pid"`
Name string `json:"name"`
Type int `json:"type"`
}
//ParentCat : ugc first level types
type ParentCat struct {
ID int32 `json:"id"`
Name string `json:"name"`
Type int `json:"type"`
Children []*CommonCat `json:"children,omitempty"`
}
//SupCats : support category map
type SupCats struct {
UgcMap map[int32]int
PgcMap map[int32]int
}
// AbnorCids is the export format for abnormal cids
type AbnorCids struct {
CID int64 `json:"cid"`
VideoTitle string `json:"video_title"`
CTime string `json:"ctime"`
AID int64 `json:"aid"`
ArcTitle string `json:"arc_title"`
PubTime string `json:"pub_time"`
}
// Export transforms the structure to export csv data
func (v *AbnorCids) Export() (res []string) {
res = append(res, fmt.Sprintf("%d", v.CID))
res = append(res, v.VideoTitle)
res = append(res, v.CTime)
res = append(res, fmt.Sprintf("%d", v.AID))
res = append(res, v.ArcTitle)
res = append(res, v.PubTime)
return
}
// AbnorVideo def.
type AbnorVideo struct {
CID int64
VideoTitle string
CTime time.Time
AID int64
}
// ToCids transforms the archive & video to abnormal cid export structure
func (v *AbnorVideo) ToCids(arc *Archive) *AbnorCids {
return &AbnorCids{
CID: v.CID,
VideoTitle: v.VideoTitle,
CTime: v.CTime.Time().Format("2006-01-02 15:04:05"),
AID: v.AID,
ArcTitle: arc.Title,
PubTime: arc.Pubtime.Time().Format("2006-01-02 15:04:05"),
}
}

View File

@@ -0,0 +1,58 @@
package model
import "go-common/library/time"
// TvPayOrder is table struct
type TvPayOrder struct {
ID int64 `json:"id"`
OrderNo string `json:"order_no"`
Platform int8 `json:"platform"`
OrderType int8 `json:"order_type"`
ActiveType int8 `json:"active_type"`
MID int64 `json:"mid" gorm:"column:mid"`
BuyMonths int8 `json:"buy_months"`
ProductID string `json:"product_id"`
Money int64 `json:"money"`
Quantity int64 `json:"quantity"`
RefundAmount int64 `json:"refund_amount"`
Status int8 `json:"status"`
ThirdTradeNO string `json:"third_trade_no"`
PaymentMoney int64 `json:"payment_money"`
PaymentType string `json:"payment_type"`
PaymentTime time.Time `json:"payment_time"`
Ver int64 `json:"ver"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// TvPayOrderResp is used to list in TV pay order list
type TvPayOrderResp struct {
ID int64 `json:"id"`
OrderNo string `json:"order_no"`
OrderType int8 `json:"order_type"`
ActiveType int8 `json:"active_type"`
MID int64 `json:"mid" form:"mid" gorm:"column:mid"`
BuyMonths int8 `json:"buy_months"`
ProductID string `json:"product_id"`
Money int64 `json:"money"`
Quantity int64 `json:"quantity"`
RefundAmount int64 `json:"refund_amount"`
Status int8 `json:"status"`
ThirdTradeNO string `json:"third_trade_no"`
PaymentMoney int64 `json:"payment_money"`
PaymentType string `json:"payment_type"`
PaymentTime time.Time `json:"payment_time"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// OrderPageHelper is used to list in TV pay order list count
type OrderPageHelper struct {
Items []*TvPayOrderResp `json:"items"`
Total *int64 `json:"total"`
}
// TableName tv_pay_order
func (*TvPayOrderResp) TableName() string {
return "tv_pay_order"
}

View File

@@ -0,0 +1,100 @@
package model
import "go-common/library/time"
// TvPriceConfig is tv vip pay order
type TvPriceConfig struct {
ID int64 `form:"id" json:"id"`
PID int64 `form:"pid" json:"pid" gorm:"column:pid"`
Platform int8 `form:"platform" json:"platform" validate:"required"`
ProductName string `form:"product_name" validate:"required" json:"product_name"`
ProductID string `form:"product_id" validate:"required" json:"product_id"`
SuitType int8 `form:"suit_type" json:"suit_type" `
Month int64 `form:"month" json:"month"`
SubType int8 `form:"sub_type" json:"sub_type" `
Price int64 `form:"price" json:"price"`
Selected int8 `form:"selected" json:"selected"`
Remark string `form:"remark" json:"remark"`
Status int8 `form:"status" json:"status"`
Superscript string `form:"superscript" json:"superscript"`
Operator string `form:"operator" json:"operator"`
OperId int64 `form:"oper_id" json:"oper_id"`
Stime time.Time `form:"stime" json:"stime"`
Etime time.Time `form:"etime" json:"etime"`
Mtime time.Time `json:"mtime"`
}
// TvPriceConfigResp is used show panel info
type TvPriceConfigResp struct {
ID int64 `form:"id" json:"id"`
PID int64 `form:"pid" json:"pid" gorm:"column:pid"`
ProductName string `form:"product_name" json:"product_name"`
ProductID string `form:"product_id" json:"product_id"`
SuitType int8 `form:"suit_type" json:"suit_type"`
Month int64 `form:"month" json:"month"`
SubType int8 `form:"sub_type" json:"sub_type"`
Price int64 `form:"price" json:"price"`
OriginPrice int64 `form:"original_price" json:"original_price"`
Selected int8 `form:"selected" json:"selected"`
Remark string `form:"remark" json:"remark"`
Status int8 `form:"status" json:"status"`
Superscript string `form:"superscript" json:"superscript"`
Operator string `form:"operator" json:"operator"`
OperId int64 `form:"oper_id" json:"oper_id"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
Items []TvPriceConfig `json:"item"`
}
// TvPriceConfigListResp is used to list in TV panel list
type TvPriceConfigListResp struct {
ID int64 `form:"id" json:"id"`
PID int64 `form:"pid" json:"pid" gorm:"column:pid"`
ProductName string `form:"product_name" json:"product_name"`
ProductID string `form:"product_id" json:"product_id"`
SuitType int8 `form:"suit_type" json:"suit_type"`
Month int64 `form:"month" json:"month"`
SubType int8 `form:"sub_type" json:"sub_type"`
Price int64 `form:"price" json:"price"`
OriginPrice int64 `form:"original_price" json:"original_price"`
Selected int8 `form:"selected" json:"selected"`
Status int8 `form:"status" json:"status"`
Operator string `form:"operator" json:"operator"`
OperId int64 `form:"oper_id" json:"oper_id"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// RemotePanel YST product res
type RemotePanel struct {
Product []Product `json:"data"`
Result struct {
ResultCode string `json:"result_code"`
ResultMsg string `json:"result_msg"`
} `json:"result"`
}
// Product YST product
type Product struct {
ID string `json:"id"`
Description string `json:"description"`
Title string `json:"title"`
Price int64 `json:"price"`
ComboPkgID string `json:"combo_pkg_id"`
ComboDes string `json:"combo_des"`
VideoType string `json:"video_type"`
VodType string `json:"vod_type"`
ProductDuration string `json:"product_duration"`
Contract string `json:"contract"`
SuitType int8 `json:"suit_type"`
}
// TableName tv_price_config
func (*TvPriceConfig) TableName() string {
return "tv_price_config"
}
// TableName tv_price_config
func (*TvPriceConfigListResp) TableName() string {
return "tv_price_config"
}

View File

@@ -0,0 +1,51 @@
package model
import (
"go-common/library/time"
"github.com/siddontang/go-mysql/mysql"
)
// RegCore .
type RegCore struct {
ID int `json:"id" form:"id"`
PageID int `json:"page_id" form:"page_id"`
Title string `json:"title" form:"title"`
Valid int `json:"valid" form:"valid"`
IndexType int `json:"index_type" form:"index_type"`
IndexTid int `json:"index_tid" form:"index_tid"`
Deleted int `json:"deleted" form:"deleted"`
Rank int `json:"rank"`
}
// RegDB .
type RegDB struct {
RegCore
Mtime time.Time `json:"mtime" form:"mtime"`
}
// RegList .
type RegList struct {
RegCore
Mtime string `json:"mtime"`
}
// ToList ctime format .
func (v *RegDB) ToList() *RegList {
return &RegList{
RegCore: v.RegCore,
Mtime: v.Mtime.Time().Format(mysql.TimeFormat),
}
}
// TableName return table name .
func (*RegDB) TableName() string {
return "tv_pages"
}
// Param .
type Param struct {
Title string `form:"title"`
PageID string `form:"page_id"`
State string `form:"state"`
}

View File

@@ -0,0 +1,43 @@
package model
import (
"go-common/library/time"
)
//SearInter reprensents the search intervene
type SearInter struct {
ID int64 `json:"id" params:"id"`
Searchword string `json:"searchword" params:"searchword"`
Rank int64 `json:"rank" params:"rank"`
Tag string `json:"tag" params:"tag"`
Deleted int8 `json:"deleted"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// TableName gives the table name of search intervene
func (*SearInter) TableName() string {
return "search_intervene"
}
// SearInterPager search intervene pager
type SearInterPager struct {
TotalCount int `json:"total_count"`
Pn int `json:"pn"`
Ps int `json:"ps"`
Items []*SearInter `json:"items"`
PubState int8
PubTime string
}
//OutSearchInter output search intervene
type OutSearchInter struct {
Keyword string `json:"keyword"`
Status string `json:"status"`
}
//PublishStatus search intervene publish status state 0-unPublish 1-publish
type PublishStatus struct {
Time string
State int8
}

View File

@@ -0,0 +1,187 @@
package model
import (
"net/url"
"reflect"
"strconv"
"go-common/library/time"
"github.com/siddontang/go-mysql/mysql"
)
// TVEpContent reprensents the content table
type TVEpContent struct {
ID int64 `form:"id" params:"id" validate:"required"`
CID int `form:"cid" params:"cid" gorm:"column:cid" validate:"required"`
SeasonID int64 `form:"season_id" params:"season_id" validate:"required"`
Title string `form:"title" params:"title"`
LongTitle string `form:"long_title" params:"long_title"`
Cover string `form:"cover" params:"cover"`
Length int32 `form:"length" params:"length"`
Order int `form:"order" params:"order" validate:"required"`
PayStatus int `form:"pay_status" validate:"required" gorm:"-"`
Desc string `form:"desc" gorm:"-"`
IsDeleted int8
Ctime time.Time
Mtime time.Time
}
// TVEpSeason represents the season table
type TVEpSeason struct {
ID int64 `form:"id" json:"id" params:"id" validate:"required" gorm:"column:id"`
OriginName string `form:"origin_name" json:"origin_name" params:"origin_name" validate:"required"`
Title string `form:"title" json:"title" params:"title"`
Alias string `form:"alias" json:"alias" params:"alias"`
Category int `form:"category" json:"category" params:"category" validate:"required" gorm:"column:category"`
Desc string `form:"desc" json:"desc" params:"desc"`
Style string `form:"style" json:"style" params:"style"`
Area string `form:"area" json:"area" params:"area"`
PlayTime time.Time `form:"play_time" json:"play_time" params:"play_time" validate:"required"`
Info int `form:"info" json:"info" params:"info" validate:"required"`
State string `form:"state" json:"state" validate:"required" params:"state"`
TotalNum string `form:"total_num" json:"total_num" params:"total_num" validate:"required"`
Upinfo string `form:"upinfo" json:"upinfo" params:"upinfo"`
Staff string `form:"staff" json:"staff" params:"staff"`
Role string `form:"role" json:"role" params:"role"`
Copyright string `form:"copyright" json:"copyright" params:"copyright"`
Cover string `form:"cover" json:"cover" params:"cover" gorm:"column:cover"`
Check int `json:"check"`
IsDeleted int `json:"is_deleted"`
AuditTime int `json:"audit_time"`
Valid int `json:"valid"`
Reason string `json:"reason"`
Version string `json:"version" form:"version"` // v1.13 new fields, movie, OVA or normal
Producer string `json:"producer" form:"producer"` // v1.13 new fields, BBC, CCTV etc
AliasSearch string `json:"alias_search" form:"alias_search"`
Brief string `json:"brief" form:"brief"`
Status string `json:"status" form:"status"`
}
// SeaRepoCore def.
type SeaRepoCore struct {
ID int64 `json:"id" params:"id"`
OriginName string `json:"origin_name" params:"origin_name"`
Title string `json:"title" params:"title"`
Alias string `json:"alias" params:"alias"`
Category int8 `json:"category" params:"category"`
Desc string `json:"desc" params:"desc"`
Style string `json:"style" params:"style"`
Area string `json:"area" params:"area"`
Info int8 `json:"info" params:"info"`
State int8 `json:"state" params:"state"`
TotalNum int32 `json:"total_num" params:"total_num"`
Upinfo string `json:"upinfo" params:"upinfo"`
Staff string `json:"staff" params:"staff"`
Role string `json:"role" params:"role"`
Copyright string `json:"copyright" params:"copyright"`
Cover string `json:"cover" params:"cover" gorm:"column:cover"`
Check int8 `json:"check"`
IsDeleted int8 `json:"is_deleted"`
AuditTime int `json:"audit_time"`
Ctime time.Time `json:"ctime"`
Valid int8 `json:"valid"`
InjectTime time.Time `json:"inject_time"`
Reason string `json:"reason"`
}
// SeaRepoDB def.
type SeaRepoDB struct {
SeaRepoCore
PlayTime time.Time `gorm:"column:play_time"`
Mtime time.Time `json:"mtime"`
}
// SeaRepoList def.
type SeaRepoList struct {
SeaRepoCore
Mtime string `json:"mtime"`
Pubdate string `json:"pubdate"`
}
// ToList transforms a SeaRepoDB to list, time transformation
func (v *SeaRepoDB) ToList() (list *SeaRepoList) {
list = &SeaRepoList{
SeaRepoCore: v.SeaRepoCore,
}
list.Mtime = v.Mtime.Time().Format(mysql.TimeFormat)
list.Pubdate = v.PlayTime.Time().Format(mysql.TimeFormat)
return
}
// TableName gives the table name of content
func (*TVEpContent) TableName() string {
return "tv_ep_content"
}
// TableName gives the table name of season
func (*TVEpSeason) TableName() string {
return "tv_ep_season"
}
// TableName gives the table name of season
func (v *SeaRepoDB) TableName() string {
return "tv_ep_season"
}
// SeasonRepoPager def.
type SeasonRepoPager struct {
TotalCount int64 `json:"total_count"`
Pn int `json:"pn"`
Ps int `json:"ps"`
Items []*SeaRepoList `json:"items"`
}
// Updated picks value from request and compare with the struct to analyse the difference
func (sn TVEpSeason) Updated(req url.Values) (fields map[string]interface{}) {
var (
vl = reflect.ValueOf(sn)
tp = reflect.TypeOf(sn)
)
fields = make(map[string]interface{})
for i := 0; i < vl.NumField(); i++ {
var (
t = tp.Field(i)
v = vl.Field(i)
name = t.Tag.Get("json")
)
if reqV := req.Get(name); reqV != "" {
if kind := t.Type.Kind(); kind == reflect.Int || kind == reflect.Int64 {
if v.Int() != atoi(reqV) {
fields[name] = atoi(reqV)
}
} else {
if v.String() != reqV {
fields[name] = reqV
}
}
}
}
return
}
// ToContent transforms an ep to content object
func (epc *TVEpContent) ToContent(isInit bool) (res *Content) {
res = &Content{
Title: epc.LongTitle,
Subtitle: epc.Title,
Desc: epc.Desc,
Cover: epc.Cover,
SeasonID: int(epc.SeasonID),
CID: epc.CID,
EPID: int(epc.ID),
PayStatus: epc.PayStatus,
}
if isInit {
res.State = 1
}
return
}
func atoi(value string) (intval int64) {
intval, err := strconv.ParseInt(value, 10, 64)
if err != nil {
intval = 0
}
return intval
}

View File

@@ -0,0 +1,60 @@
package model
import (
"go-common/library/time"
)
// Content content def.
type Content struct {
ID int64 `json:"id"`
Title string `json:"title"`
Subtitle string `json:"subtitle"`
Desc string `json:"desc"`
Cover string `json:"cover"`
SeasonID int `json:"season_id"`
CID int `json:"cid" gorm:"column:cid"`
EPID int `json:"epid" gorm:"column:epid"`
MenuID int `json:"menu_id"`
State int `json:"state"`
Valid int `json:"valid"`
PayStatus int `json:"pay_status"`
IsDeleted int `json:"is_deleted"`
AuditTime int `json:"audit_time"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
InjectTime time.Time `json:"inject_time"`
Reason string `json:"reason"`
}
// ContentDetail def.
type ContentDetail struct {
ID int64 `json:"id"`
Title string `json:"title"`
Subtitle string `json:"subtitle"`
Desc string `json:"desc"`
Cover string `json:"cover"`
SeasonID int `json:"season_id"`
CID int `json:"cid" gorm:"column:cid"`
EPID int `json:"epid" gorm:"column:epid"`
MenuID int `json:"menu_id"`
State int `json:"state"`
Valid int `json:"valid"`
PayStatus int `json:"pay_status"`
IsDeleted int `json:"is_deleted"`
AuditTime int `json:"audit_time"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
InjectTime time.Time `json:"inject_time"`
Reason string `json:"reason"`
Order int `json:"order"`
}
// TableName tv_content
func (c Content) TableName() string {
return "tv_content"
}
// TableName tv_content
func (*ContentDetail) TableName() string {
return "tv_content"
}

View File

@@ -0,0 +1,52 @@
package model
//UPlayURLR ugc play url response
type UPlayURLR struct {
Code uint64 `json:"code"`
Result string `json:"result"`
Message string `json:"message"`
From string `json:"from"`
Quality int `json:"quality"`
Format string `json:"format"`
Timelength int `json:"timelength"`
AcceptFormat string `json:"accept_format"`
AcceptDescription []string `json:"accept_description"`
AcceptQuality []int `json:"accept_quality"`
AcceptWatermark []bool `json:"accept_watermark"`
VideoCodecid int `json:"video_codecid"`
VideoProject bool `json:"video_project"`
SeekParam string `json:"seek_param"`
SeekType string `json:"seek_type"`
Durl []struct {
Order int `json:"order"`
Length int `json:"length"`
Size int `json:"size"`
Ahead string `json:"ahead"`
Vhead string `json:"vhead"`
URL string `json:"url"`
} `json:"durl"`
}
// PlayurlResp is the response struct from Playurl API
type PlayurlResp struct {
Code int `json:"code"`
Message string `json:"message"`
From string `json:"from"`
Result string `json:"result"`
Quality int `json:"quality"`
Format string `json:"format"`
Timelength int `json:"timelength"`
AcceptFormat string `json:"accept_format"`
AcceptQuality []int `json:"accept_quality"`
SeekParam string `json:"seek_param"`
SeekType string `json:"seek_type"`
Durl []*Durl `json:"durl"`
}
// Durl def.
type Durl struct {
Order int `json:"order"`
Length int `json:"length"`
Size int `json:"size"`
URL string `json:"url"`
}

View File

@@ -0,0 +1,104 @@
package model
import "go-common/library/time"
// Upper corresponds to the structure of upper in our DB
type Upper struct {
ID int `json:"id"`
MID int64 `json:"mid" gorm:"column:mid"`
State int `json:"state"`
Toinit int `json:"toinit"`
Retry int `json:"retry"`
Deleted int `json:"deleted"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// UpperR corresponds to the structure of upper to show in front-end
type UpperR struct {
MID int64 `json:"mid"`
State int `json:"state"`
Name string `json:"name"`
Ctime string `json:"ctime"`
Mtime string `json:"mtime"`
}
// UpperPager def.
type UpperPager struct {
Items []*UpperR `json:"items"`
Page *Page `json:"page"`
}
// TableName ugc_uploader
func (a Upper) TableName() string {
return "ugc_uploader"
}
// ImportResp is for the response for import uppers' videos
type ImportResp struct {
NotExist []int64 `json:"not_exist"` // not existing uppers
Succ []int64 `json:"succ"` // succesffuly updated ids
}
// ReqUpCms is the request structure of upcmsList
type ReqUpCms struct {
Order int `form:"order" validate:"required,min=3,max=4" default:"3"` // 3 = mtime Desc, 4 = mtime Asc
Pn int `form:"pn" default:"1"`
Name string `form:"name"`
MID int64 `form:"mid"`
Valid string `form:"valid"` // 0 = offline, 1 = online
}
// CmsUpper corresponds to the structure of upper for CMS in our DB
type CmsUpper struct {
MID int64 `json:"mid" gorm:"column:mid"`
Mtime time.Time `json:"-"`
MtimeStr string `json:"mtime" gorm:"-"`
CmsName string `json:"cms_name"`
OriName string `json:"ori_name"`
CmsFace string `json:"cms_face"`
Valid int `json:"valid"`
}
// ReqUpEdit is the request of up edit function
type ReqUpEdit struct {
MID int64 `form:"mid" validate:"required"`
Name string `form:"name" validate:"required"`
Face string `form:"face" validate:"required"`
}
// TableName ugc_uploader
func (a CmsUpper) TableName() string {
return "ugc_uploader"
}
// CmsUpperPager is cms upper pager
type CmsUpperPager struct {
Items []*CmsUpper `json:"items"`
Page *Page `json:"page"`
}
// RespUpAudit is the response of up audit function
type RespUpAudit struct {
Succ []int64 `json:"succ"`
Invalid []int64 `json:"invalid"`
}
// UpMC is upper info in MC
type UpMC struct {
ID int
MID int64 `gorm:"column:mid"`
Toinit int
Submit int // 1=need report
OriName string `gorm:"column:ori_name"` // original name
CMSName string `gorm:"column:cms_name"` // cms intervened name
OriFace string `gorm:"column:ori_face"` // original face
CMSFace string `gorm:"column:cms_face"` // cms intervened face
Valid int // auth info: 1=online,0=hidden
Deleted int
}
// TableName ugc_uploader
func (a UpMC) TableName() string {
return "ugc_uploader"
}

View File

@@ -0,0 +1,55 @@
package model
import "go-common/library/time"
// TvUserInfo is table struct
type TvUserInfo struct {
ID int64 `json:"id"`
MID int64 `json:"mid" gorm:"column:mid"`
Ver int64 `json:"ver"`
VipType int8 `json:"vip_type"`
PayType int8 `json:"pay_type"`
PayChannelID string `json:"pay_channel_id"`
Status int8 `json:"status"`
OverdueTime time.Time `json:"overdue_time"`
RecentPayTime time.Time `json:"recent_pay_time"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// TvUserInfoResp is used to user info
type TvUserInfoResp struct {
ID int64 `json:"id"`
MID int64 `json:"mid" gorm:"column:mid"`
VipType int8 `json:"vip_type"`
PayType int8 `json:"pay_type"`
PayChannelID string `json:"pay_channel_id"`
Status int8 `json:"status"`
OverdueTime time.Time `json:"overdue_time"`
RecentPayTime time.Time `json:"recent_pay_time"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// TvUserChangeHistory is table struct
type TvUserChangeHistory struct {
ID int64 `json:"id"`
MID int64 `json:"mid"`
ChangeType int8 `json:"change_type"`
ChangeTime time.Time `json:"change_time"`
Days int64 `json:"days"`
OperatorId string `json:"operator_id"`
Remark string `json:"remark"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// TableName tv_user_info
func (t *TvUserInfo) TableName() string {
return "tv_user_info"
}
// TableName tv_user_info
func (t *TvUserInfoResp) TableName() string {
return "tv_user_info"
}

View File

@@ -0,0 +1,83 @@
package model
import (
"go-common/library/time"
)
// VersionUpdate .
type VersionUpdate struct {
ID int64 `json:"id"`
VID int `json:"vid" gorm:"column:vid"`
Channel string `json:"channel"`
Coverage int32 `json:"coverage"`
Size int `json:"size"`
URL string `json:"url" gorm:"column:url"`
Md5 string `json:"md5"`
State int8 `json:"state"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
Sdkint int `json:"sdkint"`
Model string `json:"model"`
Policy int8 `json:"policy"`
IsForce int8 `json:"is_force"`
PolicyName string `json:"policy_name"`
IsPush int8 `json:"is_push"`
}
// VersionUpdateLimit .
type VersionUpdateLimit struct {
ID int64 `json:"id"`
UPID int32 `json:"up_id" gorm:"column:up_id"`
Condi string `json:"condi"`
Value int `json:"value"`
}
// VersionUpdateDetail .
type VersionUpdateDetail struct {
*VersionUpdate
VerLimit []*VersionUpdateLimit `json:"ver_limit"`
}
// TableName version_update
func (v VersionUpdate) TableName() string {
return "version_update"
}
// TableName version_update_limit
func (l VersionUpdateLimit) TableName() string {
return "version_update_limit"
}
// VersionUpdatePager def.
type VersionUpdatePager struct {
TotalCount int64 `json:"total_count"`
Pn int `json:"pn"`
Ps int `json:"ps"`
Items map[string]interface{} `json:"items"`
}
// Version .
type Version struct {
ID int64 `json:"id"`
Plat int8 `json:"plat"`
Description string `json:"description"`
Version string `json:"version"`
Build int `json:"build"`
State int8 `json:"state"`
Ptime time.Time `json:"ptime"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// TableName version
func (*Version) TableName() string {
return "version"
}
// VersionPager def.
type VersionPager struct {
TotalCount int64 `json:"total_count"`
Pn int `json:"pn"`
Ps int `json:"ps"`
Items []*Version `json:"items"`
}

View File

@@ -0,0 +1,110 @@
package model
import (
arccli "go-common/app/service/main/archive/api"
"go-common/library/time"
)
// Video is used from PGC video
type Video struct {
ID int `gorm:"column:id" json:"id"`
AID int `gorm:"column:aid" json:"aid"`
Eptitle string `gorm:"column:eptitle" json:"eptitle"`
Description string `gorm:"column:description" json:"description"`
CID int64 `gorm:"column:cid" json:"cid"`
Duration int `gorm:"column:duration" json:"duration"`
IndexOrder int `gorm:"column:duration" json:"index_order"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"mtime"`
InjectTime time.Time `gorm:"column:inject_time" json:"inject_time"`
Valid uint8 `gorm:"column:valid" json:"valid"`
Submit uint8 `gorm:"column:submit" json:"submit"`
Retry int `gorm:"column:retry" json:"retry"`
Result int `gorm:"column:result" json:"result"`
Deleted uint8 `gorm:"column:deleted" json:"deleted"`
State int `gorm:"column:state" json:"state"`
Reason string `gorm:"column:reason" json:"reason"`
Manual int `gorm:"column:manual" json:"manual"`
}
// VideoListParam is used for vlideolist funtion param valid
type VideoListParam struct {
CID string `form:"cid" json:"cid"`
VID string `form:"vid" json:"vid"`
Typeid int16 `form:"typeid" json:"typeid"`
Pid int32 `form:"pid" json:"-"`
Valid string `form:"valid" json:"valid"`
Order int `form:"order" json:"order" default:"2"`
Pn int `form:"pn" json:"pn" default:"1"`
Ps int `form:"ps" json:"ps" default:"20"`
}
// VideoListQuery is used for selecting the field of pgc video
type VideoListQuery struct {
ID string `json:"id"`
VID string `json:"vid" gorm:"column:cid"`
CID string `json:"cid" gorm:"column:aid"`
Eptitle string `json:"eptitle"`
Valid string `json:"valid" gorm:"column:valid"`
Mtime time.Time `json:"mtime"`
SeasonTitle string `json:"season_title" gorm:"column:title"`
TypeID int32 `json:"typeid" gorm:"column:typeid"`
PTypeID int32 `json:"parent_typeid"`
Page int `json:"page" gorm:"column:index_order"`
}
// VideoListPager is used by video list function to return result and page info
type VideoListPager struct {
Items []*VideoListQuery `json:"items"`
Page *Page `json:"page"`
}
// TableName ugc_video
func (a VideoListQuery) TableName() string {
return "ugc_video"
}
// TableName ugc_video
func (video Video) TableName() string {
return "ugc_video"
}
// ConsultRes transforms an archive to ArcRes
func (arc *Archive) ConsultRes(dict map[int32]*arccli.Tp) (res *ArcRes) {
var pid int32
res = &ArcRes{}
if cat, ok := dict[arc.TypeID]; ok {
pid = cat.Pid
res.SecondCat = cat.Name
}
if pid != 0 {
if pcat, ok := dict[pid]; ok {
res.FirstCat = pcat.Name
}
}
res.Status = int(arc.Result)
res.AVID = arc.AID
res.Title = arc.Title
res.PubTime = arc.Pubtime.Time().Format("2006-01-02 15:04:05")
if arc.InjectTime >= 0 {
res.InjectTime = arc.InjectTime.Time().Format("2006-01-02 15:04:05")
}
res.Reason = arc.Reason
return
}
// ConsultRes transforms an video to VideoRes
func (video *Video) ConsultRes() (res *VideoRes) {
res = &VideoRes{
CID: video.CID,
Title: video.Eptitle,
Page: video.IndexOrder,
Status: video.Result,
Ctime: video.Ctime.Time().Format("2006-01-02 15:04:05"),
Reason: video.Reason,
}
if video.InjectTime >= 0 {
res.InjectTime = video.InjectTime.Time().Format("2006-01-02 15:04:05")
}
return
}

View File

@@ -0,0 +1,93 @@
package model
import "go-common/library/time"
const (
//WatermarkWhite 水印白名单
WatermarkWhite = 1
//WatermarkDefault 水印默认值
WatermarkDefault = 0
//OrderDesc 降序
OrderDesc = 1
)
// WaterMarkList def.
type WaterMarkList struct {
ID string `form:"id" json:"id"`
Epid string `form:"epid" json:"epid"`
SeasonID string `form:"season_id" json:"season_id"`
Category string `form:"category" json:"category"`
SeasonTitle string `form:"season_title" json:"season_title"`
ContentTitle string `form:"content_title" json:"content_title"`
MarkTime time.Time `form:"mark_time" json:"mark_time"`
}
// WaterMarkOne is used for only selecting some field from gorm query
type WaterMarkOne struct {
ID string `form:"id" json:"id"`
Mark uint8 `form:"mark" json:"mark"`
MarkTime string `form:"mark_time" json:"mark_time"`
}
// WaterMarkListPager is used for return items and pager info
type WaterMarkListPager struct {
Items []*WaterMarkList `json:"items"`
Page *Page `json:"page"`
}
// WaterMarkListParam is use for watermarklist function query param valid
type WaterMarkListParam struct {
Order uint8 `form:"id" json:"order" default:"1"`
EpID string `form:"epid" json:"epid"`
SeasonID string `form:"season_id" json:"season_id"`
Category string `form:"category" json:"category"`
Pn int `form:"pn" json:"pn;Min(1)" default:"1"`
Ps int `form:"ps" json:"ps;Min(1)" default:"20"`
}
// TransReq is the request for transcode consulting
type TransReq struct {
Order int `form:"order" default:"1"` // 1=desc,2=asc
EpID int64 `form:"epid"`
SeasonID int64 `form:"season_id"`
Title string `form:"title"`
Category int `form:"category" validate:"min=0,max=5"`
Status string `form:"status"`
Pn int `form:"pn" default:"1"`
}
// TransReply is the response for transList
type TransReply struct {
EpID int64 `json:"epid"`
SeasonID int64 `json:"season_id"`
Category string `json:"category"`
Etitle string `json:"etitle"`
Stitle string `json:"stitle"`
Transcoded int `json:"transcoded"`
ApplyTime string `json:"apply_time"`
MarkTime string `json:"mark_time"`
}
// TransPager is used for return items and pager info
type TransPager struct {
Items []*TransReply `json:"items"`
Page *Page `json:"page"`
CountSn int `json:"count_sn"`
}
// AddEpIDResp is for function addEpID to return success and not exist and invalid values
type AddEpIDResp struct {
Succ []int64
NotExist []int64
Invalids []int64
}
// TableName select watermark list
func (a WaterMarkList) TableName() string {
return "tv_content"
}
//TableName only select watermark one
func (a WaterMarkOne) TableName() string {
return "tv_content"
}