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,46 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"archive.go",
"contest.go",
"contest_data.go",
"game.go",
"gid_map.go",
"match.go",
"match_active.go",
"match_detail.go",
"match_map.go",
"season.go",
"tag.go",
"tag_map.go",
"team.go",
"team_map.go",
"tree.go",
"year_map.go",
],
importpath = "go-common/app/admin/main/esports/model",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = ["//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"],
)

View File

@ -0,0 +1,111 @@
package model
import (
"fmt"
"strings"
)
const _arcBatchAddSQL = "INSERT INTO es_archives(`aid`) VALUES %s"
// Arc .
type Arc struct {
ID int64 `json:"id"`
Aid int64 `json:"aid"`
IsDeleted int `json:"is_deleted"`
}
// ArcAddParam .
type ArcAddParam struct {
Aids []int64 `form:"aids,split" validate:"dive,gt=1"`
Gids []int64 `form:"gids,split"`
MatchIDs []int64 `form:"match_ids,split"`
TeamIDs []int64 `form:"team_ids,split"`
TagIDs []int64 `form:"tag_ids,split"`
Years []int64 `form:"years,split"`
}
// ArcImportParam .
type ArcImportParam struct {
Aid int64 `form:"aid" validate:"min=1"`
Gids []int64 `form:"gids,split"`
MatchIDs []int64 `form:"match_ids,split"`
TeamIDs []int64 `form:"team_ids,split"`
TagIDs []int64 `form:"tag_ids,split"`
Years []int64 `form:"years,split"`
}
// ArcListParam .
type ArcListParam struct {
Title string `form:"title"`
Aid int64 `form:"aid"`
TypeID int64 `form:"type_id"`
Copyright int `form:"copyright"`
State string `form:"state"`
Pn int `form:"pn"`
Ps int `form:"ps"`
}
// SearchArc .
type SearchArc struct {
Aid int64 `json:"aid"`
TypeID int64 `json:"typeid"`
Title string `json:"title"`
State int64 `json:"state"`
Mid int64 `json:"mid"`
Gid []int64 `json:"gid"`
Tags []int64 `json:"tags"`
Matchs []int64 `json:"matchs"`
Teams []int64 `json:"teams"`
Year []int64 `json:"year"`
}
// ArcResult .
type ArcResult struct {
Aid int64 `json:"aid"`
TypeID int64 `json:"type_id"`
Title string `json:"title"`
State int64 `json:"state"`
Mid int64 `json:"mid"`
Uname string `json:"uname"`
Games []*Game `json:"games"`
Tags []*Tag `json:"tags"`
Matchs []*Match `json:"matchs"`
Teams []*Team `json:"teams"`
Years []int64 `json:"years"`
}
// ArcRelation .
type ArcRelation struct {
AddGids []*GIDMap
UpAddGids []int64
UpDelGids []int64
AddMatchs []*MatchMap
UpAddMatchs []int64
UpDelMatchs []int64
AddTags []*TagMap
UpAddTags []int64
UpDelTags []int64
AddTeams []*TeamMap
UpAddTeams []int64
UpDelTeams []int64
AddYears []*YearMap
UpAddYears []int64
UpDelYears []int64
}
// TableName .
func (a Arc) TableName() string {
return "es_archives"
}
// ArcBatchAddSQL .
func ArcBatchAddSQL(aids []int64) string {
if len(aids) == 0 {
return ""
}
var rowStrings []string
for _, aid := range aids {
rowStrings = append(rowStrings, fmt.Sprintf("(%d)", aid))
}
return fmt.Sprintf(_arcBatchAddSQL, strings.Join(rowStrings, ","))
}

View File

