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 = [
"like.go",
"monitor.go",
"stat.go",
],
importpath = "go-common/app/job/main/stat/model",
tags = ["automanaged"],
deps = ["//app/service/main/archive/api: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,25 @@
package model
import "encoding/json"
const (
ActUpdate = "update"
ActInsert = "insert"
ActDelete = "delete"
)
// Message canal binlog message.
type Message struct {
Action string `json:"action"`
Table string `json:"table"`
New json.RawMessage `json:"new"`
Old json.RawMessage `json:"old"`
}
// LikeMsg msg
type LikeMsg struct {
BusinessID int64 `json:"business_id"`
MessageID int64 `json:"message_id"`
LikesCount int64 `json:"likes_count"`
DislikesCount int64 `json:"dislikes_count"`
}

View File

@@ -0,0 +1,7 @@
package model
// Monitor is
type Monitor struct {
Topic string
Count int
}

View File

@@ -0,0 +1,73 @@
package model
import "go-common/app/service/main/archive/api"
const (
TypeForView = "view"
TypeForDm = "dm"
TypeForReply = "reply"
TypeForFav = "fav"
TypeForCoin = "coin"
TypeForShare = "share"
TypeForRank = "rank"
TypeForLike = "like"
)
// StatMsg stat info.
type StatMsg struct {
Aid int64 `json:"aid"`
Click int `json:"click"`
DM int `json:"dm"`
Reply int `json:"reply"`
Fav int `json:"fav"`
Coin int `json:"coin"`
Share int `json:"share"`
NowRank int `json:"now_rank"`
HisRank int `json:"his_rank"`
Like int `json:"like"`
DisLike int `json:"dislike_count"`
Type string `json:"-"`
Ts int64 `json:"-"`
}
type StatCount struct {
Type string `json:"type"`
Aid int64 `json:"id"`
Count int `json:"count"`
DisLike int `json:"dislike_count"`
TimeStamp int64 `json:"timestamp"`
}
// Merge merge message and stat from db.
func Merge(m *StatMsg, s *api.Stat) {
if m.Click >= 0 && m.Type == TypeForView {
s.View = int32(m.Click)
}
if m.Coin >= 0 && m.Type == TypeForCoin {
s.Coin = int32(m.Coin)
}
if m.DM >= 0 && m.Type == TypeForDm {
s.Danmaku = int32(m.DM)
}
if m.Fav >= 0 && m.Type == TypeForFav {
s.Fav = int32(m.Fav)
}
if m.Reply >= 0 && m.Type == TypeForReply {
s.Reply = int32(m.Reply)
}
if m.Share >= 0 && m.Type == TypeForShare && int32(m.Share) > s.Share {
s.Share = int32(m.Share)
}
if m.NowRank >= 0 && m.Type == TypeForRank {
s.NowRank = int32(m.NowRank)
}
if m.HisRank >= 0 && m.Type == TypeForRank {
s.HisRank = int32(m.HisRank)
}
if m.Like >= 0 && m.Type == TypeForLike {
s.Like = int32(m.Like)
}
if m.DisLike >= 0 && m.Type == TypeForLike {
s.DisLike = int32(m.DisLike)
}
}