Initial commit

This commit is contained in:
Donny
2019-04-22 20:46:32 +08:00
commit 49ab8aadd1
25441 changed files with 4055000 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"app.go",
"cache.go",
"comment.go",
"danmu.go",
"invite_code.go",
"location.go",
"model.go",
"redundance.go",
"report.go",
"search.go",
"sv.go",
"util.go",
"video.go",
],
importpath = "go-common/app/interface/bbq/app-bbq/model",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/bbq/user/api: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",
"//app/interface/bbq/app-bbq/model/grpc:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,39 @@
package model
import (
"go-common/library/time"
)
// AppVersion .
type AppVersion struct {
ID int `json:"id"`
Platform int `json:"platform"`
Name string `json:"name"`
Code int `json:"version"`
Title string `json:"title"`
Content string `json:"content"`
Download string `json:"download"`
MD5 string `json:"md5"`
Size int `json:"file_size"`
Force int `json:"force"`
Status int `json:"status"`
}
// AppResource .
type AppResource struct {
ID int `json:"id"`
Platform int `json:"platform"`
Name string `json:"name"`
Code int `json:"version"`
Download string `json:"download"`
MD5 string `json:"md5"`
Status int `json:"status"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
}
// DynamicEffect .
type DynamicEffect struct {
ID int `json:"rid"`
Name string `json:"rname"`
}

View File

@@ -0,0 +1,10 @@
package model
//缓存key常量
const (
CacheKeyUserShareToken = "user:share:token:%d" //用户分享token
CacheExpireUserShareToken = 600
CacheKeyLastPubtime = "%d:last:pubtime"
CacheExpireLastPubtime = 432000
)

View File

@@ -0,0 +1,259 @@
package model
import (
user "go-common/app/service/bbq/user/api"
xtime "go-common/library/time"
)
const (
//DefaultCmType bbq评论区
DefaultCmType = 23
)
// Int64Bytes implements the Scanner interface.
type Int64Bytes []int64
// Mstr Mstr
type Mstr []string
// ReplyCount /mcounts 返回字段
type ReplyCount struct {
SubState int64 `json:"sub_state"`
Count int64 `json:"count"`
}
// ReplyList /reply 返回字段
type ReplyList struct {
Page struct {
Num int `json:"num"`
Size int `json:"size"`
Count int `json:"count"`
Acount int `json:"acount"`
}
Config struct {
ShowEntry int `json:"showentry"`
ShowAdmin int `json:"showadmin"`
}
Replies []*Reply `json:"replies,omitempty"`
Hots []*Reply `json:"hots,omitempty"`
Upper struct {
MID int64 `json:"mid"`
Top *Reply `json:"top,omitempty"`
}
Top *Reply `json:"top,omitempty"`
Notice *Notice `json:"notice,omitempty"`
BlackList int16 `json:"blacklist"`
Assist int16 `json:"assist"`
}
// Reply .
type Reply struct {
RpID int64 `json:"rpid"`
Oid uint64 `json:"oid"`
Type int8 `json:"type"`
Mid int64 `json:"mid"`
Root int64 `json:"root"`
Parent int64 `json:"parent"`
Dialog int64 `json:"dialog"`
Count int `json:"count"`
RCount int `json:"rcount"`
Floor int `json:"floor"`
State int8 `json:"state"`
FansGrade int8 `json:"fansgrade"`
Attr int8 `json:"attr"`
CTime xtime.Time `json:"ctime"`
MTime xtime.Time `json:"-"`
// string
RpIDStr string `json:"rpid_str"`
RootStr string `json:"root_str"`
ParentStr string `json:"parent_str"`
DialogStr string `json:"dialog_str"`
// action count, from ReplyAction count
Like int `json:"like"`
Hate int `json:"-"`
Action int8 `json:"action"`
// member info
Member *Member `json:"member,omitempty"`
// other
Content *Content `json:"content,omitempty"`
Replies []*Reply `json:"replies,omitempty"`
Assist int `json:"assist"`
}
// Content .
type Content struct {
RpID int64 `json:"-"`
Message string `json:"message"`
Ats Int64Bytes `json:"ats"`
Topics Mstr `json:"topics"`
IP uint32 `json:"ipi"`
Plat int8 `json:"plat"`
Device string `json:"device"`
Version string `json:"version"`
CTime xtime.Time `json:"-"`
MTime xtime.Time `json:"-"`
// ats member info
Members []*Info `json:"members,omitempty"`
}
// Info Info
type Info struct {
Mid string `json:"mid"`
Name string `json:"uname"`
Sex string `json:"sex"`
Sign string `json:"sign"`
Avatar string `json:"avatar"`
Rank string `json:"rank"`
DisplayRank string `json:"DisplayRank"`
LevelInfo struct {
Cur int `json:"current_level"`
Min int `json:"current_min"`
NowExp int `json:"current_exp"`
NextExp int `json:"next_exp"`
} `json:"level_info"`
Pendant PendantInfo `json:"pendant"`
Nameplate NameplateInfo `json:"nameplate"`
OfficialVerify struct {
Type int `json:"type"`
Desc string `json:"desc"`
} `json:"official_verify"`
Vip struct {
Type int `json:"vipType"`
DueDate int64 `json:"vipDueDate"`
DueRemark string `json:"dueRemark"`
AccessStatus int `json:"accessStatus"`
VipStatus int `json:"vipStatus"`
VipStatusWarn string `json:"vipStatusWarn"`
} `json:"vip"`
BInfo *user.UserBase `json:"b_info,omitempty"`
}
// Member .
type Member struct {
Mid string `json:"mid"`
Name string `json:"uname"`
Sex string `json:"sex"`
Sign string `json:"sign"`
Avatar string `json:"avatar"`
Rank string `json:"rank"`
DisplayRank string `json:"DisplayRank"`
LevelInfo struct {
CurrentLevel int `json:"current_level"`
Min int `json:"current_min"`
NowExp int `json:"current_exp"`
NextExp int `json:"next_exp"`
} `json:"level_info"`
Pendant PendantInfo `json:"pendant"`
Nameplate NameplateInfo `json:"nameplate"`
OfficialVerify struct {
Type int `json:"type"`
Desc string `json:"desc"`
} `json:"official_verify"`
Vip struct {
Type int `json:"vipType"`
DueDate int64 `json:"vipDueDate"`
DueRemark string `json:"dueRemark"`
AccessStatus int `json:"accessStatus"`
VipStatus int `json:"vipStatus"`
VipStatusWarn string `json:"vipStatusWarn"`
} `json:"vip"`
FansDetail *FansDetail `json:"fans_detail,omitempty"`
Following int16 `json:"following"` //是否关注
BInfo *user.UserBase `json:"b_info,omitempty"`
}
// FansDetail .
type FansDetail struct {
UID int64 `json:"uid"`
MedalID int32 `json:"medal_id"` //勋章id
MedalName string `json:"medal_name"` //勋章名称
Score int32 `json:"score"` //当前总经验值
Level int8 `json:"level"` //level等级
Intimacy int32 `json:"intimacy"` //当前亲密度
Status int8 `json:"master_status"` //佩戴状态1:佩戴中0:未佩戴
Received int8 `json:"is_receive"` //是否领取0:未领取1:已领取
}
// NameplateInfo .
type NameplateInfo struct {
Nid int `json:"nid"`
Name string `json:"name"`
Image string `json:"image"`
ImageSmall string `json:"image_small"`
Level string `json:"level"`
Condition string `json:"condition"`
}
// PendantInfo .
type PendantInfo struct {
PID int `json:"pid"`
Name string `json:"name"`
Image string `json:"image"`
Expire int `json:"expire"`
}
//AddRes 添加评论返回字段
type AddRes struct {
RpID int64 `json:"rpid"`
NeedCaptcha bool `json:"need_captcha"`
URL string `json:"url"`
}
//CursorRes /reply/cusor response
type CursorRes struct {
Assist int64 `json:"assist"`
BlackList int64 `json:"blacklist"`
Replies []*Reply `json:"replies,omitempty"`
Upper *Upper `json:"upper,omitempty"`
Cursor *Cursor `json:"cursor,omitempty"`
Config *Config `json:"config,omitempty"`
Hots []*Reply `json:"hots,omitempty"`
Notice *Notice `json:"notice,omitempty"`
Top *Top `json:"top,omitempty"`
}
//SubCursorRes /reply/reply/cusor response
type SubCursorRes struct {
Assist int64 `json:"assist"`
BlackList int64 `json:"blacklist"`
Root *Reply `json:"root,omitempty"`
Upper *Upper `json:"upper,omitempty"`
Cursor *Cursor `json:"cursor,omitempty"`
}
// Notice Notice
type Notice struct {
ID int64 `json:"id"`
Plat int8 `json:"-"`
Condition int8 `json:"-"`
Build int64 `json:"-"`
Title string `json:"title"`
Content string `json:"content"`
Link string `json:"link"`
ClientType string `json:"-"`
}
//Top .
type Top struct {
Admin *Reply `json:"admin,omitempty"`
Upper *Reply `json:"upper,omitempty"`
}
//Config .
type Config struct {
ShowEntry int16 `json:"showentry"`
ShowAdmin int16 `json:"showadmin"`
}
//Cursor .
type Cursor struct {
ACount int64 `json:"all_count"`
CursorRangeMax int64 `json:"max_id"`
CursorRangeMin int64 `json:"min_id"`
Size int64 `json:"size"`
}
//Upper .
type Upper struct {
MID int64 `json:"mid"`
}

View File

@@ -0,0 +1,11 @@
package model
//Danmu ...
type Danmu struct {
ID int64
OID int64
MID int64
Offset int64
Content string
State int8
}

View File

@@ -0,0 +1,54 @@
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
load(
"@io_bazel_rules_go//proto:def.bzl",
"go_proto_library",
)
proto_library(
name = "grpc_proto",
srcs = ["bvc.proto"],
tags = ["automanaged"],
deps = ["@gogo_special_proto//github.com/gogo/protobuf/gogoproto"],
)
go_proto_library(
name = "grpc_go_proto",
compilers = ["@io_bazel_rules_go//proto:gogofast_grpc"],
importpath = "go-common/app/interface/bbq/app-bbq/model/grpc",
proto = ":grpc_proto",
tags = ["automanaged"],
deps = ["@com_github_gogo_protobuf//gogoproto:go_default_library"],
)
go_library(
name = "go_default_library",
srcs = [],
embed = [":grpc_go_proto"],
importpath = "go-common/app/interface/bbq/app-bbq/model/grpc",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"@com_github_gogo_protobuf//gogoproto:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_gogo_protobuf//sortkeys:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_x_net//context: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"],
)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
syntax="proto3";
package video.vod.playurlbbq;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option go_package = "grpc";
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.stringer_all) = true;
message RequestMsg {
repeated string keys = 1;
string platform = 2;
string uip = 3[(gogoproto.customname)= "UIP"];
uint32 uiplong = 4;
uint32 backup = 5;
string uuid = 6[(gogoproto.customname)= "UUID"];
}
message VideoKeyItem {
uint32 etime = 1;
repeated string url = 2[(gogoproto.customname)= "URL"];
}
message ResponseMsg {
uint32 code = 1;
map<string, VideoKeyItem> data = 2;
}
//// Following defines rpc services.
service PlayurlService {
rpc ProtobufPlayurl(RequestMsg) returns (ResponseMsg);
};

View File

@@ -0,0 +1,11 @@
package model
import "go-common/library/time"
// InviteCode 邀请码表
type InviteCode struct {
Code int64 `json:"code"`
DeviceID string `json:"device_id"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}