@ -0,0 +1,48 @@
package model
// Contest .
type Contest struct {
ID int64 `json:"id" form:"id"`
GameStage string `json:"game_stage" form:"game_stage" validate:"required"`
Stime int64 `json:"stime" form:"stime"`
Etime int64 `json:"etime" form:"etime"`
HomeID int64 `json:"home_id" form:"home_id"`
AwayID int64 `json:"away_id" form:"away_id"`
HomeScore int64 `json:"home_score" form:"home_score"`
AwayScore int64 `json:"away_score" form:"away_score"`
LiveRoom int64 `json:"live_room" form:"live_room"`
Aid int64 `json:"aid" form:"aid"`
Collection int64 `json:"collection" form:"collection"`
GameState int `json:"game_state" form:"game_state"`
Dic string `json:"dic" form:"dic"`
Status int `json:"status" form:"status"`
Sid int64 `json:"sid" form:"sid" validate:"required"`
Mid int64 `json:"mid" form:"mid" validate:"required"`
Special int `json:"special" form:"special"`
SuccessTeam int64 `json:"success_team" form:"success_team"`
SpecialName string `json:"special_name" form:"special_name"`
SpecialTips string `json:"special_tips" form:"special_tips"`
SpecialImage string `json:"special_image" form:"special_image"`
Playback string `json:"playback" form:"playback"`
CollectionURL string `json:"collection_url" form:"collection_url"`
LiveURL string `json:"live_url" form:"live_url"`
DataType int64 `json:"data_type" form:"data_type"`
Data string `json:"-" form:"data" gorm:"-"`
Adid int64 `json:"-" form:"adid" gorm:"-" validate:"required"`
MatchID int64 `json:"match_id" form:"match_id"`
}
// ContestInfo .
type ContestInfo struct {
*Contest
Games []*Game `json:"games"`
HomeName string `json:"home_name"`
AwayName string `json:"away_name"`
SuccessName string `json:"success_name" form:"success_name"`
Data []*ContestData `json:"data"`
}
// TableName es_contests
func (c Contest) TableName() string {
return "es_contests"
}

View File

@ -0,0 +1,56 @@
package model
import (
"fmt"
"strings"
"go-common/library/xstr"
)
const (
_cDataInsertSQL = "INSERT INTO es_contests_data(cid,url,point_data) VALUES %s"
_cDataEditSQL = "UPDATE es_contests_data SET url = CASE %s END,point_data = CASE %s END WHERE id IN (%s)"
)
// ContestData .
type ContestData struct {
ID int64 `json:"id"`
CID int64 `json:"cid" gorm:"column:cid"`
URL string `json:"url"`
PointData int `json:"point_data"`
IsDeleted int `json:"is_deleted"`
}
// TableName es_contests_data.
func (t ContestData) TableName() string {
return "es_contests_data"
}
// BatchAddCDataSQL .
func BatchAddCDataSQL(cID int64, data []*ContestData) string {
if len(data) == 0 {
return ""
}
var rowStrings []string
for _, v := range data {
rowStrings = append(rowStrings, fmt.Sprintf("(%d,'%s',%d)", cID, v.URL, v.PointData))
}
return fmt.Sprintf(_cDataInsertSQL, strings.Join(rowStrings, ","))
}
// BatchEditCDataSQL .
func BatchEditCDataSQL(cDatas []*ContestData) string {
if len(cDatas) == 0 {
return ""
}
var (
urlStr, pDataStr string
ids []int64
)
for _, module := range cDatas {
urlStr = fmt.Sprintf("%s WHEN id = %d THEN '%s'", urlStr, module.ID, module.URL)
pDataStr = fmt.Sprintf("%s WHEN id = %d THEN '%d'", pDataStr, module.ID, module.PointData)
ids = append(ids, module.ID)
}
return fmt.Sprintf(_cDataEditSQL, urlStr, pDataStr, xstr.JoinInts(ids))
}

View File

