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,39 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"content.go",
"databus.go",
"license.go",
"media_cache.go",
"memcache.go",
"pgc.go",
"playurl.go",
"search.go",
"style.go",
],
importpath = "go-common/app/job/main/tv/model/pgc",
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,28 @@
package pgc
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"`
EPID int `json:"epid"`
CID int `json:"cid"`
MenuID int `json:"menu_id"`
SeasonID int `json:"season_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"`
}
// TableName tv_content
func (c Content) TableName() string {
return "tv_content"
}

View File

@@ -0,0 +1,94 @@
package pgc
// MediaEP is the new structure of ep in Databus Msg
type MediaEP struct {
ID int64 `json:"id"`
EPID int `json:"epid"`
SeasonID int `json:"season_id"`
State int `json:"state"`
Valid int `json:"valid"`
IsDeleted int `json:"is_deleted"`
Title string `json:"title"`
Subtitle string `json:"subtitle"`
Cover string `json:"cover"`
Mark int `json:"mark"`
CID int64 `json:"cid"`
PayStatus int `json:"pay_status"`
}
// MediaSn is the new structure of season in Databus Msg
type MediaSn struct {
ID int64 `json:"id"`
IsDeleted int8 `json:"is_deleted"`
Valid int `json:"valid"`
Check int8 `json:"check"`
Title string `json:"title"`
Cover string `json:"cover"`
Desc string `json:"desc"`
UpInfo string `json:"upinfo"`
Ctime string `json:"ctime"`
Category int `json:"category"`
Area string `json:"area"`
Playtime string `json:"play_time"`
Role string `json:"role"`
Staff string `json:"staff"`
TotalNum int `json:"total_num"`
Style string `json:"style"`
Producer string `json:"producer"`
Version string `json:"version"`
AliasSearch string `json:"alias_search"`
Brief string `json:"brief"`
Status int `json:"status"`
}
// DatabusRes is the result of databus message
type DatabusRes struct {
Action string `json:"action"`
Table string `json:"table"`
}
// DatabusEP is the struct of message for the modification of tv_content
type DatabusEP struct {
New *MediaEP `json:"new"`
Old *MediaEP `json:"old"`
}
// DatabusSeason is the struct of message for the modification of tv_ep_season
type DatabusSeason struct {
Old *MediaSn `json:"old"`
New *MediaSn `json:"new"`
}
// ToSimple returns SimpleSeason struct
func (m *MediaSn) ToSimple() *SimpleSeason {
return &SimpleSeason{
ID: m.ID,
IsDeleted: m.IsDeleted,
Valid: m.Valid,
Check: m.Check,
}
}
// ToSimple returns SimpleEP struct
func (ep *MediaEP) ToSimple() *SimpleEP {
return &SimpleEP{
ID: ep.ID,
IsDeleted: ep.IsDeleted,
Valid: ep.Valid,
State: ep.State,
SeasonID: ep.SeasonID,
EPID: ep.EPID,
NoMark: ep.Mark,
}
}
// ToCMS returns EpCMS
func (ep *MediaEP) ToCMS() *EpCMS {
return &EpCMS{
EPID: int(ep.EPID),
Cover: ep.Cover,
Title: ep.Title,
Subtitle: ep.Subtitle,
PayStatus: ep.PayStatus,
}
}

View File