View File

@@ -0,0 +1,9 @@
package model
// Location .
type Location struct {
ID int32 `json:"id"`
PID int32 `json:"pid"`
Name string `json:"name"`
Child []*Location `json:"child,omitempty"`
}

View File

@@ -0,0 +1,77 @@
package model
import (
"encoding/json"
"go-common/library/time"
)
// 接口Action定义
const (
ActionRecommend = iota
ActionPlay
ActionLike
ActionCancelLike
ActionFollow
ActionCancelFollow
ActionCommentAdd
ActionCommentLike
ActionCommentReport
ActionFeedList
ActionShare
ActionDanmaku
ActionPlayPause
ActionPushRegister
ActionPushSucced
ActionPushCallback
ActionBlack
ActionCancelBlack
ActionVideoSearch
ActionUserSearch
ActionUserUnLike
)
// App platform
const (
PlatAndroid = iota + 1
PlatIOS
)
const (
// FeedListLen 为feed list中返回的数量
FeedListLen = 10
// SpaceListLen 空间长度
SpaceListLen = 20
// MaxInt64 用于最大int64
MaxInt64 = int64(^uint64(0) >> 1)
// BatchUserLen 批量请求用户信息时最大数量
BatchUserLen = 50
)
const (
//FromBILI video.from bilibili
FromBILI = 0
//FromBBQ video.from bbq
FromBBQ = 1
//FromCMS video.from cms
FromCMS = 2
)
// FeedMark record the struct which returned to app in feed api
type FeedMark struct {
LastSvID int64 `json:"last_svid"`
LastPubtime time.Time `json:"last_pubtime"`
IsRec bool `json:"is_rec"`
}
// CursorValue 用于cursor的定位这里可以当做通用结构使用使用者自己根据需求定义cursor_id的含义
type CursorValue struct {
CursorID int64 `json:"cursor_id"`
CursorTime time.Time `json:"cursor_time"`
}
//HTTPRpcRes ..
type HTTPRpcRes struct {
Code int `json:"code"`
Msg string `json:"message"`
Data json.RawMessage `json:"data"`
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,104 @@
package model
const (
//TypeVideo video type
TypeVideo = int16(10)
//TypeComment comment type
TypeComment = int16(20)
//TypeDanmu danmu type
TypeDanmu = int16(30)
//TypeUser user type
TypeUser = int16(40)
)
// ReportConfig .
type ReportConfig struct {
Type int16 `json:"type"`
Reasons []int16 `json:"reasons,omitempty"`
}
// ReasonConfig .
type ReasonConfig struct {
ReasonType int16 `json:"reason_type"`
Name string `json:"name"`
}
//Reports .
var Reports = []*ReportConfig{
{
Type: 10,
Reasons: []int16{1, 2, 7, 3, 4, 100},
},
{
Type: 20,
Reasons: []int16{1, 2, 7, 3, 100},
},
{
Type: 30,
Reasons: []int16{1, 2, 7, 3, 100},
},
{
Type: 40,
Reasons: []int16{5, 6},
},
}
//Reasons .
var Reasons = []*ReasonConfig{
{
ReasonType: 1,
Name: "违法违禁",
},
{
ReasonType: 2,
Name: "色情",
},
{
ReasonType: 3,
Name: "赌博诈骗",
},
{
ReasonType: 4,
Name: "血腥暴力",
},
{
ReasonType: 5,
Name: "昵称违规",
},
{
ReasonType: 6,
Name: "头像违规",
},
{
ReasonType: 7,
Name: "低俗",
},
{
ReasonType: 100,
Name: "其他",
},
}
// MapReasons map reasons
var MapReasons = map[int16]string{
1: "违法违禁",
2: "色情",
3: "赌博诈骗",
4: "血腥暴力",
5: "昵称违规",
6: "头像违规",
7: "低俗",
100: "其他",
}
// BiliReasonsMap 主站评论举报类型映射, key bbq value bilibili
var BiliReasonsMap = map[int16]int16{
1: 9,
2: 2,
3: 12,
4: 0,
5: 0,
6: 0,
7: 10,
100: 0,
}

View File

@@ -0,0 +1,78 @@
package model
import "encoding/json"
// SearchBaseReq 搜索基本请求
type SearchBaseReq struct {
KeyWord string `json:"keyword"`
Type string `json:"search_type"`
Page int64 `json:"page"`
PageSize int64 `json:"pagesize"`
Highlight int64 `json:"highlight"`
Platform string `json:"platform"`
MobiApp string `json:"mobi_app"`
Build string `json:"build"`
Device string `json:"device"`
}
// SearchBaseRet 搜索基本返回
type SearchBaseRet struct {
Code int64 `json:"code"`
NumPages int64 `json:"numPages"`
PageSize int64 `json:"pagesize"`
Seid string `json:"seid"`
Msg string `json:"msg"`
Page int64 `json:"page"`
}
// VideoSearchRet 视频搜索结果
type VideoSearchRet struct {
SearchBaseRet
Result []*VideoSearchResult `json:"result,omitempty"`
}
// VideoSearchResult 视频搜索result
type VideoSearchResult struct {
ID int32 `json:"id"`
Title string `json:"title"`
HitColumns []string `json:"hit_columns,omitempty"`
}
// UserSearchResult 用户搜索结果
type UserSearchResult struct {
ID int64 `json:"id"`
Uname string `json:"uname"`
HitColumns []string `json:"hit_columns"`
}
// RawSearchRes .
type RawSearchRes struct {
Code int `json:"code"`
SeID string `json:"seid"`
Msg string `json:"msg"`
Page int64 `json:"page"`
PageNum int64 `json:"NumPages"`
Res json.RawMessage `json:"Result"`
}
// SugBaseReq Sug基本请求
type SugBaseReq struct {
Term string `json:"term"`
SuggestType string `json:"suggest_type"`
MainVer string `json:"main_ver"`
SugNum int64 `json:"sug_num"`
Highlight int64 `json:"highlight"`
Platform string `json:"platform"`
MobiApp string `json:"mobi_app"`
Build string `json:"build"`
Device string `json:"device"`
}
// RawSugTag SugTag结构
type RawSugTag struct {
Value string `json:"value"`
Ref int64 `json:"ref"`
Name string `json:"name"`
Spid int64 `json:"spid"`
Type string `json:"type"`
}

View File

@@ -0,0 +1,68 @@
package model
import (
"go-common/library/time"
)
//SVBvcKey ..
type SVBvcKey struct {
SVID int64 `json:"svid"`
Path string `json:"path"`
ResolutionRetio string `json:"resolution_retio"`
CodeRate int16 `json:"code_rate"`
VideoCode string `json:"video_code"`
FileSize int64 `json:"file_size"`
Duration int64 `json:"duration"`
}
// ParamScore 打分参数
type ParamScore struct {
SVID int64 `form:"svid" validate:"gt=0,required"`
Score int64 `form:"score" validate:"gt=0,required"`
}
// ParamStatistic 统计参数
type ParamStatistic struct {
SVIDs string `form:"svid" validate:"required"`
}
// SvInfo svList response
type SvInfo struct {
SVID int64 `json:"svid"`
TID int64 `json:"tid"`
SubTID int64 `json:"sub_tid"`
Title string `json:"title"`
Content string `json:"content"`
MID int64 `json:"mid"`
Duration int64 `json:"duration"`
Pubtime time.Time `json:"pubtime"`
Ctime time.Time `json:"ctime"`
AVID int64 `json:"avid"`
CID int64 `json:"cid"`
State int16 `json:"state"`
Original int16 `json:"original"`
From int16 `json:"from"`
VerID int64 `json:"ver_id"`
Ver int64 `json:"ver"`
Tag string `json:"tag"`
CoverURL string `json:"cover_url"`
CoverWidth int `json:"cover_width"`
CoverHeight int `json:"cover_height"`
}
// SvStInfo static info
type SvStInfo struct {
SVID int64 `json:"svid"`
Play int64 `json:"view"` //和上层的play重复因此改成view
Subtitles int64 `json:"subtitles"`
Like int64 `json:"like"`
Share int64 `json:"share"`
Reply int64 `json:"reply"`
Report int64 `json:"report"`
}
// SvTag SvTag struct
type SvTag struct {
SVID int64
TagID int64
}

View File

@@ -0,0 +1,20 @@
package model
import (
"math"
"strconv"
)
// CalNum2SufStr int64转换带后缀字符串K,W,E
func CalNum2SufStr(n int64) string {
var f float64
var s string
if n > 1000 {
f = float64(n) / 1000
s = strconv.FormatFloat(math.Ceil(f), 'f', 0, 64) + "k"
} else {
f = float64(n)
s = strconv.FormatFloat(f, 'f', 0, 64)
}
return s
}

View File

@@ -0,0 +1,11 @@
package model
//VideoStatistics .
type VideoStatistics struct {
SVID int64 `json:"svid"`
Play int64 `json:"play"`
Subtitles int64 `json:"subtitles"`
Like int64 `json:"like"`
Share int64 `json:"share"`
Report int64 `json:"report"`
}