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: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dao

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

Dao dao.

func New

func New() (dao *Dao)

New new a dao and return.

func (*Dao) AddCacheTopicInfo

func (d *Dao) AddCacheTopicInfo(ctx context.Context, topicInfos map[int64]*api.TopicInfo) (err error)

AddCacheTopicInfo 添加topic info缓存

func (*Dao) AddCacheVideoExtension

func (d *Dao) AddCacheVideoExtension(ctx context.Context, extensions map[int64]*api.VideoExtension) (err error)

AddCacheVideoExtension 添加extension缓存

func (*Dao) CacheTopicInfo

func (d *Dao) CacheTopicInfo(ctx context.Context, topicIDs []int64) (res map[int64]*api.TopicInfo, err error)

CacheTopicInfo 从缓存获取topic info

func (*Dao) CacheVideoExtension

func (d *Dao) CacheVideoExtension(ctx context.Context, svids []int64) (res map[int64]*api.VideoExtension, err error)

CacheVideoExtension 从缓存获取extension

func (*Dao) Close

func (d *Dao) Close()

Close close the resource.

func (*Dao) DelCacheTopicInfo

func (d *Dao) DelCacheTopicInfo(ctx context.Context, topicID int64)

DelCacheTopicInfo 删除topic info缓存

func (*Dao) DelCacheVideoExtension

func (d *Dao) DelCacheVideoExtension(ctx context.Context, svid int64)

DelCacheVideoExtension 删除extension缓存

func (*Dao) GetStickTopic

func (d *Dao) GetStickTopic(ctx context.Context) (list []int64, err error)

GetStickTopic 获取置顶视频 TODO: 这个方式是临时之计,当qps增大时,会导致热点的产生

func (*Dao) GetStickTopicVideo

func (d *Dao) GetStickTopicVideo(ctx context.Context, topicID int64) (list []int64, err error)

GetStickTopicVideo 获取置顶视频

func (*Dao) GetVideoTopic

func (d *Dao) GetVideoTopic(ctx context.Context, svid int64) (list []*api.TopicVideoItem, err error)

GetVideoTopic 获取视频的话题列表

func (*Dao) InsertExtension

func (d *Dao) InsertExtension(ctx context.Context, svid int64, extensionType int64, extension *api.Extension) (rowsAffected int64, err error)

InsertExtension 插入extension到db

func (*Dao) InsertTopicVideo

func (d *Dao) InsertTopicVideo(ctx context.Context, svid int64, topicIDs []int64) (rowsAffected int64, err error)

InsertTopicVideo 插入topic video表

func (*Dao) InsertTopics

func (d *Dao) InsertTopics(ctx context.Context, topics map[string]*api.TopicInfo) (newTopics map[string]*api.TopicInfo, err error)

InsertTopics 插入话题

func (*Dao) ListRankTopics

func (d *Dao) ListRankTopics(ctx context.Context, page int32, size int32) (list []int64, hasMore bool, err error)

ListRankTopics 获取推荐的话题列表 TODO: 把置顶逻辑移上去

func (*Dao) ListTopicVideos

func (d *Dao) ListTopicVideos(ctx context.Context, topicID int64, cursorPrev, cursorNext string, size int) (res []*api.VideoItem, hasMore bool, err error)

ListTopicVideos 获取话题下排序的视频列表 按道理来说,Dao层不应该有那么多的复杂逻辑的,但是redis、db等操作在业务本身就是耦合在一起的,因此移到dao层,简化逻辑操作 TODO: 这里把置顶的数据放在了redis里,所以导致排序问题过于复杂,待修正

func (*Dao) ListUnAvailableTopics

func (d *Dao) ListUnAvailableTopics(ctx context.Context, page int32, size int32) (list []int64, hasMore bool, err error)

ListUnAvailableTopics .

func (*Dao) Ping

func (d *Dao) Ping(ctx context.Context) (err error)

Ping ping the resource.

func (*Dao) RawTopicInfo

func (d *Dao) RawTopicInfo(ctx context.Context, topicIDs []int64) (res map[int64]*api.TopicInfo, err error)

RawTopicInfo 从mysql获取topic info

func (*Dao) RawVideoExtension

func (d *Dao) RawVideoExtension(ctx context.Context, svids []int64) (res map[int64]*api.VideoExtension, err error)

RawVideoExtension 从mysql获取extension

func (*Dao) SetStickTopicVideo

func (d *Dao) SetStickTopicVideo(ctx context.Context, topicID int64, list []int64) (err error)

SetStickTopicVideo 设置置顶视频

func (*Dao) StickTopic

func (d *Dao) StickTopic(ctx context.Context, opTopicID, op int64) (err error)

StickTopic .

func (*Dao) StickTopicVideo

func (d *Dao) StickTopicVideo(ctx context.Context, opTopicID, opSvid, op int64) (err error)

StickTopicVideo 操作置顶视频

func (*Dao) TopicID

func (d *Dao) TopicID(ctx context.Context, names []string) (topics map[string]int64, err error)

TopicID 通过话题name获取话题ID 话题ID结果存在topics中

func (*Dao) TopicInfo

func (d *Dao) TopicInfo(c context.Context, keys []int64) (res map[int64]*api.TopicInfo, err error)

TopicInfo get data from cache if miss will call source method, then add to cache.

func (*Dao) UpdateTopic

func (d *Dao) UpdateTopic(ctx context.Context, topicID int64, field string, value interface{}) (err error)

UpdateTopic 更新话题,当前有简介和状态 这个函数把操作权其实已经交给上层了,设计上不是个好设计,但是在于避免重复代码

func (*Dao) UpdateVideoScore

func (d *Dao) UpdateVideoScore(ctx context.Context, svid int64, score float64) (err error)

UpdateVideoScore 更新视频的score

@param topicID: 携带的时候会修改指定的topicID的video的score,否则会全部修改

func (*Dao) UpdateVideoState

func (d *Dao) UpdateVideoState(ctx context.Context, svid int64, state int32) (err error)

UpdateVideoState 更新视频的state

func (*Dao) VideoExtension

func (d *Dao) VideoExtension(c context.Context, keys []int64) (res map[int64]*api.VideoExtension, err error)

VideoExtension get data from cache if miss will call source method, then add to cache.

Jump to

Keyboard shortcuts

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