@ -0,0 +1,50 @@
package model
// game play and type
const (
PlatPc = 1
PlatMobile = 2
TypeMOBA = 1
TypeACT = 2
TypeFPS = 3
TypeFTG = 4
TypeRTS = 5
TypeRPG = 6
)
// game plat map and type map
var (
PlatMap = map[int]int{
PlatPc: PlatPc,
PlatMobile: PlatMobile,
}
TypeMap = map[int]int{
TypeMOBA: TypeMOBA,
TypeACT: TypeACT,
TypeFPS: TypeFPS,
TypeFTG: TypeFTG,
TypeRTS: TypeRTS,
TypeRPG: TypeRPG,
}
)
// Game .
type Game struct {
ID int64 `json:"id" form:"id"`
Title string `json:"title" form:"title" validate:"required"`
SubTitle string `json:"sub_title" form:"sub_title"`
ETitle string `json:"e_title" form:"e_title"`
Plat int `json:"plat" form:"plat"`
Type int `json:"type" form:"type"`
Logo string `json:"logo" form:"logo" validate:"required"`
Publisher string `json:"publisher" form:"publisher"`
Operations string `json:"operations" form:"operations"`
PbTime int64 `json:"pb_time" form:"pb_time"`
Dic string `json:"dic" form:"dic"`
Status int `json:"status" form:"status"`
}
// TableName es_game
func (g Game) TableName() string {
return "es_games"
}

View File

@ -0,0 +1,42 @@
package model
import (
"fmt"
"strings"
)
// gid map
const (
TypeMatch = 1
TypeSeason = 2
TypeContest = 3
TypeTeam = 4
TypeArc = 5
_gidMapInsertSQL = "INSERT INTO es_gid_map(`type`,`oid`,`gid`) VALUES %s"
)
// GIDMap .
type GIDMap struct {
ID int64 `json:"id"`
Type int `json:"type"`
Oid int64 `json:"oid"`
Gid int64 `json:"gid"`
IsDeleted int `json:"is_deleted"`
}
// TableName .
func (g GIDMap) TableName() string {
return "es_gid_map"
}
// GidBatchAddSQL .
func GidBatchAddSQL(gidMap []*GIDMap) string {
if len(gidMap) == 0 {
return ""
}
var rowStrings []string
for _, v := range gidMap {
rowStrings = append(rowStrings, fmt.Sprintf("(%d,%d,%d)", v.Type, v.Oid, v.Gid))
}
return fmt.Sprintf(_gidMapInsertSQL, strings.Join(rowStrings, ","))
}

View File

@ -0,0 +1,25 @@
package model
// Match .
type Match struct {
ID int64 `json:"id" form:"id"`
Title string `json:"title" form:"title"`
SubTitle string `json:"sub_title" form:"sub_title"`
CYear int `json:"c_year" form:"c_year"`
Sponsor string `json:"sponsor" form:"sponsor"`
Logo string `json:"logo" form:"logo" validate:"required"`
Dic string `json:"dic" form:"dic"`
Status int `json:"status" form:"status"`
Rank int `json:"rank" form:"rank" validate:"min=0,max=99"`
}
// MatchInfo .
type MatchInfo struct {
*Match
Games []*Game `json:"games"`
}
// TableName .
func (m Match) TableName() string {
return "es_matchs"
}

View File

