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,32 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"anchor_level.go",
"databusMsg.go",
"model.go",
],
importpath = "go-common/app/service/live/dao-anchor/model",
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,107 @@
package model
import (
"errors"
"math"
)
const MaxAnchorLevel = 40
var anchorLevelScoreTable = []int64{
0,
50,
200,
470,
920,
2100,
4060,
7160,
11760,
18060,
27160,
39610,
56410,
78810,
109810,
154810,
226810,
319810,
442810,
602810,
816810,
1138810,
1594810,
2214810,
3004810,
3984810,
5229810,
6909810,
9013810,
11883810,
15613810,
20613810,
27313810,
36413810,
47813810,
62013810,
79513810,
99513810,
122013810,
147013810,
int64(math.MaxInt64),
}
// Returns the index of first element that **greater** than the given value.
func upperBound(list []int64, value int64) int {
count := len(list)
first:= 0
for count > 0 {
i := first
step := count / 2
i += step
if value >= list[i] {
first = i + 1
count -= step + 1
} else {
count = step
}
}
return first
}
// GetAnchorLevel returns anchor level, i.e. Lv1 ~ Lv40, corresponding to the given score.
func GetAnchorLevel(score int64) (int64, error) {
if score < 0 {
return 0, errors.New("invalid anchor score")
}
return int64(upperBound(anchorLevelScoreTable, score)), nil
}
// GetLevelScoreInfo returns left & right score of a given level.
func GetLevelScoreInfo(lv int64) (left, right int64, err error) {
if lv < 1 || lv >= int64(len(anchorLevelScoreTable)) {
return 0, 0, errors.New("invalid request level")
}
left = anchorLevelScoreTable[lv-1]
right = anchorLevelScoreTable[lv] - 1
return
}
// GetAnchorLevelColor returns level color.
func GetAnchorLevelColor(lv int64) (int64, error) {
if lv < 1 || lv > MaxAnchorLevel {
return 0, errors.New("invalid request level")
}
q := lv / 10
r := lv % 10
if r == 0 {
q -= 1
}
return q, nil
}

View File

@@ -0,0 +1,78 @@
package model
//MessageValue php 格式
type MessageValue struct {
Topic string `json:"topic"`
MsgID string `json:"msg_id"`
MsgContent string `json:"msg_content"`
}
//MessageWithoutMsgId golang投递
type MessageWithoutMsgId struct {
Topic string `json:"topic"`
Value string `json:"value"`
}
//DMSendMessageContent
type DMSendMsgContent struct {
RoomId int64 `json:"room_id"`
//Uid int64 `json:"uid"`
//Uname string `json:"uname"`
//UserLevel int64 `json:"user_level"`
//Color string `json:"color"`
//Content string `json:"content"`
}
type GiftSendMsgContent struct {
Body BodyMsg `json:"body"`
}
//BodyMsg
type BodyMsg struct {
MsgID string `json:"msg_id"`
Uid int64 `json:"uid"`
Ruid int64 `json:"ruid"`
RoomId int64 `json:"roomid"`
GiftId int64 `json:"giftid"`
PayCoin int64 `json:"pay_coin"`
Num int64 `json:"num"`
CoinType string `json:"coinType"`
}
// GuardBuyMessageContent
type GuardBuyMessageContent struct {
Uid int64 `json:"uid"`
Ruid int64 `json:"ruid"`
RoomId int64 `json:"roomid"`
Privilege int64 `json:"privilege"`
Coin int64 `json:"coin"`
Num int64 `json:"num"`
Type string `json:"type"`
Platform string `json:"platform"`
IsNew bool `json:"is_new"`
}
type TopicCommonMsg struct {
MsgId string `json:"msg_id"`
RoomId int64 `json:"room_id"`
Value int64 `json:"value"`
Cycle int64 `json:"cycle"`
Type int64 `json:"type"`
}
type LiveRoomTagMsg struct {
MsgId string `json:"msg_id"`
RoomId int64 `json:"room_id"`
TagId int64 `json:"tag_id"`
TagSubId int64 `json:"tag_sub_id"`
TagValue int64 `json:"tag_value"`
TagExt string `json:"tag_ext"`
ExpireTime int64 `json:"expire_time"`
}
type LiveRankListMsg struct {
RankId int64 `json:"rank_id"`
RankType string `json:"rank_type"`
RankList map[int64]int64 `json:"rank_list"`
ExpireTime int64 `json:"expire_time"`
}

View File

@@ -0,0 +1,7 @@
package model
type AreaInfo struct {
AreaID int64
AreaName string
ParentAreaID int64
}