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,34 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"message.go",
"result.go",
"retry.go",
"stat.go",
],
importpath = "go-common/app/job/main/archive-shjd/model",
tags = ["automanaged"],
visibility = ["//visibility:public"],
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"
// Message databus
type Message struct {
Action string `json:"action"`
Table string `json:"table"`
New json.RawMessage `json:"new"`
Old json.RawMessage `json:"old"`
}
// Notify is
type Notify struct {
Table string `json:"table"`
Action string `json:"action"`
Nw *Archive `json:"new"`
Old *Archive `json:"old"`
}
// AccountNotify is
type AccountNotify struct {
Mid int64 `json:"mid"`
Action string `json:"action"`
}

View File

@@ -0,0 +1,55 @@
package model
import (
"database/sql/driver"
"time"
)
// Archive archive result
type Archive struct {
ID int64 `json:"id"`
AID int64 `json:"aid"`
Mid int64 `json:"mid"`
TypeID int16 `json:"typeid"`
Videos int `json:"videos"`
Title string `json:"title"`
Cover string `json:"cover"`
Content string `json:"content"`
Duration int `json:"duration"`
Attribute int32 `json:"attribute"`
Copyright int8 `json:"copyright"`
Access int `json:"access"`
PubTime wocaoTime `json:"pubtime"`
CTime wocaoTime `json:"ctime"`
MTime wocaoTime `json:"mtime"`
State int `json:"state"`
MissionID int64 `json:"mission_id"`
OrderID int64 `json:"order_id"`
RedirectURL string `json:"redirect_url"`
Forward int64 `json:"forward"`
Dynamic string `json:"dynamic"`
}
// Video is
type Video struct {
AID int64 `json:"aid"`
CID int64 `json:"cid"`
}
type wocaoTime string
// Scan scan time.
func (jt *wocaoTime) Scan(src interface{}) (err error) {
switch sc := src.(type) {
case time.Time:
*jt = wocaoTime(sc.Format("2006-01-02 15:04:05"))
case string:
*jt = wocaoTime(sc)
}
return
}
// Value get time value.
func (jt wocaoTime) Value() (driver.Value, error) {
return time.Parse("2006-01-02 15:04:05", string(jt))
}

View File

@@ -0,0 +1,18 @@
package model
// is
const (
TypeForUpdateVideo = int(0)
TypeForDelVideo = int(1)
TypeForUpdateArchive = int(2)
)
// RetryItem struct
type RetryItem struct {
Tp int `json:"type"`
AID int64 `json:"aid"`
CID int64 `json:"cid"`
Old *Archive `json:"new_archive"`
Nw *Archive `json:"old_archive"`
Action string `json:"action"`
}

View File

@@ -0,0 +1,70 @@
package model
import "go-common/app/service/main/archive/api"
// is
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 int32 `json:"click"`
DM int32 `json:"dm"`
Reply int32 `json:"reply"`
Fav int32 `json:"fav"`
Coin int32 `json:"coin"`
Share int32 `json:"share"`
NowRank int32 `json:"now_rank"`
HisRank int32 `json:"his_rank"`
Like int32 `json:"like"`
Type string `json:"-"`
Ts int64 `json:"-"`
}
// StatCount is
type StatCount struct {
Type string `json:"type"`
Aid int64 `json:"id"`
Count int32 `json:"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 = m.Click
}
if m.Coin >= 0 && m.Type == TypeForCoin {
s.Coin = m.Coin
}
if m.DM >= 0 && m.Type == TypeForDm {
s.Danmaku = m.DM
}
if m.Fav >= 0 && m.Type == TypeForFav {
s.Fav = m.Fav
}
if m.Reply >= 0 && m.Type == TypeForReply {
s.Reply = m.Reply
}
if m.Share >= 0 && m.Type == TypeForShare && m.Share > s.Share {
s.Share = m.Share
}
if m.NowRank >= 0 && m.Type == TypeForRank {
s.NowRank = m.NowRank
}
if m.HisRank >= 0 && m.Type == TypeForRank {
s.HisRank = m.HisRank
}
if m.Like >= 0 && m.Type == TypeForLike {
s.Like = m.Like
}
}