@ -0,0 +1,100 @@
package model
import (
"fmt"
"strings"
"go-common/library/xstr"
)
const (
_moduleInsertSQL = "INSERT INTO es_matchs_module(ma_id,name,oids) VALUES %s"
_moduleEditSQL = "UPDATE es_matchs_module SET name = CASE %s END,oids = CASE %s END WHERE id IN (%s)"
)
// ParamMA .
type ParamMA struct {
MatchActive
Modules string `json:"-" form:"modules"`
Adid int64 `json:"-" form:"adid" validate:"required"`
}
// MatchActive .
type MatchActive struct {
ID int64 `json:"id" form:"id"`
Sid int64 `json:"sid" form:"sid" validate:"required"`
Mid int64 `json:"mid" form:"mid" validate:"required"`
Background string `json:"background" form:"background"`
BackColor string `json:"back_color" form:"back_color"`
ColorStep string `json:"color_step" form:"color_step"`
LiveID int64 `json:"live_id" form:"live_id" validate:"required"`
Intr string `json:"intr" form:"intr"`
Focus string `json:"focus" form:"focus"`
URL string `json:"url" form:"url"`
Status int `json:"status" form:"status"`
H5Background string `json:"h5_background" form:"h5_background"`
H5BackColor string `json:"h5_back_color" form:"h5_back_color"`
H5Focus string `json:"h5_focus" form:"h5_focus"`
H5URL string `json:"h5_url" form:"h5_url"`
IntrLogo string `json:"intr_logo" form:"intr_logo"`
IntrTitle string `json:"intr_title" form:"intr_title"`
IntrText string `json:"intr_text" form:"intr_text"`
}
// Module .
type Module struct {
ID int64 `json:"id"`
MaID int64 `json:"ma_id"`
Name string `json:"name"`
Oids string `json:"oids"`
Status int `json:"-" form:"status"`
}
// MatchModule .
type MatchModule struct {
*MatchActive
Modules []*Module `json:"modules"`
MatchTitle string `json:"match_title"`
MatchSubTitle string `json:"match_sub_title"`
SeasonTitle string `json:"season_title"`
SeasonSubTitle string `json:"season_sub_title"`
}
// TableName es_matchs_module.
func (t Module) TableName() string {
return "es_matchs_module"
}
// TableName es_matchs_active.
func (t MatchActive) TableName() string {
return "es_matchs_active"
}
// BatchAddModuleSQL .
func BatchAddModuleSQL(maID int64, data []*Module) string {
if len(data) == 0 {
return ""
}
var rowStrings []string
for _, v := range data {
rowStrings = append(rowStrings, fmt.Sprintf("(%d,'%s','%s')", maID, v.Name, v.Oids))
}
return fmt.Sprintf(_moduleInsertSQL, strings.Join(rowStrings, ","))
}
// BatchEditModuleSQL .
func BatchEditModuleSQL(mapModuel []*Module) string {
if len(mapModuel) == 0 {
return ""
}
var (
nameStr, oidsStr string
ids []int64
)
for _, module := range mapModuel {
nameStr = fmt.Sprintf("%s WHEN id = %d THEN '%s'", nameStr, module.ID, module.Name)
oidsStr = fmt.Sprintf("%s WHEN id = %d THEN '%s'", oidsStr, module.ID, module.Oids)
ids = append(ids, module.ID)
}
return fmt.Sprintf(_moduleEditSQL, nameStr, oidsStr, xstr.JoinInts(ids))
}

View File

@ -0,0 +1,21 @@
package model
// MatchDetail .
type MatchDetail struct {
ID int64 `json:"id" form:"id"`
MaID int64 `json:"ma_id" form:"ma_id" validate:"required"`
GameType int64 `json:"game_type" form:"game_type" validate:"required"`
Stime int64 `json:"stime" form:"stime" validate:"required"`
Etime int64 `json:"etime" form:"etime" validate:"required"`
GameStage string `json:"game_stage" form:"game_stage" validate:"required"`
KnockoutType int64 `json:"knockout_type" form:"knockout_type"`
WinnerType int64 `json:"winner_type" form:"winner_type"`
ScoreID int64 `json:"score_id" form:"score_id"`
Status int `json:"status" form:"status"`
Online int `json:"online" form:"online"`
}
// TableName .
func (t MatchDetail) TableName() string {
return "es_matchs_detail"
}

View File

