dao

package
v0.0.0-...-83adff0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2020 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INFO_ROOM = 1 << iota
	INFO_ROOM_EXT
	INFO_TAG
	INFO_ANCHOR
	INFO_SHORT_ID
	INFO_AREA_INFO
)
View Source
const (
	//弹幕
	//DANMU_NUM 当前弹幕累计数量
	DANMU_NUM = "danmu_num"
	//DANMU_MINUTE_NUM_15 最近15分钟弹幕数量
	DANMU_MINUTE_NUM_15 = "danmu_minute_num_15"
	//DANMU_MINUTE_NUM_30 ...
	DANMU_MINUTE_NUM_30 = "danmu_minute_num_30"
	//DANMU_MINUTE_NUM_45 ...
	DANMU_MINUTE_NUM_45 = "danmu_minute_num_45"
	//DANMU_MINUTE_NUM_60 ...
	DANMU_MINUTE_NUM_60 = "danmu_minute_num_60"
	//人气
	//POPULARITY 当前实时人气
	POPULARITY = "popularity"
	//POPULARITY_MAX_TO_ARG_7 7日峰值人气的均值
	POPULARITY_MAX_TO_ARG_7 = "popularity_max_to_avg_7"
	//POPULARITY_MAX_TO_ARG_30 30日人气峰值的均值
	POPULARITY_MAX_TO_ARG_30 = "popularity_max_to_avg_30"
	//送礼
	//GIFT_NUM 实时送礼数
	GIFT_NUM = "gift_num_current_total"
	//GIFT_GOLD_AMOUNT 实时消费金瓜子数
	GIFT_GOLD_NUM = "gift_gold_num"
	//GIFT_GOLD_AMOUNT 实时消费金瓜子金额
	GIFT_GOLD_AMOUNT = "gift_gold_amount"
	//GIFT_GOLD_AMOUNT_MINUTE_15 最近15分钟金瓜子金额
	GIFT_GOLD_AMOUNT_MINUTE_15 = "gift_gold_num_minute_15"
	//GIFT_GOLD_AMOUNT_MINUTE_30 最近30分钟金瓜子金额
	GIFT_GOLD_AMOUNT_MINUTE_30 = "gift_gold_num_minute_30"
	//GIFT_GOLD_AMOUNT_MINUTE_45 ...
	GIFT_GOLD_AMOUNT_MINUTE_45 = "gift_gold_num_minute_45"
	//GIFT_GOLD_AMOUNT_MINUTE_60 ...
	GIFT_GOLD_AMOUNT_MINUTE_60 = "gift_gold_num_minute_60"
	//有效开播天数
	//VALID_LIVE_DAYS_TYPE_1_DAY_7 7日内有效开播天数;有效开播:一次开播大于5分钟
	VALID_LIVE_DAYS_TYPE_1_DAY_7 = "valid_days_type_1_day_7"
	//VALID_LIVE_DAYS_TYPE_1_DAY_14 14日内有效开播天数;有效开播:一次开播大于5分钟
	VALID_LIVE_DAYS_TYPE_1_DAY_14 = "valid_days_type_1_day_14"
	//VALID_LIVE_DAYS_TYPE_2_DAY_7 7日内有效开播天数;有效开播:大于等于120分钟
	VALID_LIVE_DAYS_TYPE_2_DAY_7 = "valid_days_type_2_day_7"
	//VALID_LIVE_DAYS_TYPE_2_DAY_30 14日内有效开播天数;有效开播:大于等于120分钟
	VALID_LIVE_DAYS_TYPE_2_DAY_30 = "valid_days_type_2_day_30"
	//房间状态
	//ROOM_TAG_CURRENT 房间实时标签
	ROOM_TAG_CURRENT = "room_tag_current"
	//榜单
	//RANK_LIST_CURRENT 排行榜相关数据
	RANK_LIST_CURRENT = "rank_list_current"
	//DAU
	DAU = "dau"
)

消费类型常量 定义

View Source
const (
	LIVE_OPEN  = 1
	LIVE_CLOSE = 0
	LIVE_ROUND = 2
)

房間狀態常量

View Source
const (
	ATTRID_POPULARITY      = 1
	ATTRID_REVENUE         = 2
	ATTRID_DANMU           = 3
	ATTRID_RANK_LIST       = 4
	ATTRID_VALID_LIVE_DAYS = 5
)

attr表相关常量定义

