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 = ["const.go"],
importpath = "go-common/app/interface/main/app-resource/model",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = ["//app/interface/main/app-resource/model/tab:go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/interface/main/app-resource/model/abtest:all-srcs",
"//app/interface/main/app-resource/model/broadcast:all-srcs",
"//app/interface/main/app-resource/model/domain:all-srcs",
"//app/interface/main/app-resource/model/experiment:all-srcs",
"//app/interface/main/app-resource/model/guide:all-srcs",
"//app/interface/main/app-resource/model/module:all-srcs",
"//app/interface/main/app-resource/model/notice:all-srcs",
"//app/interface/main/app-resource/model/param:all-srcs",
"//app/interface/main/app-resource/model/plugin:all-srcs",
"//app/interface/main/app-resource/model/show:all-srcs",
"//app/interface/main/app-resource/model/sidebar:all-srcs",
"//app/interface/main/app-resource/model/splash:all-srcs",
"//app/interface/main/app-resource/model/static:all-srcs",
"//app/interface/main/app-resource/model/tab:all-srcs",
"//app/interface/main/app-resource/model/version:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,29 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["abtest.go"],
importpath = "go-common/app/interface/main/app-resource/model/abtest",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = ["//app/service/main/resource/model: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,15 @@
package abtest
import (
resource "go-common/app/service/main/resource/model"
)
type List struct {
ID int64 `json:"group_id,lomitempty"`
Name string `json:"group_name,omitempty"`
}
func (l *List) ListChange(r *resource.AbTest) {
l.ID = r.ID
l.Name = r.Name
}

View File

@@ -0,0 +1,29 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["broadcast.go"],
importpath = "go-common/app/interface/main/app-resource/model/broadcast",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = ["//app/service/main/broadcast/api/grpc/v1: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,43 @@
package broadcast
import (
wardensvr "go-common/app/service/main/broadcast/api/grpc/v1"
)
type ServerListReply struct {
Domain string `json:"domain,omitempty"`
TCPPort int32 `json:"tcp_port,omitempty"`
WsPort int32 `json:"ws_port,omitempty"`
WssPort int32 `json:"wss_port,omitempty"`
Heartbeat int32 `json:"heartbeat,omitempty"`
HeartbeatMax int32 `json:"heartbeat_max,omitempty"`
Nodes []string `json:"nodes,omitempty"`
Backoff *Backoff `json:"backoff,omitempty"`
}
type Backoff struct {
MaxDelay int32 `json:"max_delay,omitempty"`
BaseDelay int32 `json:"base_delay,omitempty"`
Factor float32 `json:"factor,omitempty"`
Jitter float32 `json:"jitter,omitempty"`
}
func (l *ServerListReply) ServerListChange(w *wardensvr.ServerListReply) {
l.Domain = w.Domain
l.TCPPort = w.TcpPort
l.WsPort = w.WsPort
l.WssPort = w.WssPort
l.Heartbeat = w.Heartbeat
l.HeartbeatMax = w.HeartbeatMax
if len(w.Nodes) > 0 {
l.Nodes = w.Nodes
}
if w.Backoff != nil {
l.Backoff = &Backoff{
MaxDelay: w.Backoff.MaxDelay,
BaseDelay: w.Backoff.BaseDelay,
Factor: w.Backoff.Factor,
Jitter: w.Backoff.Jitter,
}
}
}

View File

@@ -0,0 +1,201 @@
package model
import (
"fmt"
"strings"
"go-common/app/interface/main/app-resource/model/tab"
)
const (
// PlatAndroid is int8 for android.
PlatAndroid = int8(0)
// PlatIPhone is int8 for iphone.
PlatIPhone = int8(1)
// PlatIPad is int8 for ipad.
PlatIPad = int8(2)
// PlatWPhone is int8 for wphone.
PlatWPhone = int8(3)
// PlatAndroidG is int8 for Android Global.
PlatAndroidG = int8(4)
// PlatIPhoneI is int8 for Iphone Global.
PlatIPhoneI = int8(5)
// PlatIPadI is int8 for IPAD Global.
PlatIPadI = int8(6)
// PlatAndroidTV is int8 for AndroidTV Global.
PlatAndroidTV = int8(7)
// PlatAndroidI is int8 for Android Global.
PlatAndroidI = int8(8)
// PlatAndroidB is int8 for Android Blue.
PlatAndroidB = int8(9)
// PlatIPhoneB is int8 for Ios Blue
PlatIPhoneB = int8(10)
// PlatBilistudio is int8 for bilistudio
PlatBilistudio = int8(11)
// PlatAndroidTVYST is int8 for AndroidTV_YST Global.
PlatAndroidTVYST = int8(12)
GotoAv = "av"
GotoWeb = "web"
GotoBangumi = "bangumi"
GotoSp = "sp"
GotoLive = "live"
GotoGame = "game"
GotoPegasusTab = "pegasus"
)
var (
PegasusHandler = func(m *tab.Menu) func(uri string) string {
return func(uri string) string {
if m == nil {
return uri
}
if m.Name != "" {
return fmt.Sprintf("%s?name=%s", uri, m.Name)
}
return uri
}
}
)
// Plat return plat by platStr or mobiApp
func Plat(mobiApp, device string) int8 {
switch mobiApp {
case "iphone":
if device == "pad" {
return PlatIPad
}
return PlatIPhone
case "white":
return PlatIPhone
case "ipad":
return PlatIPad
case "android":
return PlatAndroid
case "win":
return PlatWPhone
case "android_G":
return PlatAndroidG
case "android_i":
return PlatAndroidI
case "android_b":
return PlatAndroidB
case "iphone_i":
if device == "pad" {
return PlatIPadI
}
return PlatIPhoneI
case "ipad_i":
return PlatIPadI
case "iphone_b":
return PlatIPhoneB
case "android_tv":
return PlatAndroidTV
case "android_tv_yst":
return PlatAndroidTVYST
case "bilistudio":
return PlatBilistudio
case "biliLink":
return PlatIPhone
}
return PlatIPhone
}
// InvalidBuild check source build is not allow by config build and condition.
// eg: when condition is gt, means srcBuild must gt cfgBuild, otherwise is invalid srcBuild.
func InvalidBuild(srcBuild, cfgBuild int, cfgCond string) bool {
if cfgBuild != 0 && cfgCond != "" {
switch cfgCond {
case "gt":
if cfgBuild >= srcBuild {
return true
}
case "lt":
if cfgBuild <= srcBuild {
return true
}
case "eq":
if cfgBuild != srcBuild {
return true
}
case "ne":
if cfgBuild == srcBuild {
return true
}
}
}
return false
}
// IsAndroid check plat is android or ipad.
func IsAndroid(plat int8) bool {
return plat == PlatAndroid || plat == PlatAndroidG || plat == PlatAndroidB || plat == PlatAndroidI ||
plat == PlatBilistudio || plat == PlatAndroidTV || plat == PlatAndroidTVYST
}
// IsIOS check plat is iphone or ipad.
func IsIOS(plat int8) bool {
return plat == PlatIPad || plat == PlatIPhone || plat == PlatIPadI || plat == PlatIPhoneI || plat == PlatIPhoneB
}
// FillURI deal app schema.
func FillURI(gt, param string, f func(uri string) string) (uri string) {
if param == "" {
return
}
switch gt {
case GotoAv, "":
uri = "bilibili://video/" + param
case GotoLive:
uri = "bilibili://live/" + param
case GotoBangumi:
uri = "bilibili://bangumi/season/" + param
case GotoGame:
uri = "bilibili://game/" + param
case GotoSp:
uri = "bilibili://splist/" + param
case GotoWeb:
uri = param
case GotoPegasusTab:
uri = "bilibili://pegasus/op/" + param
}
if f != nil {
uri = f(uri)
}
return
}
// MobiAPPBuleChange
func MobiAPPBuleChange(mobiApp string) string {
switch mobiApp {
case "android_b":
return "android"
case "iphone_b":
return "iphone"
}
return mobiApp
}
func URLHTTPS(uri string) (url string) {
if strings.HasPrefix(uri, "http://") {
url = "https://" + uri[7:]
} else {
url = uri
}
return
}
// IsOverseas is overseas
func IsOverseas(plat int8) bool {
return plat == PlatAndroidI || plat == PlatIPhoneI || plat == PlatIPadI
}
func PlatAPPBuleChange(plat int8) int8 {
switch plat {
case PlatAndroidB:
return PlatAndroid
case PlatIPhoneB:
return PlatIPhone
}
return plat
}

View File

@@ -0,0 +1,28 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["domain.go"],
importpath = "go-common/app/interface/main/app-resource/model/domain",
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,7 @@
package domain
// Domain
type Domain struct {
Domains []string `json:"domains"`
ImageDomains []string `json:"image_domains"`
}

View File

@@ -0,0 +1,28 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["experiment.go"],
importpath = "go-common/app/interface/main/app-resource/model/experiment",
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,21 @@
package experiment
type Experiment struct {
ID int64 `json:"id,omitempty"`
Plat int8 `json:"-"`
Name string `json:"name,omitempty"`
Strategy string `json:"strategy,omitempty"`
Desc string `json:"desc,omitempty"`
TrafficGroup string `json:"traffic_group,omitempty"`
Limit []*Limit `json:"-"`
}
type Limit struct {
ExperimentID int64 `json:"-"`
Build int `json:"-"`
Condition string `json:"-"`
}
type ABTestV2 struct {
AutoPlay int `json:"autoplay"`
}

View File

@@ -0,0 +1,28 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["guide.go"],
importpath = "go-common/app/interface/main/app-resource/model/guide",
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,11 @@
package guide
type Interest struct {
ID int `json:"-"`
Name string `json:"name"`
}
type InterestTM struct {
Interests []*Interest `json:"interests,omitempty"`
FeedType int `json:"feed_type"`
}

View File

@@ -0,0 +1,29 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["module.go"],
importpath = "go-common/app/interface/main/app-resource/model/module",
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,66 @@
package module
import (
xtime "go-common/library/time"
)
const (
Total = 0
Incremental = 1
EnvRelease = "1"
EnvTest = "2"
EnvDefault = "3"
NotValid = int8(0)
Valid = int8(1)
)
type ResourcePool struct {
ID int `json:"-"`
Name string `json:"name"`
Resources []*Resource `json:"resources,omitempty"`
}
type Resource struct {
ID int `json:"-"`
ResID int `json:"-"`
Name string `json:"name"`
Compresstype int `json:"compresstype"`
Type string `json:"type"`
URL string `json:"url"`
MD5 string `json:"md5"`
TotalMD5 string `json:"total_md5"`
Size int `json:"size"`
Version int `json:"ver"`
Increment int `json:"increment"`
FromVer int `json:"-"`
Condition *Condition `json:"-"`
Level int `json:"level,omitempty"`
IsWifi int8 `json:"is_wifi"`
}
type Condition struct {
ID int `json:"-"`
ResID int `json:"-"`
STime xtime.Time `json:"stime"`
ETime xtime.Time `json:"etime"`
Valid int8 `json:"valid"`
ValidTest int8 `json:"valid_test"`
Default int `json:"-"`
Columns map[string][]*Column `json:"columns"`
IsWifi int8 `json:"-"`
}
type Column struct {
Condition string `json:"condition"`
Value string `json:"value"`
}
type Versions struct {
PoolName string `json:"name"`
Resource []struct {
ResourceName string `json:"name"`
Version interface{} `json:"ver"`
} `json:"resources"`
}

View File

@@ -0,0 +1,29 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["notice.go"],
importpath = "go-common/app/interface/main/app-resource/model/notice",
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,18 @@
package notice
import xtime "go-common/library/time"
// Notice is notice type.
type Notice struct {
ID int `json:"id,omitempty"`
Title string `json:"title,omitempty"`
Content string `json:"content,omitempty"`
Start xtime.Time `json:"start_time,omitempty"`
End xtime.Time `json:"end_time,omitempty"`
URI string `json:"uri,omitempty"`
Type int `json:"-"`
Plat int8 `json:"-"`
Build int `json:"-"`
Condition string `json:"-"`
Area string `json:"-"`
}

View File

@@ -0,0 +1,29 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["param.go"],
importpath = "go-common/app/interface/main/app-resource/model/param",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = ["//app/interface/main/app-resource/model: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,24 @@
package param
import "go-common/app/interface/main/app-resource/model"
// Param struct
type Param struct {
Name string `json:"-"`
Value string `json:"-"`
Plat int8 `json:"-"`
Build int `json:"-"`
Condition string `json:"-"`
}
// Change func
func (p *Param) Change() {
switch p.Plat {
case 10:
p.Plat = model.PlatAndroidB
case 11:
p.Plat = model.PlatAndroidTVYST
case 12:
p.Plat = model.PlatIPhoneB
}
}

View File

@@ -0,0 +1,28 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["plugin.go"],
importpath = "go-common/app/interface/main/app-resource/model/plugin",
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,27 @@
package plugin
type Plugin struct {
Name string `json:"name"`
Package string `json:"package"`
Policy int8 `json:"policy"`
VerCode int64 `json:"ver_code"`
VerName string `json:"ver_name"`
Size int64 `json:"size"`
MD5 string `json:"md5"`
URL string `json:"url"`
Enable bool `json:"enable"`
Force bool `json:"force"`
Clear bool `json:"clear"`
MinBuild int `json:"min_build"`
MaxBuild int `json:"max_build"`
BaseCode int `json:"base_code"`
BaseName string `json:"base_name"`
Desc string `json:"desc"`
Coverage int `json:"-"`
}
type Plugins []*Plugin
func (ps Plugins) Len() int { return len(ps) }
func (ps Plugins) Less(i, j int) bool { return ps[i].VerCode > ps[j].VerCode }
func (ps Plugins) Swap(i, j int) { ps[i], ps[j] = ps[j], ps[i] }

View File

@@ -0,0 +1,33 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["show.go"],
importpath = "go-common/app/interface/main/app-resource/model/show",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/interface/main/app-resource/model:go_default_library",
"//app/interface/main/app-resource/model/tab:go_default_library",
"//app/service/main/resource/model: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,83 @@
package show
import (
"go-common/app/interface/main/app-resource/model"
"go-common/app/interface/main/app-resource/model/tab"
resource "go-common/app/service/main/resource/model"
"strconv"
)
type Tab struct {
ID int64 `json:"id,omitempty"`
Icon string `json:"icon,omitempty"`
IconSelected string `json:"icon_selected,omitempty"`
Name string `json:"name,omitempty"`
URI string `json:"uri,omitempty"`
TabID string `json:"tab_id,omitempty"`
Color string `json:"color,omitempty"`
Pos int `json:"pos,omitempty"`
DefaultSelected int `json:"default_selected,omitempty"`
Module int `json:"-"`
ModuleStr string `json:"-"`
Plat int8 `json:"-"`
Group string `json:"-"`
Language string `json:"-"`
}
type Limit struct {
ID int64 `json:"-"`
Build int `json:"-"`
Condition string `json:"-"`
}
func (t *Tab) TabChange(rsb *resource.SideBar, abtest map[string]string, defaultTab map[string]*Tab) (ok bool) {
var (
_top = 10
_tab = 8
_bottom = 9
)
t.ID = rsb.ID
t.Icon = rsb.Logo
t.IconSelected = rsb.LogoSelected
t.Name = rsb.Name
t.URI = rsb.Param
t.Module = rsb.Module
t.Plat = rsb.Plat
t.Language = rsb.Language
switch t.Module {
case _top:
t.ModuleStr = "top"
case _tab:
t.ModuleStr = "tab"
t.Icon = ""
t.IconSelected = ""
case _bottom:
t.ModuleStr = "bottom"
default:
return false
}
if len(abtest) > 0 {
if groups, ok := abtest[t.URI]; ok {
t.Group = groups
}
}
if len(defaultTab) > 0 {
if dt, ok := defaultTab[t.URI]; ok && dt != nil {
t.DefaultSelected = dt.DefaultSelected
t.TabID = dt.TabID
}
if rsb.TabID != "" {
t.TabID = rsb.TabID
}
}
return true
}
func (t *Tab) TabMenuChange(m *tab.Menu) {
t.TabID = strconv.FormatInt(m.TabID, 10)
t.Name = m.Name
t.Color = m.Color
t.ID = m.ID
t.ModuleStr = "tab"
t.URI = model.FillURI(model.GotoPegasusTab, strconv.FormatInt(t.ID, 10), model.PegasusHandler(m))
}

View File

@@ -0,0 +1,32 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["sidebar.go"],
importpath = "go-common/app/interface/main/app-resource/model/sidebar",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/resource/model: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,48 @@
package sidebar
import (
resource "go-common/app/service/main/resource/model"
"go-common/library/time"
)
type SideBar struct {
ID int64 `json:"id,omitempty"`
Tip int `json:"tip,omitempty"`
Rank int `json:"rank,omitempty"`
Logo string `json:"logo,omitempty"`
LogoWhite string `json:"logo_white,omitempty"`
Name string `json:"name,omitempty"`
Param string `json:"param,omitempty"`
Module int `json:"module,omitempty"`
Plat int8 `json:"-"`
Build int `json:"-"`
Conditions string `json:"-"`
OnlineTime time.Time `json:"online_time"`
NeedLogin int8 `json:"-"`
WhiteURL string `json:"-"`
Language string `json:"-"`
}
type Limit struct {
ID int64 `json:"-"`
Build int `json:"-"`
Condition string `json:"-"`
}
func (s *SideBar) Change(rsb *resource.SideBar) {
s.ID = rsb.ID
s.Tip = rsb.Tip
s.Rank = rsb.Rank
s.Logo = rsb.Logo
s.LogoWhite = rsb.LogoWhite
s.Name = rsb.Name
s.Param = rsb.Param
s.Module = rsb.Module
s.Plat = rsb.Plat
s.Build = rsb.Build
s.Conditions = rsb.Conditions
s.OnlineTime = rsb.OnlineTime
s.NeedLogin = rsb.NeedLogin
s.WhiteURL = rsb.WhiteURL
s.Language = rsb.Language
}

View File

@@ -0,0 +1,32 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["splash.go"],
importpath = "go-common/app/interface/main/app-resource/model/splash",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/interface/main/app-resource/model: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,126 @@
package splash
import (
"encoding/json"
"go-common/app/interface/main/app-resource/model"
xtime "go-common/library/time"
)
// Splash is splash type.
type Splash struct {
ID int64 `json:"id"`
Type int8 `json:"type"`
Animate int8 `json:"animate"`
Duration int16 `json:"duration"`
Start xtime.Time `json:"start_time,omitempty"`
End xtime.Time `json:"end_time,omitempty"`
Image string `json:"thumb"`
Hash string `json:"hash"`
Times int16 `json:"times"`
Skip int8 `json:"skip"`
URI string `json:"uri"`
Area string `json:"-"`
Plat int8 `json:"-"`
Goto string `json:"-"`
Param string `json:"-"`
Width int `json:"-"`
Height int `json:"-"`
Build int `json:"-"`
Condition string `json:"-"`
Operate int `json:"-"`
NoPreview int `json:"-"`
// bitrhday
BirthStart string `json:"start_date,omitempty"`
BirthEnd string `json:"end_date,omitempty"`
BirthStartMonth string `json:"-"`
BirthEndMonth string `json:"-"`
}
type List struct {
ID int64 `json:"id"`
Type int8 `json:"type"`
CardType int8 `json:"card_type"`
Duration int16 `json:"duration"`
Start xtime.Time `json:"begin_time,omitempty"`
End xtime.Time `json:"end_time,omitempty"`
Image string `json:"thumb"`
Hash string `json:"hash"`
LogoURL string `json:"logo_url"`
LogoHash string `json:"logo_hash"`
Skip int8 `json:"skip"`
URI string `json:"uri"`
VideoURL string `json:"video_url,omitempty"`
VideoHash string `json:"video_hash,omitempty"`
VideoWidth int `json:"video_width,omitempty"`
VideoHeight int `json:"video_height,omitempty"`
URITitle string `json:"uri_title"`
Source int `json:"source,omitempty"`
CmMark int `json:"cm_mark,omitempty"`
AdCb string `json:"ad_cb,omitempty"`
ResourceID int `json:"resource_id,omitempty"`
RequestID string `json:"request_id,omitempty"`
ClientIP string `json:"client_ip,omitempty"`
IsAd bool `json:"is_ad"`
IsAdLoc bool `json:"is_ad_loc,omitempty"`
Schema string `json:"schema,omitempty"`
SchemaTitle string `json:"schema_title,omitempty"`
SchemaPackageName string `json:"schema_package_name,omitempty"`
SchemaCallupWhiteList []string `json:"schema_callup_white_list,omitempty"`
Extra json.RawMessage `json:"extra,omitempty"`
}
type Show struct {
ID int64 `json:"id"`
Stime xtime.Time `json:"stime"`
Etime xtime.Time `json:"etime"`
}
type CmSplash struct {
*CmConfig
List []*List `json:"list,omitempty"`
Show []*Show `json:"show,omitempty"`
}
type CmConfig struct {
MaxTime int `json:"max_time"`
MinInterval int `json:"min_interval"`
PullInterval int `json:"pull_interval"`
}
// PlatChange
func (s *Splash) PlatChange() {
switch s.Plat {
case 1: // resource iphone
s.Plat = model.PlatIPhone
case 2: // resource android
s.Plat = model.PlatAndroid
case 3: // resource pad
s.Plat = model.PlatIPad
case 4: // resource iphoneg
s.Plat = model.PlatIPhoneI
case 5: // resource androidg
s.Plat = model.PlatAndroidG
case 6: // resource padg
s.Plat = model.PlatIPadI
case 8: // resource androidi
s.Plat = model.PlatAndroidI
}
if s.Operate == 1 { // NOTE: operate=1 means AD
s.Type = 1 // NOTE: type=1 compatiable mobile, must type=1 can splash
}
}
// BirthDate
func (s *Splash) BirthDate() {
s.BirthStart = s.Start.Time().Format("0102")
s.BirthEnd = s.End.Time().Format("0102")
s.BirthStartMonth = s.Start.Time().Format("01")
s.BirthEndMonth = s.End.Time().Format("01")
s.Start = xtime.Time(0)
s.End = xtime.Time(0)
}
// Ratio calc width/height ratio.
func Ratio(w, h int) float64 {
return float64(w) / float64(h)
}

View File

@@ -0,0 +1,29 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["static.go"],
importpath = "go-common/app/interface/main/app-resource/model/static",
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,36 @@
package static
import (
"strings"
xtime "go-common/library/time"
)
// Static
type Static struct {
Sid int `json:"sid"`
Name string `json:"name"`
Type string `json:"type"`
URL string `json:"url"`
Hash string `json:"hash"`
ImageHash string `json:"imageHash"`
Size int `json:"size"`
Plat int8 `json:"-"`
Build int `json:"-"`
Condition string `json:"-"`
Start xtime.Time `json:"-"`
End xtime.Time `json:"-"`
}
func (s *Static) StaticChange() {
var (
urls = strings.Split(s.URL, "/")
urlsLen = len(urls)
)
if urlsLen == 0 {
return
}
s.Name = urls[urlsLen-1]
s.ImageHash = s.Hash
s.Type = "mov"
}

View File

@@ -0,0 +1,32 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["tab.go"],
importpath = "go-common/app/interface/main/app-resource/model/tab",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/log: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,71 @@
package tab
import (
"encoding/json"
"strconv"
"go-common/library/log"
xtime "go-common/library/time"
)
type Menu struct {
ID int64 `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Img string `json:"img,omitempty"`
Icon string `json:"icon,omitempty"`
Color string `json:"color,omitempty"`
TabID int64 `json:"tab_id,omitempty"`
Plat int `json:"-"`
CType int `json:"-"`
CValue string `json:"-"`
PlatVersion json.RawMessage `json:"-"`
STime xtime.Time `json:"-"`
ETime xtime.Time `json:"-"`
Status int `json:"-"`
Badge string `json:"-"`
Versions map[int8][]*Version `json:"-"`
}
type Version struct {
PlatStr string `json:"plat"`
BuildStr string `json:"build"`
Condition string `json:"conditions"`
Plat int8 `json:"-"`
Build int `json:"-"`
}
func (m *Menu) Change() {
m.Icon = m.Badge
var vs []*Version
if err := json.Unmarshal(m.PlatVersion, &vs); err != nil {
log.Error("json.Unmarshal(%s) error(%v)", m.PlatVersion, err)
return
}
vm := make(map[int8][]*Version, len(vs))
for _, v := range vs {
if v.PlatStr == "" || v.BuildStr == "" {
continue
}
if plat, err := strconv.ParseInt(v.PlatStr, 10, 8); err != nil {
log.Error("strconv.ParseInt(%s,10,8) error(%v)", v.PlatStr, err)
continue
} else {
v.Plat = int8(plat)
}
if build, err := strconv.Atoi(v.BuildStr); err != nil {
log.Error("strconv.Atoi(%s) error(%v)", v.BuildStr, err)
continue
} else {
v.Build = build
}
vm[v.Plat] = append(vm[v.Plat], v)
}
m.Versions = vm
if m.CType == 1 {
var err error
if m.ID, err = strconv.ParseInt(m.CValue, 10, 64); err != nil {
log.Error("strconv.ParseInt(%s) error(%v)", m.CValue, err)
return
}
}
}

View File

@@ -0,0 +1,52 @@
load(
"@io_bazel_rules_go//proto:def.bzl",
"go_proto_library",
)
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
proto_library(
name = "version_proto",
srcs = ["version.proto"],
tags = ["automanaged"],
)
go_proto_library(
name = "version_go_proto",
compilers = ["@io_bazel_rules_go//proto:go_proto"],
importpath = "go-common/app/interface/main/app-resource/model/version",
proto = ":version_proto",
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = ["version.go"],
embed = [":version_go_proto"],
importpath = "go-common/app/interface/main/app-resource/model/version",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/time:go_default_library",
"@com_github_golang_protobuf//proto:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,123 @@
package version
import (
xtime "go-common/library/time"
"strings"
)
const (
PlatAndroid = int8(0)
PlatIPhone = int8(1)
PlatIPad = int8(2)
PlatWinPhone = int8(3)
)
type Version struct {
Id int `json:"-"`
Plat int8 `json:"plat"`
Desc string `json:"desc"`
Version string `json:"version"`
Build int `json:"build"`
PTime xtime.Time `json:"ptime"`
}
type VersionUpdate struct {
Id int `json:"-"`
Channel string `json:"-"`
Coverage int `json:"-"`
Version string `json:"ver"`
Build int `json:"build"`
Desc string `json:"info"`
State int `json:"-"`
Size string `json:"size"`
Url string `json:"url"`
MD5 string `json:"hash"`
SdkInts string `json:"-"`
SdkIntList map[string]struct{} `json:"-"`
Model string `json:"-"`
Policy int `json:"policy"`
Plat int8 `json:"-"`
IsForce int `json:"is_force"`
IsPush int `json:"is_push"`
PolicyName string `json:"-"`
IsGray int `json:"is_gray"`
PolicyURL string `json:"policy_url,omitempty"`
BuvidStart int `json:"-"`
BuvidEnd int `json:"-"`
Mtime xtime.Time `json:"mtime"`
Incre *Incremental `json:"patch,omitempty"`
}
type UpdateLimit struct {
ID int `json:"-"`
BuildLimit int `json:"-"`
Conditions string `json:"-"`
}
type VersionSo struct {
Id int `json:"-"`
Package string `json:"-"`
Name string `json:"-"`
Description string `json:"-"`
Clear int `json:"-"`
Ver_code int `json:"ver_code"`
Ver_name string `json:"ver_name"`
Url string `json:"url"`
Size int `json:"size"`
Enable_state int `json:"enable"`
Force_state int `json:"force"`
Md5 string `json:"md5"`
Min_build int `json:"min_build"`
Coverage int `json:"-"`
Sdkint int `json:"-"`
Model string `json:"-"`
}
type VersionSoDesc struct {
Package string `json:"package"`
Name string `json:"name"`
Description string `json:"desc"`
Clear int `json:"clear"`
Versions []*VersionSo `json:"versions"`
}
// Incremental version Incremental
type Incremental struct {
ID int `json:"-"`
TargetVersion string `json:"-"`
TargetBuild int `json:"-"`
TargetID string `json:"new_id"`
SourceVersion string `json:"-"`
SourceBuild int `json:"-"`
SourceID string `json:"old_id"`
TaskID string `json:"-"`
FilePath string `json:"-"`
URL string `json:"url"`
Md5 string `json:"md5"`
Size int `json:"size"`
Policy int `json:"-"`
Plat int8 `json:"-"`
Build int `json:"-"`
}
// Rn
type Rn struct {
ID int `json:"-"`
DeploymentKey string `json:"-"`
BundleID string `json:"bundle_id"`
URL string `json:"url"`
Md5 string `json:"md5"`
Size int `json:"size"`
Version string `json:"-"`
}
// VersionUpdateChange version update change
func (v *VersionUpdate) VersionUpdateChange() {
if v.SdkInts != "" {
v.SdkIntList = map[string]struct{}{}
tmp := strings.Split(v.SdkInts, ",")
for _, sdkint := range tmp {
v.SdkIntList[sdkint] = struct{}{}
}
}
}

View File

@@ -0,0 +1,70 @@
// Code generated by protoc-gen-go.
// source: version.proto
// DO NOT EDIT!
/*
Package version is a generated protocol buffer package.
It is generated from these files:
version.proto
It has these top-level messages:
VerUpdate
*/
package version
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type VerUpdate struct {
Ver string `protobuf:"bytes,1,opt,name=ver" json:"ver,omitempty"`
Build int32 `protobuf:"varint,2,opt,name=build" json:"build,omitempty"`
Info string `protobuf:"bytes,3,opt,name=info" json:"info,omitempty"`
Size int32 `protobuf:"varint,4,opt,name=size" json:"size,omitempty"`
Url string `protobuf:"bytes,5,opt,name=url" json:"url,omitempty"`
Hash string `protobuf:"bytes,6,opt,name=hash" json:"hash,omitempty"`
Policy int32 `protobuf:"varint,7,opt,name=policy" json:"policy,omitempty"`
IsForce int32 `protobuf:"varint,8,opt,name=isForce" json:"isForce,omitempty"`
IsGray int32 `protobuf:"varint,9,opt,name=isGray" json:"isGray,omitempty"`
Mtime int64 `protobuf:"varint,10,opt,name=mtime" json:"mtime,omitempty"`
}
func (m *VerUpdate) Reset() { *m = VerUpdate{} }
func (m *VerUpdate) String() string { return proto.CompactTextString(m) }
func (*VerUpdate) ProtoMessage() {}
func (*VerUpdate) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func init() {
proto.RegisterType((*VerUpdate)(nil), "version.VerUpdate")
}
func init() { proto.RegisterFile("version.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 196 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x34, 0x8f, 0xcb, 0x8a, 0xc3, 0x30,
0x0c, 0x45, 0xc9, 0xe4, 0x35, 0x11, 0x0c, 0x0c, 0x66, 0x18, 0xb4, 0x2c, 0x5d, 0x75, 0xd5, 0x4d,
0xff, 0xa1, 0xdd, 0x07, 0xda, 0x7d, 0x1e, 0x2e, 0x11, 0x24, 0x71, 0xb0, 0x93, 0x42, 0xfa, 0xb7,
0xfd, 0x93, 0x5a, 0x72, 0xba, 0x3b, 0x47, 0xba, 0x57, 0xd8, 0xf0, 0xf3, 0xd0, 0xd6, 0x91, 0x19,
0x8f, 0x93, 0x35, 0xb3, 0x51, 0xf9, 0xa6, 0xfb, 0x57, 0x04, 0xc5, 0x4d, 0xdb, 0xeb, 0xd4, 0x56,
0xb3, 0x56, 0xbf, 0x10, 0xfb, 0x05, 0x46, 0xbb, 0xe8, 0x50, 0x94, 0x8c, 0xea, 0x0f, 0xd2, 0x7a,
0xa1, 0xbe, 0xc5, 0x2f, 0x3f, 0x4b, 0xcb, 0x20, 0x4a, 0x41, 0x42, 0xe3, 0xdd, 0x60, 0x2c, 0x41,
0x61, 0x9e, 0x39, 0x7a, 0x6a, 0x4c, 0x24, 0x28, 0xcc, 0xf7, 0x16, 0xdb, 0x63, 0x1a, 0xee, 0x79,
0xe4, 0x54, 0x57, 0xb9, 0x0e, 0xb3, 0xd0, 0x64, 0x56, 0xff, 0x90, 0x4d, 0xa6, 0xa7, 0x66, 0xc5,
0x5c, 0xba, 0x9b, 0x29, 0x84, 0x9c, 0xdc, 0xd9, 0xd8, 0x46, 0xe3, 0xb7, 0x2c, 0x3e, 0xca, 0x0d,
0x72, 0x17, 0x5b, 0xad, 0x58, 0x84, 0x46, 0x30, 0x7e, 0xed, 0x30, 0xd3, 0xa0, 0x11, 0xfc, 0x38,
0x2e, 0x83, 0xd4, 0x99, 0xfc, 0xf9, 0xf4, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x5a, 0x56, 0x88, 0xe5,
0x04, 0x01, 0x00, 0x00,
}

View File

@@ -0,0 +1,15 @@
syntax = "proto3";
package version;
message VerUpdate{
string ver=1;
int32 build=2;
string info=3;
int32 size=4;
string url=5;
string hash=6;
int32 policy=7;
int32 isForce=8;
int32 isGray=9;
int64 mtime=10;
}