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,74 @@
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 = ["message.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/up/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 = [
"archive.go",
"monitor.go",
"msg.go",
"rpc.go",
"sign_up.go",
"up.go",
"up_card.go",
"up_group.go",
"up_info.go",
"up_special.go",
"up_switch.go",
],
embed = [":model_go_proto"],
importpath = "go-common/app/service/main/up/model",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/time:go_default_library",
"//vendor/github.com/siddontang/go-mysql/mysql:go_default_library",
"@com_github_gogo_protobuf//gogoproto:go_default_library",
"@com_github_golang_protobuf//proto:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/main/up/model/data:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,19 @@
package model
import (
"go-common/library/time"
)
//Archive for db.
type Archive struct {
ID int64 `json:"id"`
MID int64 `json:"mid"`
State int `json:"state"`
}
// AidPubTime aid's pubdate and copyright
type AidPubTime struct {
Aid int64 `json:"aid"`
PubDate time.Time `json:"pubdate"`
Copyright int8 `json:"copyright"`
}

View File

@@ -0,0 +1,38 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"data.go",
"hbase.go",
],
importpath = "go-common/app/service/main/up/model/data",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/interface/main/creative/model/archive:go_default_library",
"//app/interface/main/creative/model/medal:go_default_library",
"//app/service/main/up/api/v1:go_default_library",
"//app/service/main/up/model: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"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,174 @@
package data
import (
xtime "go-common/library/time"
"go-common/app/interface/main/creative/model/medal"
)
// Stat info
type Stat struct {
FanLast int64 `json:"fan_last"`
Fan int64 `json:"fan"`
DmLast int64 `json:"dm_last"`
Dm int64 `json:"dm"`
CommentLast int64 `json:"comment_last"`
Comment int64 `json:"comment"`
Play int64 `json:"play"`
PlayLast int64 `json:"play_last"`
Fav int64 `json:"fav"`
FavLast int64 `json:"fav_last"`
Like int64 `json:"like"`
LikeLast int64 `json:"like_last"`
Day30 map[string]int `json:"30,omitempty"`
Arcs map[string][]*Arc `json:"arcs"`
}
// Arc Arcs info.
type Arc struct {
Aid int64 `json:"aid"`
Title string `json:"title"`
Click int64 `json:"click"`
}
// Tags Arcs info
type Tags struct {
Tags []string `json:"tags"`
}
// CheckedTag tags with checked
type CheckedTag struct {
Tag string `json:"tag"`
Checked int `json:"checked"`
}
// AppStat arc stat.
type AppStat struct {
Date string `json:"date"`
Num int64 `json:"num"`
}
// AppStatList for arc stat list.
type AppStatList struct {
Danmu []*AppStat `json:"danmu"`
View []*AppStat `json:"view"`
Fans []*AppStat `json:"fans"`
Comment []*AppStat `json:"comment"`
Show int8 `json:"show"`
}
// ViewerTrend for up trend data.
type ViewerTrend struct {
Tag map[int]string `json:"tag"`
Ty map[string]int64 `json:"ty"`
}
// ViewerIncr for up increment data.
type ViewerIncr struct {
Arcs []*ArcInc `json:"arc_inc"`
TotalIncr int `json:"total_inc"`
TyRank map[string]int `json:"type_rank"`
}
// ArcInc for archive increment data.
type ArcInc struct {
AID int64 `json:"aid"`
Incr int `json:"incr"`
Title string `json:"title"`
PTime xtime.Time `json:"ptime"`
}
// PeriodTip period tip for data.
type PeriodTip struct {
ModuleOne string `json:"module_one"`
ModuleTwo string `json:"module_two"`
ModuleThree string `json:"module_three"`
ModuleFour string `json:"module_four"`
}
// AppViewerIncr for up increment data.
type AppViewerIncr struct {
DateKey int64 `json:"date_key"`
Arcs []*ArcInc `json:"arc_inc"`
TotalIncr int `json:"total_inc"`
TyRank []*Rank `json:"type_rank"`
}
// ThirtyDay for 30 days data.
type ThirtyDay struct {
DateKey int64 `json:"date_key"`
TotalIncr int64 `json:"total_inc"`
}
// Rank type rank for up data.
type Rank struct {
Name string `json:"name"`
Rank int `json:"rank"`
}
// CreatorDataShow for display archive/article data module.
type CreatorDataShow struct {
Archive int `json:"archive"`
Article int `json:"article"`
}
// AppFan for stat.
type AppFan struct {
Summary map[string]int64 `json:"summary"`
}
//for fan manager top mids.
const (
//Total 粉丝管理-累计数据
Total = iota
//Seven 粉丝管理-7日数据
Seven
//Thirty 粉丝管理-30日数据
Thirty
//Ninety 粉丝管理-90日数据
Ninety
//PlayDuration 播放时长
PlayDuration = "video_play"
//VideoAct 视频互动
VideoAct = "video_act"
//DynamicAct 动态互动
DynamicAct = "dynamic_act"
)
// WebFan for stat.
type WebFan struct {
RankMap map[string]map[string]int32 `json:"-"`
Summary map[string]int32 `json:"summary"`
RankList map[string][]*RankInfo `json:"rank_list"`
RankMedal map[string][]*medal.FansRank `json:"rank_medal"`
Source map[string]int32 `json:"source"`
}
// RankInfo str
type RankInfo struct {
MID int64 `json:"mid"`
Uname string `json:"uname"`
Photo string `json:"photo"`
}
// PlaySource for play soucre.
type PlaySource struct {
PlayProportion map[string]int32 `json:"play_proportion"`
PageSource map[string]int32 `json:"page_source"`
}
// ArchivePlay for archive play.
type ArchivePlay struct {
AID int64 `json:"aid"`
View int32 `json:"view"`
Rate int32 `json:"rate"`
CTime int32 `json:"ctime"`
Duration int64 `json:"duration"`
AvgDuration int64 `json:"avg_duration"`
Title string `json:"title"`
}
//ArchivePlayList for arc play list.
type ArchivePlayList struct {
ArcPlayList []*ArchivePlay `json:"arc_play_list"`
}