View Source
const (
	//ATTRSUBID_POPULARITY_REALTIME 实时人气值
	ATTRSUBID_POPULARITY_REALTIME = 1
	//ATTRSUBID_POPULARITY_MAX_TO_ARG_7 7日人气峰值的均值
	ATTRSUBID_POPULARITY_MAX_TO_ARG_7 = 2
	//ATTRSUBID_POPULARITY_MAX_TO_ARG_30 30日人气峰值的均值
	ATTRSUBID_POPULARITY_MAX_TO_ARG_30 = 3
)
View Source
const (
	//ATTRSUBID_REVENUE_MINUTE_NUM_15  15分钟营收
	ATTRSUBID_REVENUE_MINUTE_NUM_15 = 1
	//ATTRSUBID_REVENUE_MINUTE_NUM_30  30分钟营收
	ATTRSUBID_REVENUE_MINUTE_NUM_30 = 2
	//ATTRSUBID_REVENUE_MINUTE_NUM_45  45分钟营收
	ATTRSUBID_REVENUE_MINUTE_NUM_45 = 3
	//ATTRSUBID_REVENUE_MINUTE_NUM_60  60分钟营收
	ATTRSUBID_REVENUE_MINUTE_NUM_60 = 4
)
View Source
const (
	//ATTRSUBID_DANMU_MINUTE_NUM_15  15分钟弹幕
	ATTRSUBID_DANMU_MINUTE_NUM_15 = 1
	//ATTRSUBID_DANMU_MINUTE_NUM_30  30分钟弹幕
	ATTRSUBID_DANMU_MINUTE_NUM_30 = 2
	//ATTRSUBID_DANMU_MINUTE_NUM_45  45分钟弹幕
	ATTRSUBID_DANMU_MINUTE_NUM_45 = 3
	//ATTRSUBID_DANMU_MINUTE_NUM_60  60分钟弹幕
	ATTRSUBID_DANMU_MINUTE_NUM_60 = 4
)
View Source
const (
	VALID_LIVE_DAYS_TYPE_1 = 1 //一次开播大于5分钟
	VALID_LIVE_DAYS_TYPE_2 = 2 // 累加大于等于120分钟
)

有效开播天数

View Source
const (
	//ATTRSUBID_VALID_LIVE_DAYS_TYPE_1_DAY_7 近7天的有效天数,(有效天数:一次开播大于5分钟)
	ATTRSUBID_VALID_LIVE_DAYS_TYPE_1_DAY_7 = 1
	//ATTRSUBID_VALID_LIVE_DAYS_TYPE_1_DAY_14 近14天的有效天数,(有效天数:一次开播大于5分钟)
	ATTRSUBID_VALID_LIVE_DAYS_TYPE_1_DAY_14 = 2
	//ATTRSUBID_VALID_LIVE_DAYS_TYPE_2_DAY_7 近7天的有效天数,(有效天数:累加大于等于120分钟)
	ATTRSUBID_VALID_LIVE_DAYS_TYPE_2_DAY_7 = 3
	//ATTRSUBID_VALID_LIVE_DAYS_TYPE_2_DAY_30 近30天的有效天数,(有效天数:累加大于等于120分钟)
	ATTRSUBID_VALID_LIVE_DAYS_TYPE_2_DAY_30 = 4
)
View Source
const (
	TAGID_PK          = 1
	TAGID_LOTTERY     = 2
	ROOM_EXT_SHARDING = 10

	EXP_2_SCORE_RATE = 100
)

tag表相关常量定义

View Source
const (
	NEED_INSERT = 1
	NEED_UPDATE = 2
)
View Source
const (
	//ATTRSUBID_RANK_HOUR 小时榜
	ATTRSUBID_RANK_HOUR = 1
)
View Source
const DATE = "date" //是否最新消息,是为1(需要刷新到DB) 否为0(不需要刷新到DB)
View Source
const DATE_1 = "1"
View Source
const (
	FETCH_PAGE_SIZE = 100
)
View Source
const VALUE = "value"

Variables

This section is empty.

Functions

func RoomAttrNeedSet

func RoomAttrNeedSet(d *Dao, ctx context.Context, req *v1pb.RoomAttrSetExReq) (resp int, err error)

roomAttrNeedSet 内部函数 0 不需要set 1 需要insert 2 需要update

Types

type Dao

type Dao struct {
	// contains filtered or unexported fields
}

Dao dao

func New

func New(c *conf.Config) (dao *Dao)

New init mysql db

func (*Dao) AnchorBatchIncre

func (d *Dao) AnchorBatchIncre(ctx context.Context, req *v1pb.AnchorBatchIncreReq) (resp *v1pb.UpdateResp, err error)

AnchorBatchIncre implementation AnchorBatchIncre 主播增量更新