@ -0,0 +1,33 @@
package model
import (
"fmt"
"strings"
)
const _matchMapInsertSQL = "INSERT INTO es_matchs_map(mid,aid) VALUES %s"
// MatchMap .
type MatchMap struct {
ID int64 `json:"id"`
Mid int64 `json:"mid"`
Aid int64 `json:"aid"`
IsDeleted int `json:"is_deleted"`
}
// TableName es_year_map.
func (m MatchMap) TableName() string {
return "es_matchs_map"
}
// BatchAddMachMapSQL .
func BatchAddMachMapSQL(data []*MatchMap) string {
if len(data) == 0 {
return ""
}
var rowStrings []string
for _, v := range data {
rowStrings = append(rowStrings, fmt.Sprintf("(%d,%d)", v.Mid, v.Aid))
}
return fmt.Sprintf(_matchMapInsertSQL, strings.Join(rowStrings, ","))
}

View File

@ -0,0 +1,31 @@
package model
// Season .
type Season struct {
ID int64 `json:"id" form:"id"`
Mid int64 `json:"mid" form:"mid" validate:"required"`
Title string `json:"title" form:"title" validate:"required"`
SubTitle string `json:"sub_title" form:"sub_title"`
Stime int64 `json:"stime" form:"stime"`
Etime int64 `json:"etime" form:"etime"`
Sponsor string `json:"sponsor" form:"sponsor"`
Logo string `json:"logo" form:"logo" validate:"required"`
Dic string `json:"dic" form:"dic"`
Status int `json:"status" form:"is_deleted"`
IsApp int `json:"is_app" form:"is_app"`
Rank int `json:"rank" form:"rank" validate:"min=0,max=10"`
URL string `json:"url" form:"url"`
DataFocus string `json:"data_focus" form:"data_focus"`
FocusURL string `json:"focus_url" form:"focus_url"`
}
// SeasonInfo .
type SeasonInfo struct {
*Season
Games []*Game `json:"games"`
}
// TableName .
func (s Season) TableName() string {
return "es_seasons"
}

View File

@ -0,0 +1,13 @@
package model
// Tag .
type Tag struct {
ID int64 `json:"id" form:"id"`
Name string `json:"name" form:"name" validate:"required"`
Status int `json:"status" form:"status"`
}
// TableName .
func (t Tag) TableName() string {
return "es_tags"
}

View File

@ -0,0 +1,33 @@
package model
import (
"fmt"
"strings"
)
const _tagMapInsertSQL = "INSERT INTO es_tags_map(tid,aid) VALUES %s"
// TagMap .
type TagMap struct {
ID int64 `json:"id"`
Tid int64 `json:"tid"`
Aid int64 `json:"aid"`
IsDeleted int `json:"is_deleted"`
}
// TableName es_year_map.
func (t TagMap) TableName() string {
return "es_tags_map"
}
// BatchAddTagMapSQL .
func BatchAddTagMapSQL(data []*TagMap) string {
if len(data) == 0 {
return ""
}
var rowStrings []string
for _, v := range data {
rowStrings = append(rowStrings, fmt.Sprintf("(%d,%d)", v.Tid, v.Aid))
}
return fmt.Sprintf(_tagMapInsertSQL, strings.Join(rowStrings, ","))
}

View File

@ -0,0 +1,27 @@
package model
// Team .
type Team struct {
ID int64 `json:"id" form:"id"`
Title string `json:"title" form:"title" validate:"required"`
SubTitle string `json:"sub_title" form:"sub_title"`
ETitle string `json:"e_title" form:"e_title"`
CreateTime int64 `json:"create_time" form:"create_time"`
Area string `json:"area" form:"area"`
Logo string `json:"logo" form:"logo" validate:"required"`
UID int64 `json:"uid" form:"uid" gorm:"column:uid"`
Members string `json:"members" form:"members"`
Dic string `json:"dic" form:"dic"`
IsDeleted int `json:"is_deleted" form:"is_deleted"`
}
// TeamInfo .
type TeamInfo struct {
*Team
Games []*Game `json:"games"`
}
// TableName .
func (t Team) TableName() string {
return "es_teams"
}

View File

