dao

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDeleteOtherCollection = errors.New("删除非本人的收藏夹")
View Source
var (
	ErrRecordNotFound = gorm.ErrRecordNotFound
)

Functions

func InitTables

func InitTables(db *egorm.Component) error

Types

type Collection added in v0.1.8

type Collection struct {
	Id int64 `gorm:"primaryKey,autoIncrement"`
	// 在 Uid 和 Name 上创建唯一索引,确保用户不会创建同名收藏夹
	Uid   int64  `gorm:"uniqueIndex:uid_name"`
	Name  string `gorm:"type:varchar(256);uniqueIndex:uid_name"`
	Utime int64
	Ctime int64
}

type GORMInteractiveDAO

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

func NewInteractiveDAO

func NewInteractiveDAO(db *egorm.Component) *GORMInteractiveDAO

func (*GORMInteractiveDAO) CollectToggle

func (g *GORMInteractiveDAO) CollectToggle(ctx context.Context, cb UserCollectionBiz) error

func (*GORMInteractiveDAO) CollectionInfo added in v0.2.1

func (g *GORMInteractiveDAO) CollectionInfo(ctx context.Context, collectionId int64) ([]UserCollectionBiz, error)

func (*GORMInteractiveDAO) CollectionInfoWithPage added in v0.2.1

func (g *GORMInteractiveDAO) CollectionInfoWithPage(ctx context.Context, uid, collectionId int64, offset, limit int) ([]UserCollectionBiz, error)

func (*GORMInteractiveDAO) CollectionList added in v0.2.1

func (g *GORMInteractiveDAO) CollectionList(ctx context.Context, uid int64, offset, limit int) ([]Collection, error)

func (*GORMInteractiveDAO) DecrCollectCount added in v0.2.1

func (g *GORMInteractiveDAO) DecrCollectCount(ctx context.Context, biz string, bizid int64) error

func (*GORMInteractiveDAO) DeleteCollection added in v0.2.1

func (g *GORMInteractiveDAO) DeleteCollection(ctx context.Context, uid, collectionId int64) error

func (*GORMInteractiveDAO) Get

func (*GORMInteractiveDAO) GetByIds

func (g *GORMInteractiveDAO) GetByIds(ctx context.Context, biz string, ids []int64) ([]Interactive, error)

func (*GORMInteractiveDAO) GetCollectInfo

func (g *GORMInteractiveDAO) GetCollectInfo(ctx context.Context, biz string, id int64, uid int64) (UserCollectionBiz, error)

func (*GORMInteractiveDAO) GetLikeInfo

func (g *GORMInteractiveDAO) GetLikeInfo(ctx context.Context, biz string, id int64, uid int64) (UserLikeBiz, error)

func (*GORMInteractiveDAO) IncrViewCnt

func (g *GORMInteractiveDAO) IncrViewCnt(ctx context.Context, biz string, bizId int64) error

func (*GORMInteractiveDAO) LikeToggle

func (g *GORMInteractiveDAO) LikeToggle(ctx context.Context, biz string, id int64, uid int64) error

func (*GORMInteractiveDAO) MoveCollection added in v0.2.1

func (g *GORMInteractiveDAO) MoveCollection(ctx context.Context, biz string, bizid, uid, collectionId int64) error

func (*GORMInteractiveDAO) SaveCollection added in v0.2.1

func (g *GORMInteractiveDAO) SaveCollection(ctx context.Context, collection Collection) (int64, error)

type Interactive

type Interactive struct {
	Id         int64  `gorm:"primaryKey,autoIncrement"`
	BizId      int64  `gorm:"uniqueIndex:biz_type_id"`
	Biz        string `gorm:"type:varchar(128);uniqueIndex:biz_type_id"`
	ViewCnt    int
	LikeCnt    int
	CollectCnt int
	Utime      int64
	Ctime      int64
}

Interactive 汇总表

type InteractiveDAO

type InteractiveDAO interface {
	IncrViewCnt(ctx context.Context, biz string, bizId int64) error
	LikeToggle(ctx context.Context, biz string, id int64, uid int64) error
	CollectToggle(ctx context.Context, cb UserCollectionBiz) error
	GetLikeInfo(ctx context.Context,
		biz string, id int64, uid int64) (UserLikeBiz, error)
	GetCollectInfo(ctx context.Context,
		biz string, id int64, uid int64) (UserCollectionBiz, error)
	Get(ctx context.Context, biz string, id int64) (Interactive, error)
	GetByIds(ctx context.Context, biz string, ids []int64) ([]Interactive, error)

	// 创建收藏夹
	SaveCollection(ctx context.Context, collection Collection) (int64, error)
	// 删除收藏夹
	DeleteCollection(ctx context.Context, uid, collectionId int64) error
	// 收藏夹列表
	CollectionList(ctx context.Context, uid int64, offset, limit int) ([]Collection, error)
	// 收藏夹下的收藏内容带分页
	CollectionInfoWithPage(ctx context.Context, uid, collectionId int64, offset, limit int) ([]UserCollectionBiz, error)
	// 收藏夹下的所有内容
	CollectionInfo(ctx context.Context, collectionId int64) ([]UserCollectionBiz, error)
	// 收藏转移
	MoveCollection(ctx context.Context, biz string, bizid, uid, collectionId int64) error
	// 减少计数
	DecrCollectCount(ctx context.Context, biz string, bizid int64) error
}

type UserCollectionBiz

type UserCollectionBiz struct {
	Id    int64  `gorm:"primaryKey,autoIncrement"`
	Uid   int64  `gorm:"uniqueIndex:uid_biz_type_id"`
	BizId int64  `gorm:"uniqueIndex:uid_biz_type_id"`
	Biz   string `gorm:"type:varchar(128);uniqueIndex:uid_biz_type_id"`

	// Cid 收藏夹id
	Cid   int64 `gorm:"index;not null;default(0)"`
	Utime int64
	Ctime int64
}

UserCollectionBiz 收藏明细表

type UserLikeBiz

type UserLikeBiz struct {
	Id    int64  `gorm:"primaryKey,autoIncrement"`
	Uid   int64  `gorm:"uniqueIndex:uid_biz_type_id"`
	BizId int64  `gorm:"uniqueIndex:uid_biz_type_id"`
	Biz   string `gorm:"type:varchar(128);uniqueIndex:uid_biz_type_id"`
	Utime int64
	Ctime int64
}

UserLikeBiz 点赞明细表

Jump to

Keyboard shortcuts

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