func (*Dao) AnchorBatchUpdate

func (d *Dao) AnchorBatchUpdate(ctx context.Context, req *v1pb.AnchorBatchUpdateReq) (resp *v1pb.UpdateResp, err error)

AnchorBatchUpdate implementation AnchorBatchUpdate 主播更新

func (*Dao) AnchorIncre

func (d *Dao) AnchorIncre(ctx context.Context, req *v1pb.AnchorIncreReq) (resp *v1pb.UpdateResp, err error)

AnchorIncre implementation AnchorIncre 主播增量更新

func (*Dao) AnchorUpdate

func (d *Dao) AnchorUpdate(ctx context.Context, req *v1pb.AnchorUpdateReq) (resp *v1pb.UpdateResp, err error)

AnchorUpdate implementation AnchorUpdate 主播更新

func (*Dao) CanConsume

func (d *Dao) CanConsume(ctx context.Context, msg *databus.Message) bool

CanConsume 是否可以消费

func (*Dao) Close

func (d *Dao) Close()

Close close the resource.

func (*Dao) DelRoomRecordsCurrent

func (d *Dao) DelRoomRecordsCurrent(ctx context.Context, content string, roomIds []int64) (err error)

func (*Dao) DeleteAttr

func (d *Dao) DeleteAttr(ctx context.Context, req *v1pb.DeleteAttrReq) (resp *v1pb.UpdateResp, err error)

DeleteAttr implementation DeleteAttr 删除一个指标

func (*Dao) FetchAreas

func (d *Dao) FetchAreas(ctx context.Context, req *v1pb.FetchAreasReq) (resp *v1pb.FetchAreasResp, err error)

FetchAreas implementation FetchAreas 根据父分区号查询子分区

func (*Dao) FetchAttrByIDs

func (d *Dao) FetchAttrByIDs(ctx context.Context, req *v1pb.FetchAttrByIDsReq) (resp *v1pb.FetchAttrByIDsResp, err error)

FetchAttrByIDs implementation FetchAttrByIDs 批量根据房间号查询指标

func (*Dao) FetchRoomByIDs

func (d *Dao) FetchRoomByIDs(ctx context.Context, req *v1pb.RoomByIDsReq) (resp *v1pb.RoomByIDsResp, err error)

FetchRoomByIDs implementation FetchRoomByIDs 查询房间信息

func (*Dao) GetList

func (d *Dao) GetList(ctx context.Context, redisKey string, start int, end int) (resp []*ListIntValueInfo, err error)

func (*Dao) GetRoomLiveRecordsRange

func (d *Dao) GetRoomLiveRecordsRange(ctx context.Context, content string, roomIds []int64, liveTime int64, start, end int) (resp map[int64][]*ListIntValueInfo, err error)

GetRoomLiveRecordsRange can partially succeed, and in this case, err is still nil.

func (*Dao) GetRoomRecordsCurrent

func (d *Dao) GetRoomRecordsCurrent(ctx context.Context, content string, roomIds []int64) (list []int64, err error)

GetRoomRecordsCurrent return a list of records corresponding to `content`.

func (*Dao) HGet

func (d *Dao) HGet(ctx context.Context, redisKey string) (resp int64, err error)

func (*Dao) Incr

func (d *Dao) Incr(ctx context.Context, redisKey string, value int64, timeOut int) (err error)

Incr 设置增加数据

func (*Dao) LRoomLiveRecordList

func (d *Dao) LRoomLiveRecordList(content string, roomId int64, liveTime int64) (resp *redisKeyResp)

RoomRecordListForLive 房间侧开播记录相关历史数据,存3天

func (*Dao) LRoomRecordList

func (d *Dao) LRoomRecordList(contentType string, roomId int64) (resp *redisKeyResp)

RoomRecordList 房间侧记录相关历史数据,存1天

func (*Dao) LUserLiveRecordList

func (d *Dao) LUserLiveRecordList(content string, uid int64, liveTime int64) (resp *redisKeyResp)

主播侧开播记录相关历史数据,存3天

func (*Dao) LUserRecordList

func (d *Dao) LUserRecordList(contentType string, uid int64) (resp *redisKeyResp)

主播侧记录相关历史数据,存1天

func (*Dao) Ping

func (d *Dao) Ping(c context.Context) error

Ping dao ping

func (*Dao) RoomAttrCreate

func (d *Dao) RoomAttrCreate(ctx context.Context, req *v1pb.RoomAttrCreateReq) (resp *v1pb.UpdateResp, err error)

RoomAttrCreate implementation RoomAttrCreate 房间Attr创建