@@ -0,0 +1,189 @@
package pgc
import "fmt"
const (
_definition = "SD"
)
// License Owner Request message
// License represents the data that we need to send to the license owner for auditing
type License struct {
TId string
InputTime string
Sign string
XMLData *XMLData
}
// XMLData reprensents the main body of xml data sent to license owner
type XMLData struct {
Service *Service `xml:"Service"`
}
// Service body+head
type Service struct {
ID string `xml:"id,attr"`
Head *Head
Body *Body
}
// Head some header info
type Head struct {
TradeID string `xml:"TradeId"`
Date string
Count int
}
// Body Media list
type Body struct {
ProgramSetList *PSList `xml:"programSetList"`
}
// PSList is short for programSetList
type PSList struct {
ProgramSet []*PS `xml:"programSet"`
}
// PS is short for ProgramSet
type PS struct {
ProgramSetID string `xml:"programSetId"`
ProgramSetName string `xml:"programSetName"`
ProgramSetClass string `xml:"programSetClass"`
ProgramSetType string `xml:"programSetType"`
ProgramSetPoster string `xml:"programSetPoster"`
Portrait string `xml:"portrait"` // upper's portrait
Producer string `xml:"producer"` // upper's name
PublishDate string `xml:"publishDate"`
Copyright string `xml:"copyright"`
ProgramCount int `xml:"programCount"`
CREndData string `xml:"cREndDate"`
DefinitionType string `xml:"definitionType"`
CpCode string `xml:"cpCode"`
PayStatus int `xml:"payStatus"`
PrimitiveName string `xml:"primitiveName"`
Alias string `xml:"alias"`
Zone string `xml:"zone"`
LeadingRole string `xml:"leadingRole"`
ProgramSetDesc string `xml:"programSetDesc"`
Staff string `xml:"Staff"`
SubGenre string `xml:"subGenre"`
ProgramList *ProgramList `xml:"programList,omitempty"`
}
// ProgramList contains different EP
type ProgramList struct {
Program []*Program `xml:"program"`
}
// Program represents one EP data
type Program struct {
ProgramID string `xml:"programId"`
ProgramName string `xml:"programName"`
ProgramPoster string `xml:"programPoster"`
ProgramLength int `xml:"programLength"`
PublishDate string `xml:"publishDate"`
IfPreview int `xml:"ifPreview"`
Number string `xml:"number"`
DefinitionType string `xml:"definitionType"`
PlayCount int `xml:"playCount"`
Drm int `xml:"drm"`
ProgramMediaList *PMList `xml:"programMediaList"`
ProgramDesc string `xml:"programDesc"`
}
// PMList is short for programMediaList
type PMList struct {
ProgramMedia []*PMedia `xml:"programMedia"`
}
// PMedia is short for ProgramMedia
type PMedia struct {
MediaID string `xml:"mediaId"`
PlayURL string `xml:"playUrl"`
Definition string `xml:"definition"`
HTMLURL string `xml:"htmlUrl"`
}
// MakePMedia is used to construct PMedia structure
func MakePMedia(prefix, playurl string, cid int64) *PMedia {
return &PMedia{
MediaID: fmt.Sprintf("%s%d", prefix, cid),
PlayURL: playurl,
Definition: _definition,
HTMLURL: playurl,
}
}
// Document is the result structure of license owner's response
type Document struct {
Response *Response
}
// Response is the main content of response
type Response struct {
TradeID string `xml:"TradeId"`
ResponseCode string
ResponseInfo string
ResponseTime string `xml:"responseTime"`
ErrorList *ErrorList
}
// ErrorList is the list of error returned by the license owner
type ErrorList struct {
Error *Error
}
// Error one error body
type Error struct {
ID string `xml:"Id"`
Message string
}
// DelBody is the bodu message of deletion
type DelBody struct {
ProgramList *ProgramList `xml:"programList"`
}
// CreatePMedia creates PMedia struct
func CreatePMedia(prefix string, epid int, url string) *PMedia {
return &PMedia{
MediaID: prefix + fmt.Sprintf("%d", epid),
PlayURL: url,
Definition: "SD",
HTMLURL: url,
}
}
// CreateProgram creates program
func CreateProgram(prefix string, ep *TVEpContent) *Program {
r := &Program{
ProgramID: prefix + fmt.Sprintf("%d", ep.ID),
ProgramName: ep.LongTitle,
ProgramPoster: ep.Cover,
ProgramLength: int(ep.Length * 60),
PublishDate: "1970-01-01",
IfPreview: 0,
Number: ep.Title,
DefinitionType: "SD",
PlayCount: 0,
Drm: ep.PayStatus,
}
r.isPay()
return r
}
// ReqEpLicCall is the request struct for epLicCall function
type ReqEpLicCall struct {
EpLic *License
SID int64
Conts []*Content
}
// isPay .
func (p *Program) isPay() {
if p.Drm == 2 {
p.Drm = 0
} else {
p.Drm = 1
}
}

View File

@@ -0,0 +1,35 @@
package pgc
import "go-common/library/time"
// SeasonCMS defines the elements could be changed from TV CMS side
type SeasonCMS struct {
SeasonID int
Cover string
Desc string
Title string
UpInfo string // season update information
Category int // - cn, jp, movie, tv, documentary
Area string // - cn, jp, others
Playtime time.Time
Role string
Staff string
NewestOrder int // the newest passed ep's order
NewestEPID int // the newest passed ep's ID
NewestNb int // the newest ep's number ( after keyword filter )
TotalNum int
Style string
OriginName string // new fields
Alias string // new fields
PayStatus int // season's pay status, 0||2 = free, others = pay, pass by conf
}
// EpCMS defines the elements could be changed from TV CMS side
type EpCMS struct {
EPID int `json:"epid"`
Cover string `json:"cover"`
Title string `json:"title"`
Subtitle string `json:"subtitle"`
// new fields
PayStatus int `json:"pay_status"`
}

View File

@@ -0,0 +1,20 @@
package pgc
// SimpleEP is the structure of ep in mc
type SimpleEP struct {
ID int64 `json:"id"`
EPID int `json:"epid"`
SeasonID int `json:"season_id"`
State int `json:"state"`
Valid int `json:"valid"`
IsDeleted int `json:"is_deleted"`
NoMark int `json:"no_mark"`
}
// SimpleSeason is the structure of season in mc
type SimpleSeason struct {
ID int64 `json:"id"`
IsDeleted int8 `json:"is_deleted"`
Valid int `json:"valid"`
Check int8 `json:"check"`
}

View File

@@ -0,0 +1,67 @@
package pgc
import (
"go-common/library/time"
)
// TVEpContent reprensents the content table
type TVEpContent struct {
ID int64
SeasonID int64
CID int64
Title string
LongTitle string
Cover string
Length int32
IsDeleted int8
Order int
Ctime time.Time
Mtime time.Time
PayStatus int
}
// TVEpSeason represents the season table
type TVEpSeason struct {
ID int64
OriginName string
Title string
Alias string
Category int8
Desc string
Style string
Area string
PlayTime time.Time
Info int8
State int8
TotalNum int32
Upinfo string
Staff string
Role string
Copyright string
IsDeleted int8
Ctime time.Time
Mtime time.Time
Check int8
AuditTime int
Cover string
Valid int `json:"valid"`
Producer string `json:"producer"`
Version string `json:"version"`
Status int
}
// Offset used for mysql offset
type Offset struct {
Begin int
End int
}
// 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"
}

View File

@@ -0,0 +1,25 @@
package pgc
// 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,32 @@
package pgc
import "go-common/library/time"
// SearPgcCon is used for setting search pgc content
type SearPgcCon struct {
ID int `json:"id"`
Category int `json:"category"`
Cover string `json:"cover"`
Title string `json:"title"`
PlayTime time.Time `json:"pubtime"`
Role string `json:"cv"`
Staff string `json:"staff"`
Desc string `json:"description"`
}
// SearUgcCon is used for setting search ugc content
type SearUgcCon struct {
AID int `json:"id"`
Title string `json:"title"`
Cover string `json:"cover"`
Content string `json:"description"`
Pubtime time.Time `json:"pubtime"`
Typeid int `json:"category"`
}
// SearchSug represents the search suggestion unit
type SearchSug struct {
Term string `json:"term"`
ID int `json:"id"`
Type string `json:"type"`
}

View File

@@ -0,0 +1,21 @@
package pgc
// ParamStyle .
type ParamStyle struct {
Name string `json:"name"`
StyleID int `json:"style_id"`
}
// StyleRes .
type StyleRes struct {
ID int
Style string
Category int
}
// LabelRes .
type LabelRes struct {
Name string
Value int
Category int
}