@ -0,0 +1,33 @@
package model
import (
"fmt"
"strings"
)
const _teamMapInsertSQL = "INSERT INTO es_teams_map(tid,aid) VALUES %s"
// TeamMap .
type TeamMap struct {
ID int64 `json:"id"`
Tid int64 `json:"tid"`
Aid int64 `json:"aid"`
IsDeleted int `json:"is_deleted"`
}
// TableName es_teams_map.
func (t TeamMap) TableName() string {
return "es_teams_map"
}
// BatchAddTeamMapSQL .
func BatchAddTeamMapSQL(data []*TeamMap) string {
if len(data) == 0 {
return ""
}
var rowStrings []string
for _, v := range data {
rowStrings = append(rowStrings, fmt.Sprintf("(%d,%d)", v.Tid, v.Aid))
}
return fmt.Sprintf(_teamMapInsertSQL, strings.Join(rowStrings, ","))
}

View File

@ -0,0 +1,71 @@
package model
import (
"fmt"
"go-common/library/xstr"
)
const _treeEditSQL = "UPDATE es_matchs_tree SET mid = CASE %s END WHERE id IN (%s)"
// TreeListParam .
type TreeListParam struct {
MadID int64 `form:"mad_id" validate:"required"`
}
// TreeEditParam .
type TreeEditParam struct {
MadID int64 `form:"mad_id" validate:"required"`
Nodes string `form:"nodes" validate:"required"`
}
// TreeDelParam .
type TreeDelParam struct {
MadID int64 `form:"mad_id" validate:"required"`
IDs string `form:"ids" validate:"required"`
}
// Tree .
type Tree struct {
ID int64 `json:"id" form:"id"`
MaID int64 `json:"ma_id,omitempty" form:"ma_id" validate:"required"`
MadID int64 `json:"mad_id,omitempty" form:"mad_id" validate:"required"`
Pid int64 `json:"pid" form:"pid"`
RootID int64 `json:"root_id" form:"root_id"`
GameRank int64 `json:"game_rank,omitempty" form:"game_rank" validate:"required"`
Mid int64 `json:"mid" form:"mid"`
IsDeleted int `json:"is_deleted,omitempty" form:"is_deleted"`
}
// TreeList .
type TreeList struct {
*Tree
*ContestInfo
}
// TreeDetailList .
type TreeDetailList struct {
Detail *MatchDetail `json:"detail"`
Tree [][]*TreeList `json:"tree"`
}
// TableName .
func (t Tree) TableName() string {
return "es_matchs_tree"
}
// BatchEditTreeSQL .
func BatchEditTreeSQL(nodes map[int64]int64) string {
if len(nodes) == 0 {
return ""
}
var (
caseStr string
ids []int64
)
for id, mid := range nodes {
caseStr = fmt.Sprintf("%s WHEN id = %d THEN %d", caseStr, id, mid)
ids = append(ids, id)
}
return fmt.Sprintf(_treeEditSQL, caseStr, xstr.JoinInts(ids))
}

View File

@ -0,0 +1,33 @@
package model
import (
"fmt"
"strings"
)
const _yearMapInsertSQL = "INSERT INTO es_year_map(year,aid) VALUES %s"
// YearMap .
type YearMap struct {
ID int64 `json:"id"`
Year int64 `json:"year"`
Aid int64 `json:"aid"`
IsDeleted int `json:"is_deleted"`
}
// TableName es_year_map.
func (y YearMap) TableName() string {
return "es_year_map"
}
// BatchAddYearMapSQL .
func BatchAddYearMapSQL(data []*YearMap) string {
if len(data) == 0 {
return ""
}
var rowStrings []string
for _, v := range data {
rowStrings = append(rowStrings, fmt.Sprintf("(%d,%d)", v.Year, v.Aid))
}
return fmt.Sprintf(_yearMapInsertSQL, strings.Join(rowStrings, ","))
}