func (*Dao) RoomAttrSetEx

func (d *Dao) RoomAttrSetEx(ctx context.Context, req *v1pb.RoomAttrSetExReq) (resp *v1pb.UpdateResp, err error)

RoomAttrSetEx implementation RoomAttrSetEx 房间Attr更新

func (*Dao) RoomBatchUpdate

func (d *Dao) RoomBatchUpdate(ctx context.Context, req *v1pb.RoomBatchUpdateReq) (resp *v1pb.UpdateResp, err error)

RoomBatchUpdate implementation RoomBatchUpdate 房间更新

func (*Dao) RoomCreate

func (d *Dao) RoomCreate(ctx context.Context, req *v1pb.RoomCreateReq) (resp *v1pb.RoomCreateResp, err error)

RoomCreate implementation RoomCreate 房间创建

func (*Dao) RoomExtendBatchIncre

func (d *Dao) RoomExtendBatchIncre(ctx context.Context, req *v1pb.RoomExtendBatchIncreReq) (resp *v1pb.UpdateResp, err error)

RoomExtendBatchIncre implementation RoomExtendBatchIncre 房间增量更新

func (*Dao) RoomExtendBatchUpdate

func (d *Dao) RoomExtendBatchUpdate(ctx context.Context, req *v1pb.RoomExtendBatchUpdateReq) (resp *v1pb.UpdateResp, err error)

RoomExtendBatchUpdate implementation RoomExtendBatchUpdate 房间更新

func (*Dao) RoomExtendIncre

func (d *Dao) RoomExtendIncre(ctx context.Context, req *v1pb.RoomExtendIncreReq) (resp *v1pb.UpdateResp, err error)

RoomExtendIncre implementation RoomExtendIncre 房间增量更新

func (*Dao) RoomExtendUpdate

func (d *Dao) RoomExtendUpdate(ctx context.Context, req *v1pb.RoomExtendUpdateReq) (resp *v1pb.UpdateResp, err error)

RoomExtendUpdate implementation RoomExtendUpdate 房间更新

func (*Dao) RoomOnlineList

func (d *Dao) RoomOnlineList(ctx context.Context, req *v1pb.RoomOnlineListReq) (resp *v1pb.RoomOnlineListResp, err error)

RoomOnlineList implementation RoomOnlineList 在线房间列表

func (*Dao) RoomOnlineListByArea

func (d *Dao) RoomOnlineListByArea(ctx context.Context, req *v1pb.RoomOnlineListByAreaReq) (resp *v1pb.RoomOnlineListByAreaResp, err error)

RoomOnlineListByArea implementation RoomOnlineListByArea 分区在线房间列表

func (*Dao) RoomOnlineListByAttrs

func (d *Dao) RoomOnlineListByAttrs(ctx context.Context, req *v1pb.RoomOnlineListByAttrsReq) (resp *v1pb.RoomOnlineListByAttrsResp, err error)

RoomOnlineListByAttrs implementation RoomOnlineListByAttrs 在线房间维度信息(不传attrs,不查询attr)

func (*Dao) RoomTagCreate

func (d *Dao) RoomTagCreate(ctx context.Context, req *v1pb.RoomTagCreateReq) (resp *v1pb.UpdateResp, err error)

RoomTagCreate implementation RoomTagCreate 房间Tag创建

func (*Dao) RoomUpdate

func (d *Dao) RoomUpdate(ctx context.Context, req *v1pb.RoomUpdateReq) (resp *v1pb.UpdateResp, err error)

RoomUpdate implementation RoomUpdate 房间更新

func (*Dao) SRoomRecordCurrent

func (d *Dao) SRoomRecordCurrent(content string, roomId int64) (resp *redisKeyResp)

RoomRecordCurrent 房间侧实时数据记录,存一个小时

func (*Dao) SUserRecordCurrent

func (d *Dao) SUserRecordCurrent(content string, uid int64) (resp *redisKeyResp)

UserRecordCurrent 主播侧实时数据记录,存一个小时

func (*Dao) Set

func (d *Dao) Set(ctx context.Context, redisKey string, value string, timeOut int) (err error)

Set 设置实时数据

func (*Dao) SetList

func (d *Dao) SetList(ctx context.Context, redisKey string, value string, timeOut int) (err error)

func (*Dao) SetRoomRecordsList

func (d *Dao) SetRoomRecordsList(ctx context.Context, roomIds []int64, keys map[int64]interface{}, values map[int64]string) (err error)

type ListIntValueInfo

type ListIntValueInfo struct {
	Value int64 `json:"value"`
	Time  int64 `json:"time"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL