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,66 @@
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 = "model_proto",
srcs = ["model.proto"],
tags = ["automanaged"],
deps = ["@gogo_special_proto//github.com/gogo/protobuf/gogoproto"],
)
go_proto_library(
name = "model_go_proto",
compilers = ["@io_bazel_rules_go//proto:gogofast_proto"],
importpath = "go-common/app/service/main/usersuit/model",
proto = ":model_proto",
tags = ["automanaged"],
deps = [
"//library/time:go_default_library",
"@com_github_gogo_protobuf//gogoproto:go_default_library",
],
)
go_library(
name = "go_default_library",
srcs = [
"invite.go",
"medal.go",
"model.go",
"notify.go",
"pendant_state.go",
"rpc.go",
],
embed = [":model_go_proto"],
importpath = "go-common/app/service/main/usersuit/model",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/log:go_default_library",
"//library/time:go_default_library",
"@com_github_gogo_protobuf//gogoproto:go_default_library",
"@com_github_gogo_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,81 @@
package model
import (
xtime "go-common/library/time"
)
const (
// StatusOk ok
StatusOk = 0
// StatusUsed used
StatusUsed = 1
// StatusExpires expire
StatusExpires = 2
)
// Invite invaite
type Invite struct {
Status int64 `json:"status"`
Mid int64 `json:"mid"`
Code string `json:"invite_code"`
IP uint32 `json:"-"` // legacy IP field
IPng []byte `json:"-"`
Ctime xtime.Time `json:"buy_time"`
Expires int64 `json:"expires"`
Imid int64 `json:"invited_mid,omitempty"`
UsedAt int64 `json:"used_at,omitempty"`
Mtime xtime.Time `json:"-"`
}
// FillStatus fill status
func (inv *Invite) FillStatus(now int64) {
if inv.Used() {
inv.Status = StatusUsed
return
}
if inv.Expired(now) {
inv.Status = StatusExpires
return
}
inv.Status = StatusOk
}
// Used use
func (inv *Invite) Used() bool {
return inv.UsedAt > 0 && inv.Imid > 0
}
// Expired expire
func (inv *Invite) Expired(now int64) bool {
return now > inv.Expires
}
// SortInvitesByCtimeDesc sort
type SortInvitesByCtimeDesc []*Invite
// Len len
func (invs SortInvitesByCtimeDesc) Len() int {
return len(invs)
}
// Less less
func (invs SortInvitesByCtimeDesc) Less(i, j int) bool {
return int64(invs[i].Ctime) > int64(invs[j].Ctime)
}
// Swap swap
func (invs SortInvitesByCtimeDesc) Swap(i, j int) {
tmp := invs[i]
invs[i] = invs[j]
invs[j] = tmp
}
// InviteStat stat
type InviteStat struct {
Mid int64 `json:"mid"`
CurrentLimit int64 `json:"current_limit"`
CurrentBought int64 `json:"current_bought"`
TotalBought int64 `json:"total_bought"`
TotalUsed int64 `json:"total_used"`
InviteCodes []*Invite `json:"invite_codes"`
}

View File

@@ -0,0 +1,75 @@
package model
import (
"fmt"
"math/rand"
xtime "go-common/library/time"
)
const (
// OwnerInstall is_activated=1.
OwnerInstall = 1
// OwnerUninstall is_activated=0.
OwnerUninstall = 0
// Level1 medal_info.level 普通.
Level1 = int32(1)
// Level2 medal_info.level 高级.
Level2 = int32(2)
// Level3 medal_info.level 稀有.
Level3 = int32(3)
// IsGet medal has get.
IsGet = int32(1)
// NotGet medal not get.
NotGet = int32(0)
)
var medalLevel = map[int32]string{Level1: "普通勋章", Level2: "高级勋章", Level3: "稀有勋章"}
// MedalOwner struct.
type MedalOwner struct {
ID int64 `json:"id"`
MID int64 `json:"mid"`
NID int64 `json:"nid"`
IsActivated int8 `json:"is_activated"`
CTime xtime.Time `json:"ctime"`
MTime xtime.Time `json:"mtime"`
}
// MedalGroup struct.
type MedalGroup struct {
ID int64 `json:"id"`
Name string `json:"name"`
PID int64 `json:"pid"`
Rank int8 `json:"rank"`
IsOnline int8 `josn:"is_online"`
CTime xtime.Time `json:"ctime"`
MTime xtime.Time `json:"mtime"`
}
// MedalMsg struct.
type MedalMsg struct {
ID int64 `json:"id"`
MID int64 `json:"mid"`
NID int64 `json:"nid"`
CTime xtime.Time `json:"ctime"`
MTime xtime.Time `json:"mtime"`
}
// MedalCheck struct.
type MedalCheck struct {
Has int32 `json:"has"`
Info interface{} `json:"info"`
}
// Build build image and level info.
func (mi *MedalInfo) Build() {
mi.Image = getImageURL(mi.Image)
mi.ImageSmall = getImageURL(mi.ImageSmall)
mi.LevelDesc = medalLevel[mi.Level]
}
// getImageUrl get image from BFS.
func getImageURL(imgSrc string) (imgURL string) {
return fmt.Sprintf("http://i%d.hdslb.com%s", rand.Int63n(3), imgSrc)
}

View File

@@ -0,0 +1,33 @@
package model
// Pendant event const.
const (
PendantPickOff int64 = iota + 1
PendantPutOn
)
// VipInfo .
type VipInfo struct {
Mid int64 `json:"mid"`
VipType int64 `json:"vipType"`
VipStatus int64 `json:"vipStatus"`
VipDueDate int64 `json:"vipDueDate"`
}
// ArgMIDNID struct.
type ArgMIDNID struct {
MID int64 `form:"mid" validate:"gt=0,required"`
NID int64 `form:"nid" validate:"gt=0,required"`
}
// ArgMID struct.
type ArgMID struct {
MID int64 `form:"mid" validate:"gt=0,required"`
}
// AccountNotify .
type AccountNotify struct {
UID int64 `json:"mid"`
Type string `json:"type"`
Action string `json:"action"`
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,206 @@
syntax = "proto3";
package account.service.usersuit;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option go_package = "model";
message ArgPendantHistory {
int64 mid =1 [(gogoproto.jsontag) = "mid"];
int32 source_type =2 [(gogoproto.jsontag) = "sourceType"];
int64 start_time =3 [(gogoproto.jsontag) = "startTime"];
int64 end_time =4 [(gogoproto.jsontag) = "endTime"];
int64 page =5 [(gogoproto.jsontag) = "page"];
}
message ArgOrderHistory {
string order_id = 1 [(gogoproto.jsontag) = "oderID", (gogoproto.customname) = "OrderID"];
string pay_id = 2 [(gogoproto.jsontag) = "payID", (gogoproto.customname) = "PayID"];
int64 mid = 3 [(gogoproto.jsontag) = "mid"];
int64 pid = 4 [(gogoproto.jsontag) = "pid"];
int32 status = 5 [(gogoproto.jsontag) = "status"];
int32 pay_type =6 [(gogoproto.jsontag) = "payType"];
int64 start_time =7 [(gogoproto.jsontag) = "startTime"];
int64 end_time =8 [(gogoproto.jsontag) = "endTime"];
int64 page =9 [(gogoproto.jsontag) = "page"];
}
message PendantGroupInfo {
int64 id = 1 [(gogoproto.jsontag) = "id", (gogoproto.customname) = "ID"];
string name = 2 [(gogoproto.jsontag) = "group_name"];
int32 rank = 3 [(gogoproto.jsontag) = "rank"];
int32 status = 4 [(gogoproto.jsontag) = "status"];
string image =5 [(gogoproto.jsontag) = "image"];
string image_model =6 [(gogoproto.jsontag) = "image_model"];
int32 frequency_limit =7 [(gogoproto.jsontag) = "-"];
int32 time_limit =8 [(gogoproto.jsontag) = "-"];
int64 number =9 [(gogoproto.jsontag) = "group_count"];
repeated Pendant sub_pendant = 10 [(gogoproto.jsontag) = "pendant_info"];
}
message PendantGroup {
int64 id = 1 [(gogoproto.jsontag) = "id", (gogoproto.customname) = "ID"];
int64 gid = 2 [(gogoproto.jsontag) = "gid"];
int64 pid = 3 [(gogoproto.jsontag) = "pid"];
}
message PendantPrice {
int64 id = 1 [(gogoproto.jsontag) = "id", (gogoproto.customname) = "ID"];
int64 pid = 2 [(gogoproto.jsontag) = "pid"];
int64 type = 3 [(gogoproto.jsontag) = "type"];
int64 price = 4 [(gogoproto.jsontag) = "price"];
}
message PendantHistory {
int64 id = 1 [(gogoproto.jsontag) = "id", (gogoproto.customname) = "ID"];
int64 mid = 2 [(gogoproto.jsontag) = "mid"];
int64 pid = 3 [(gogoproto.jsontag) = "pid"];
int32 source_type = 4 [(gogoproto.jsontag) = "source_type"];
int64 expire = 5 [(gogoproto.jsontag) = "expire"];
string operator_name = 6 [(gogoproto.jsontag) = "opeartor_name"];
int32 operator_action = 7 [(gogoproto.jsontag) = "opeartor_action"];
}
message PendantOrderInfo {
int64 id =1 [(gogoproto.jsontag) = "_", (gogoproto.customname) = "ID"];
int64 mid = 2 [(gogoproto.jsontag) = "mid"];
string order_id = 3 [(gogoproto.jsontag) = "order_id", (gogoproto.customname) = "OrderID"];
string pay_id = 4 [(gogoproto.jsontag) = "pay_id", (gogoproto.customname) = "PayID"];
int64 pay_type = 5 [(gogoproto.jsontag) = "pay_type"];
double pay_price = 6 [(gogoproto.jsontag) = "pay_price"];
int64 app_id = 7 [(gogoproto.jsontag) = "app_id", (gogoproto.customname) = "AppID"];
int32 stauts = 8 [(gogoproto.jsontag) = "status"];
int64 pid = 9 [(gogoproto.jsontag) = "pid"];
int64 time_length = 10 [(gogoproto.jsontag) = "time_length"];
string cost = 11 [(gogoproto.jsontag) = "cost"];
int64 buy_time = 12 [(gogoproto.jsontag) = "buy_time"];
int32 is_callback = 13 [(gogoproto.jsontag) = "is_callback"];
int64 callback_time = 14 [(gogoproto.jsontag) = "callback_time"];
string image = 15 [(gogoproto.jsontag) = "image"];
string name = 16 [(gogoproto.jsontag) = "name"];
}
message PayInfo {
string order_id = 1 [(gogoproto.jsontag) = "order_id", (gogoproto.customname) = "OrderID"];
string order_num = 2 [(gogoproto.jsontag) = "order_no"];
string pay_url = 3 [(gogoproto.jsontag) = "pay_url", (gogoproto.customname) = "PayURL"];
}
message Pendant {
int64 id =1 [(gogoproto.jsontag) = "pid", (gogoproto.customname) = "ID"];
string name = 2 [(gogoproto.jsontag) = "name"];
string image = 3 [(gogoproto.jsontag) = "image"];
string image_model =4 [(gogoproto.jsontag) = "image_model"];
int32 status =5 [(gogoproto.jsontag) = "status"];
int64 coin =6 [(gogoproto.jsontag) = "coin"];
int64 point =7 [(gogoproto.jsontag) = "point"];
int64 bcoin =8 [(gogoproto.jsontag) = "bcoin", (gogoproto.customname) = "BCoin"];
int64 expires =9 [(gogoproto.jsontag) = "expire"];
int64 gid =10 [(gogoproto.jsontag) = "gid"];
int32 rank = 11 [(gogoproto.jsontag) = "rank"];
}
message PendantPackage {
int64 id = 1 [(gogoproto.jsontag) = "id", (gogoproto.customname) = "ID"];
int64 mid = 2 [(gogoproto.jsontag) = "mid"];
int64 pid = 3 [(gogoproto.jsontag) = "pid"];
int64 expires =4 [(gogoproto.jsontag) = "expire"];
int64 type =5 [(gogoproto.jsontag) = "type"];
int32 status =6 [(gogoproto.jsontag) = "status"];
int32 is_vip =7 [(gogoproto.jsontag) = "isVIP", (gogoproto.customname) = "IsVIP"];
Pendant pendant =8 [(gogoproto.jsontag) = "pendant"];
}
message PendantEquip {
int64 mid = 1 [(gogoproto.jsontag) = "mid"];
int64 pid = 2 [(gogoproto.jsontag) = "pid"];
int64 expires =3 [(gogoproto.jsontag) = "expire"];
Pendant pendant =4 [(gogoproto.jsontag) = "pendant"];
}
message GroupPendantList {
int64 pkgExpires = 1 [(gogoproto.jsontag) = "pkg_expires"];
int32 pkgStatus = 2 [(gogoproto.jsontag) = "pkg_status"];
Pendant pendant = 3 [(gogoproto.embed) = true, (gogoproto.jsontag) = ""];
}
message MedalInfo {
int64 ID = 1 [(gogoproto.jsontag) = "nid"];
string Name = 2 [(gogoproto.jsontag) = "name"];
string Description = 3 [(gogoproto.jsontag) = "description"];
string Image = 4 [(gogoproto.jsontag) = "image"];
string ImageSmall = 5 [(gogoproto.jsontag) = "image_small"];
string Condition = 6 [(gogoproto.jsontag) = "condition"];
int64 GID = 7 [(gogoproto.jsontag) = "gid"];
int32 Level = 8 [(gogoproto.jsontag) = "level,omitempty"];
string LevelRank = 9 [(gogoproto.jsontag) = "level_rank,omitempty"];
string LevelDesc = 10 [(gogoproto.jsontag) = "level_desc,omitempty"];
int32 Sort = 11 [(gogoproto.jsontag) = "sort,omitempty"];
int32 IsOnline = 12 [(gogoproto.jsontag) = "is_online,omitempty"];
int32 IsGet = 13 [(gogoproto.jsontag) = "is_get,omitempty"];
int64 Ctime = 14 [(gogoproto.jsontag) = "ctime,omitempty", (gogoproto.casttype) = "go-common/library/time.Time"];
int64 Mtime = 15 [(gogoproto.jsontag) = "mtime,omitempty", (gogoproto.casttype) = "go-common/library/time.Time"];
}
message MedalHomeInfo {
string Description = 1 [(gogoproto.jsontag) = "description"];
string Image = 2 [(gogoproto.jsontag) = "image"];
string ImageSmall = 3 [(gogoproto.jsontag) = "image_small"];
int32 IsActivated = 4 [(gogoproto.jsontag) = "is_activated"];
string Level = 5 [(gogoproto.jsontag) = "level"];
string Name = 6 [(gogoproto.jsontag) = "name"];
int64 NID = 7 [(gogoproto.jsontag) = "nid"];
}
message MedalUserInfo {
string Name = 1 [(gogoproto.jsontag) = "name"];
string Face = 2 [(gogoproto.jsontag) = "face"];
int32 Level = 3 [(gogoproto.jsontag) = "level"];
bool TrueLove = 4 [(gogoproto.jsontag) = "truelove"];
int64 NID = 5 [(gogoproto.jsontag) = "nid"];
string ImageSmall = 6 [(gogoproto.jsontag) = "image_small"];
}
message MedalPopup {
int64 NID = 1 [(gogoproto.jsontag) = "nid"];
string Name = 2 [(gogoproto.jsontag) = "name"];
string Image = 3 [(gogoproto.jsontag) = "image"];
}
message MedalMyInfo{
MedalInfo MedalInfo = 1 [(gogoproto.embed) = true, (gogoproto.jsontag) = ""];
int32 IsActivated = 2 [(gogoproto.jsontag) = "is_activated"];
int32 IsNewGet = 3 [(gogoproto.jsontag) = "is_new_get"];
int64 GetTime = 4 [(gogoproto.jsontag) = "get_time,omitempty", (gogoproto.casttype) = "go-common/library/time.Time"];
}
message MedalMyInfos{
int32 Count = 1 [(gogoproto.jsontag) = "count"];
string Name = 2 [(gogoproto.jsontag) = "name"];
repeated MedalMyInfo List = 3 [(gogoproto.jsontag) = "list"];
}
message MedalAllInfos{
int64 HasActivated = 1 [(gogoproto.jsontag) = "has_activated"];
bool RedPoint = 2 [(gogoproto.jsontag) = "is_show_red_point"];
repeated int64 HasGet = 3 [(gogoproto.jsontag) = "has_get"];
map<int64, MedalCategoryInfo> List = 4 [(gogoproto.jsontag) = "list"];
}
message MedalCategoryInfo{
int32 Count = 1 [(gogoproto.jsontag) = "count"];
string Name = 2 [(gogoproto.jsontag) = "name"];
repeated MedalItemInfo Data = 3 [(gogoproto.jsontag) = "data"];
}
message MedalItemInfo{
MedalInfo Left = 1 [(gogoproto.jsontag) = "left"];
int32 Count = 2 [(gogoproto.jsontag) = "count"];
repeated MedalInfo Right = 3 [(gogoproto.jsontag) = "right,omitempty"];
}
message PointFlag{
bool Pendant = 1 [(gogoproto.jsontag) = "pendant"];
bool Medal = 2 [(gogoproto.jsontag) = "medal"];
}

View File

@@ -0,0 +1,7 @@
package model
//const
const (
AccountNotifyUpdatePendant = "updatePendant"
AccountNotifyUpdateMedal = "updateMedal"
)

View File

@@ -0,0 +1,61 @@
package model
import (
"strconv"
"go-common/library/log"
)
// const .
const (
// pendant status
PendantStatusON = 1
PendantStatusOFF = 0
// group status
GroupStatusON = 1
GroupStatusOFF = 0
// packpage status
InvalidPendantPKG = int32(0)
ValidPendantPKG = int32(1)
EquipPendantPKG = int32(2)
// pendant equip
PendantEquipOFF = int8(1)
PendantEquipON = int8(2)
// pendant source
UnknownEquipSource = 0
EquipFromPackage = 1
EquipFromVIP = 2
)
// IsValidSource 挂件来源是否合法 合法true,无效false
func IsValidSource(source int64) bool {
if source != EquipFromPackage && source != EquipFromVIP && source != UnknownEquipSource {
log.Error("IsValidSource souce=%v is not correct value", source)
return false
}
return true
}
// ParseSource c处理挂件来源
func ParseSource(sourceStr string) int64 {
// 没有传值,则设置为未知挂件
if sourceStr == "" {
return UnknownEquipSource
}
// 有传递参数,但是没有按照要求传值,也设置为未知挂件
source, err := strconv.ParseInt(sourceStr, 10, 64)
if err != nil {
log.Error("ParseSource err(%+v)", err)
return UnknownEquipSource
}
// 没有按照要求传值,也设置为未知挂件
if source != EquipFromPackage && source != EquipFromVIP && source != UnknownEquipSource {
log.Error("ParseSource souce=%v is not correct value", source)
return UnknownEquipSource
}
return source
}

View File

@@ -0,0 +1,95 @@
package model
// ArgBuy buy
type ArgBuy struct {
Mid int64
Num int64
IP string
}
// ArgApply apply
type ArgApply struct {
Mid int64
Code string
Cookie string
IP string
}
// ArgStat stat
type ArgStat struct {
Mid int64
IP string
}
// ArgGenerate generator
type ArgGenerate struct {
Mid int64
Num int64
ExpireDay int64
IP string
}
// ArgList list
type ArgList struct {
Mid int64
Start, End int64
}
// ArgEquipment rpc pendant arg .
type ArgEquipment struct {
Mid int64
IP string
}
// ArgEquipments rpc equipment arg .
type ArgEquipments struct {
Mids []int64
IP string
}
// ArgEquip rpc equip arg.
type ArgEquip struct {
Mid int64
Pid int64
Status int8
IP string
Source int64
}
// ArgMid struct.
type ArgMid struct {
Mid int64
}
// ArgMids struct.
type ArgMids struct {
Mids []int64
}
// ArgMedalUserInfo struct.
type ArgMedalUserInfo struct {
Mid int64
Cookie string
IP string
}
// ArgMedalInstall struct.
type ArgMedalInstall struct {
Mid int64 `form:"mid" validate:"gt=0,required"`
Nid int64 `form:"nid" validate:"gt=0,required"`
IsActivated int8 `form:"isActivated"`
}
// ArgGrantByMids one pendant give to multiple users.
type ArgGrantByMids struct {
BatchNo string
Mids []int64
Pid int64
Expire int64
}
// ArgGPMID .
type ArgGPMID struct {
MID int64
GID int64
}