View File

@@ -0,0 +1,159 @@
package data
import (
"go-common/app/interface/main/creative/model/archive"
upgrpc "go-common/app/service/main/up/api/v1"
"go-common/app/service/main/up/model"
)
// ArchiveStat for archive stat.
type ArchiveStat struct {
Play int64 `json:"play"`
Dm int64 `json:"dm"`
Reply int64 `json:"reply"`
Coin int64 `json:"coin"`
Elec int64 `json:"elec"`
Fav int64 `json:"fav"`
Share int64 `json:"share"`
}
// ArchiveSource for archive source
type ArchiveSource struct {
Mainsite int64 `json:"mainsite"`
Outsite int64 `json:"outsite"`
Mobile int64 `json:"mobile"`
Others int64 `json:"others"`
WebPC int64 `json:"-"`
WebH5 int64 `json:"-"`
IOS int64 `json:"-"`
Android int64 `json:"-"`
}
// ArchiveGroup for archive group.
type ArchiveGroup struct {
Fans int64 `json:"fans"`
Guest int64 `json:"guest"`
}
// ArchiveArea for archive area.
type ArchiveArea struct {
Location string `json:"location"`
Count int64 `json:"count"`
}
// ArchiveData for single archive stats.
type ArchiveData struct {
ArchiveStat *ArchiveStat `json:"stat"`
ArchiveSource *ArchiveSource `json:"source"`
ArchiveGroup *ArchiveGroup `json:"group"`
ArchiveAreas []*ArchiveArea `json:"area"`
Videos []*archive.SimpleVideo `json:"videos,omitempty"`
}
// UpBaseStat for up base.
type UpBaseStat struct {
View int64 `json:"view"` //播放
Reply int64 `json:"reply"` //评论
Dm int64 `json:"dm"` //弹幕
Fans int64 `json:"fans"` //粉丝
Fav int64 `json:"fav"` //收藏
Like int64 `json:"like"` //喜欢
}
//CopyTo copy to
func (u *UpBaseStat) CopyTo(stat *model.UpBaseStat) {
stat.Dm = u.Dm
stat.Fans = u.Fans
stat.Fav = u.Fav
stat.View = u.View
stat.Reply = u.Reply
stat.Like = u.Like
}
// CopyToReply copy to reply
func (u *UpBaseStat) CopyToReply(stat *upgrpc.UpBaseStatReply) {
if u == nil {
return
}
stat.Dm = u.Dm
stat.Fans = u.Fans
stat.Fav = u.Fav
stat.View = u.View
stat.Reply = u.Reply
stat.Like = u.Like
}
// ViewerBase for up base data analysis.
type ViewerBase struct {
Male int64 `json:"male"`
Female int64 `json:"female"`
AgeOne int64 `json:"age_one"`
AgeTwo int64 `json:"age_two"`
AgeThree int64 `json:"age_three"`
AgeFour int64 `json:"age_four"`
PlatPC int64 `json:"plat_pc"`
PlatH5 int64 `json:"plat_h5"`
PlatOut int64 `json:"plat_out"`
PlatIOS int64 `json:"plat_ios"`
PlatAndroid int64 `json:"plat_android"`
PlatOtherApp int64 `json:"plat_other_app"`
}
// ViewerActionHour for up action data analysis.
type ViewerActionHour struct {
View map[int]int `json:"view"`
Reply map[int]int `json:"reply"`
Dm map[int]int `json:"danmu"`
Elec map[int]int `json:"elec"`
Contract map[int]int `json:"contract"`
}
// Trend for up trend data analysis.
type Trend struct {
Ty map[int]int64
Tag map[int]int64
}
// UpDataIncrMeta for Play/Dm/Reply/Fav/Share/Elec/Coin incr.
type UpDataIncrMeta struct {
Incr int `json:"-"`
TopAIDList map[int]int64 `json:"-"`
TopIncrList map[int]int `json:"-"`
Rank map[int]int `json:"-"`
TyRank map[string]int `json:"-"`
}
const (
//Play 播放相关.
Play = int8(1)
//Dm 弹幕相关.
Dm = int8(2)
//Reply 评论相关.
Reply = int8(3)
//Share 分享相关.
Share = int8(4)
//Coin 投币相关.
Coin = int8(5)
//Fav 收藏相关.
Fav = int8(6)
//Elec 充电相关.
Elec = int8(7)
)
var (
typeNameMap = map[int8]string{
Play: "play",
Dm: "dm",
Reply: "reply",
Share: "share",
Coin: "coin",
Fav: "fav",
Elec: "elec",
}
)
//IncrTy return incr data type.
func IncrTy(ty int8) (val string, ok bool) {
val, ok = typeNameMap[ty]
return
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,51 @@
syntax = "proto3";
package model;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
message UpSpecial {
int64 ID = 1 [(gogoproto.jsontag) = "id"];
int64 GroupID = 2 [(gogoproto.jsontag) = "group_id"];
string GroupName = 3 [(gogoproto.jsontag) = "group_name"];
string GroupTag = 4 [(gogoproto.jsontag) = "group_tag"];
int64 Mid = 5 [(gogoproto.jsontag) = "mid"];
string Note = 6 [(gogoproto.jsontag) = "note"];
int64 CTime = 7 [(gogoproto.jsontag) = "ctime", (gogoproto.casttype) = "go-common/library/time.Time"];
int64 UID = 8 [(gogoproto.jsontag) = "uid"];
int64 MTime = 9 [(gogoproto.jsontag) = "mtime", (gogoproto.casttype) = "go-common/library/time.Time"];
string FontColor = 10 [(gogoproto.jsontag) = "font_color"];
string BgColor = 11 [(gogoproto.jsontag) = "bg_color"];
}
message UpInfo {
int32 isAuthor = 1 [(gogoproto.jsontag) = "isAuthor"];
}
message UpGroup {
int64 ID = 1 [(gogoproto.jsontag) = "id"];
string name = 2 [(gogoproto.jsontag) = "name"];
string tag = 3 [(gogoproto.jsontag) = "tag"];
string short_tag = 4 [(gogoproto.jsontag) = "short_tag"];
string remark = 5 [(gogoproto.jsontag) = "remark"];
int32 state = 6 [(gogoproto.jsontag) = "state"];
string FontColor = 7 [(gogoproto.jsontag) = "font_color"];
string BgColor = 8 [(gogoproto.jsontag) = "bg_color"];
}
message UpBaseStat {
int64 View = 1 [(gogoproto.jsontag) = "view"];
int64 Reply =2[(gogoproto.jsontag) ="reply"];
int64 Dm =3 [(gogoproto.jsontag) ="dm"];
int64 Fans = 4 [(gogoproto.jsontag) ="fans"];
int64 Fav = 5[(gogoproto.jsontag) ="fav"];
int64 Like = 6 [(gogoproto.jsontag) ="like"];
}
message PBSetUpSwitchRes {
int64 id = 1 [(gogoproto.jsontag) = "id"];
}
message PBUpSwitch {
int32 state = 1 [(gogoproto.jsontag) = "state"];
}

View File

@@ -0,0 +1,13 @@
package model
// BAP for wechat msg.
type BAP struct {
UserName string `json:"username"`
Title string `json:"title"`
Content string `json:"content"`
URL string `json:"url"`
Ty string `json:"type"`
Token string `json:"token"`
Signature string `json:"signature"`
TimeStamp int64 `json:"timestamp"`
}

View File

@@ -0,0 +1,9 @@
package model
//Msg for databus consume.
type Msg struct {
MID int64 `json:"mid"`
From int `json:"from"`
IsAuthor int `json:"is_author"`
TimeStamp int64 `json:"timestamp"`
}

View File

@@ -0,0 +1,5 @@
gopath="$GOPATH/src"
protobuf_path="$gopath/go-common/vendor/github.com/gogo/protobuf"
echo $protobuf_path
ls "$gopath/go-common/vendor/github.com/gogo/protobuf/gogoproto/"
protoc --gofast_out=".." -I"../" -I"$gopath/go-common/vendor/" ../*.proto

View File

@@ -0,0 +1,28 @@
package model
import "time"
//ArgSpecial special arg
type ArgSpecial struct {
GroupID int64
}
//ArgInfo info arg
type ArgInfo struct {
Mid int64
From int
}
//ArgMidWithDate arg mid with date
type ArgMidWithDate struct {
Mid int64
Date time.Time // 需要查询的时间,如果不填,会使用当前最新的数据
}
//ArgUpSwitch info arg
type ArgUpSwitch struct {
Mid int64
State int
From int
IP string
}

View File

@@ -0,0 +1,12 @@
package model
import "go-common/library/time"
// SignUp table sign_up
type SignUp struct {
ID int64
Mid int64
State int
BeginDate time.Time
EndDate time.Time
}

View File

@@ -0,0 +1,97 @@
package model
const (
// IsUp is up
IsUp = 1
// NotUp not up
NotUp = 0
)
//Up for db.
type Up struct {
ID int64 `json:"id"`
MID int64 `json:"mid"`
Attribute int `json:"attribute"`
}
//Info for auth by all platform
type Info struct {
Archive int `json:"archive"`
ArchiveFake int `json:"archive_fake"`
}
// IdentifyAll for all type of uper identify.
type IdentifyAll struct {
Archive int `json:"archive"`
Article int `json:"article"`
Pic int `json:"pic"`
Blink int `json:"blink"`
}
// AttrSet set attribute.
func (u *Up) AttrSet(v int, bit uint8) {
u.Attribute = u.Attribute&(^(1 << bit)) | (v << bit)
}
// AttrVal get attribute.
func (u *Up) AttrVal(bit uint8) int {
return (u.Attribute >> bit) & int(1)
}
// Const State
const (
// AttrNo attribute yes and no
AttrNo = int(0)
AttrYes = int(1)
// AttrArchiveUp attribute bit
AttrArchiveUp = uint8(0)
AttrArchiveNewUp = uint8(1)
AttrLiveUp = uint8(2)
AttrLiveWhiteUp = uint8(3)
)
var (
_attr = map[int]int{
AttrNo: AttrNo,
AttrYes: AttrYes,
}
_bits = map[uint8]string{
AttrArchiveUp: "稿件作者-有过审稿",
AttrArchiveNewUp: "稿件作者-有投过稿",
AttrLiveUp: "直播作者",
AttrLiveWhiteUp: "直播白名单",
}
)
// BitDesc return bit desc.
func BitDesc(bit uint8) (desc string) {
return _bits[bit]
}
// InAttr in correct attrs.
func InAttr(attr int) (ok bool) {
_, ok = _attr[attr]
return
}
// ListUpBaseArg arg
type ListUpBaseArg struct {
LastID int64 `form:"last_id"`
Size int `form:"size"`
Activity []int64 `form:"activity,split"`
}
// Validate ListUpBaseArg
func (arg *ListUpBaseArg) Validate() bool {
if arg.Size < 0 || arg.Size > 1000 || arg.LastID < 0 {
return false
}
if len(arg.Activity) > 0 {
for _, v := range arg.Activity {
if v < 0 || v > 4 {
return false
}
}
}
return true
}

View File

@@ -0,0 +1,84 @@
package model
import "go-common/library/time"
//ListUpCardInfoArg arg
type ListUpCardInfoArg struct {
Pn uint `form:"pn"` // page num
Ps uint `form:"ps"` // query size
}
//UpCardInfoPage page result of card info
type UpCardInfoPage struct {
Cards map[int64]*UpCard `json:"cards"`
Page *Pager `json:"page"`
}
//GetCardByMidArg arg
type GetCardByMidArg struct {
Mid int64 `form:"mid" validate:"required"`
}
//ListCardByMidsArg arg
type ListCardByMidsArg struct {
Mids string `form:"mids" validate:"required"` // mids split by ","
}
//UpCard up card content
type UpCard struct {
UpCardInfo *UpCardInfo `json:"up_card_info"`
Accounts []*UpCardAccount `json:"accounts"`
Videos []*UpCardVideo `json:"videos"`
Images []*UpCardImage `json:"images"`
}
//UpCardInfo for up info in card info
type UpCardInfo struct {
MID int64 `json:"mid"`
NameCN string `json:"name_cn"`
NameEN string `json:"name_en"`
NameAlias string `json:"name_alias"`
Signature string `json:"signature"`
Content string `json:"content"`
Nationality string `json:"nationality"`
Nation string `json:"nation"`
Gender string `json:"gender"`
BloodType string `json:"blood_type"`
Constellation string `json:"constellation"`
Height int `json:"height"`
Weight int `json:"weight"`
BirthPlace string `json:"birth_place"`
BirthDate time.Time `json:"birth_date"`
Occupation string `json:"occupation"`
Tags string `json:"tags"`
Masterpieces string `json:"masterpieces"`
School string `json:"school"`
Location string `json:"location"`
Interests string `json:"interests"`
Platform string `json:"platform"`
PlatformAccount string `json:"platform_account"`
}
//UpCardAccount for accounts in card info
type UpCardAccount struct {
URL string `json:"url"`
Title string `json:"title"`
Desc string `json:"desc"`
Picture string `json:"picture"`
}
//UpCardImage for images in card info
type UpCardImage struct {
URL string `json:"url"`
Width int `json:"width"`
Height int `json:"height"`
}
//UpCardVideo for videos in card info
type UpCardVideo struct {
URL string `json:"url"`
Title string `json:"title"`
Picture string `json:"picture"`
Duration int64 `json:"duration"`
CTime time.Time `json:"ctime"`
}

View File

@@ -0,0 +1,27 @@
package model
//AddGroupArg arg
type AddGroupArg struct {
Name string `form:"name" validate:"required"`
Tag string `form:"tag" validate:"required"`
ShortTag string `form:"short_tag"`
FontColor string `form:"font_color"`
BgColor string `form:"bg_color"`
Remark string `from:"remark"`
}
//EditGroupArg arg
type EditGroupArg struct {
AddArg *AddGroupArg
ID int64 `form:"id" validate:"required"`
}
//RemoveGroupArg arg
type RemoveGroupArg struct {
ID int32 `form:"id" validate:"required"`
}
//GetGroupArg arg
type GetGroupArg struct {
State int `form:"state"`
}

View File

@@ -0,0 +1,18 @@
package model
// UpInfoActiveReq req
type UpInfoActiveReq struct {
Mid int64 `form:"mid" validate:"required"`
}
// UpsInfoActiveReq req
type UpsInfoActiveReq struct {
Mids []int64 `form:"mids,split" validate:"required,dive,gt=0"`
}
// UpInfoActiveReply Reply
type UpInfoActiveReply struct {
ID int64 `json:"id"`
MID int64 `json:"mid"`
ActiveTid int16 `json:"active_tid"`
}

View File

@@ -0,0 +1,79 @@
package model
import (
"fmt"
"github.com/siddontang/go-mysql/mysql"
"time"
)
//GetSpecialArg arg
type GetSpecialArg struct {
GroupID int `form:"group_id"`
UID int `form:"uid"`
FromTime string `form:"from_time"` // "2006-01-02 15:04:05"
ToTime string `form:"to_time"` // "2006-01-02 15:04:05"
Order string `form:"order" ` // 根据mtime排序默认从升序, 取值asc/desc
Export string `form:"export"` // csv
Charset string `form:"charset"` // 导出编码格式默认gbk
Pn uint `form:"pn"` // 页码默认1
Ps uint `form:"ps"` // 每页数量默认20
Mids string `form:"mids"` // 用户ids,以,分隔
AdminName string `form:"admin_name"` // 管理员昵称
}
//UpSpecialWithName arg with name
type UpSpecialWithName struct {
UpSpecial
UName string `json:"uname"`
AdminName string `json:"admin_name"`
}
//GetSpecialByMidArg arg
type GetSpecialByMidArg struct {
Mid int `form:"mid" validate:"required"`
}
//Copy copy
func (u *UpSpecialWithName) Copy(special *UpSpecial) {
u.UpSpecial = *special
}
//GetTitleFields get title fields
func (u *UpSpecialWithName) GetTitleFields() []string {
return []string{
"配置时间",
"MID",
"昵称",
"所属用户组",
"描述",
"配置人",
"用户组Id",
}
}
//ToStringFields get to string fields
func (u *UpSpecialWithName) ToStringFields() []string {
var fields []string
var mtime = time.Unix(int64(u.MTime), 0)
fields = append(fields, fmt.Sprintf("%v", mtime.Format(mysql.TimeFormat)))
fields = append(fields, fmt.Sprintf("%v", u.Mid))
fields = append(fields, fmt.Sprintf("%v", u.UName))
fields = append(fields, fmt.Sprintf("%v", u.GroupName))
fields = append(fields, fmt.Sprintf("%v", u.Note))
fields = append(fields, fmt.Sprintf("%v", u.AdminName))
fields = append(fields, fmt.Sprintf("%v", u.GroupID))
return fields
}
// UpsPage CategoryPager def.
type UpsPage struct {
Items []*UpSpecialWithName `json:"items"`
Pager *Pager `json:"page"`
}
// Pager Common Pager def.
type Pager struct {
Num uint `json:"num"`
Size uint `json:"size"`
Total int `json:"total"`
}

View File

@@ -0,0 +1,33 @@
package model
const (
// Open is open switch
Open = 1
// Close is close switch
Close = 0
)
//UpSwitch for db.
type UpSwitch struct {
ID int64 `json:"id"`
MID int64 `json:"mid"`
Attribute int `json:"attribute"`
}
// AttrSet set attribute.
func (u *UpSwitch) AttrSet(v int, bit uint8) {
u.Attribute = u.Attribute&(^(1 << bit)) | (v << bit)
}
// AttrVal get attribute.
func (u *UpSwitch) AttrVal(bit uint8) int {
return (u.Attribute >> bit) & int(1)
}
// Const State
const (
// AttrPlayer flow up window 's switch of attribute bit
AttrPlayer = uint8(0)
// AttrHonorWeekly honor weekly subscription 's switch of attribute bit
AttrHonorWeekly = uint8(1)
)