biz

package
v0.0.0-...-066287a Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 10 Imported by: 0

README

Biz

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUserNotFound is user not found.
	ErrUserNotFound = errors.NotFound(v1.ErrorReason_USER_NOT_FOUND.String(), "user not found")
)

ProviderSet is biz providers.

Functions

This section is empty.

Types

type Greeter

type Greeter struct {
	Hello string
}

Greeter is a Greeter model.

type GreeterRepo

type GreeterRepo interface {
	Save(context.Context, *Greeter) (*Greeter, error)
	Update(context.Context, *Greeter) (*Greeter, error)
	FindByID(context.Context, int64) (*Greeter, error)
	ListByHello(context.Context, string) ([]*Greeter, error)
	ListAll(context.Context) ([]*Greeter, error)
}

GreeterRepo is a Greater repo.

type GreeterUsecase

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

GreeterUsecase is a Greeter usecase.

func NewGreeterUsecase

func NewGreeterUsecase(repo GreeterRepo, logger log.Logger) *GreeterUsecase

NewGreeterUsecase new a Greeter usecase.

func (*GreeterUsecase) CreateGreeter

func (uc *GreeterUsecase) CreateGreeter(ctx context.Context, g *Greeter) (*Greeter, error)

CreateGreeter creates a Greeter, and returns the new Greeter.

type Inter

type Inter struct {
	ID         int64     `json:"id"`
	BizID      int64     `json:"biz_id"`
	Biz        string    `json:"biz"`
	ReadCnt    int64     `json:"read_cnt"`
	LikeCnt    int64     `json:"like_cnt"`
	CollectCnt int64     `json:"collect_cnt"`
	IsDeleted  int32     `json:"is_deleted"`  // 是否删除
	CreateTime time.Time `json:"create_time"` // 创建时间
	UpdateTime time.Time `json:"update_time"` // 更新时间
}

Inter is a Inter model.

type InterRepo

type InterRepo interface {
	IncrReadCount(c context.Context, biz string, id int64) error
	Like(c context.Context, biz string, bizID, userID int64) error
	CancelLike(c context.Context, biz string, bizID, userID int64) error
	Collect(c context.Context, biz string, bizID, userID, collectionID int64) error
	CancelCollect(c context.Context, biz string, bizID, userID, collectionID int64) error
	Stat(c context.Context, biz string, bizID, userID int64) (*InterStat, error)
}

InterRepo is a Greater repo.

type InterStat

type InterStat struct {
	LikeCnt    int64 `json:"like_count"`
	CollectCnt int64 `json:"collect_count"`
	ReadCnt    int64 `json:"read_count"`
	IsLike     bool  `json:"is_like"`
	IsCollect  bool  `json:"is_collect"`
}

type InterUsecase

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

InterUsecase is a Inter usecase.

func NewInterUsecase

func NewInterUsecase(repo InterRepo, logger log.Logger) *InterUsecase

NewInterUsecase new a Inter usecase.

func (*InterUsecase) CancelCollect

func (uc *InterUsecase) CancelCollect(ctx context.Context, biz string, bizID, userID, collectionID int64) error

CancelCollect .

func (*InterUsecase) CancelLike

func (uc *InterUsecase) CancelLike(ctx context.Context, biz string, bizID, userID int64) error

CancelLike .

func (*InterUsecase) Collect

func (uc *InterUsecase) Collect(ctx context.Context, biz string, bizID, userID, collectionID int64) error

Collect .

func (*InterUsecase) IncrReadCount

func (uc *InterUsecase) IncrReadCount(ctx context.Context, biz string, id int64) error

IncrReadCount .

func (*InterUsecase) Like

func (uc *InterUsecase) Like(ctx context.Context, biz string, bizID, userID int64) error

Like .

func (*InterUsecase) Stat

func (uc *InterUsecase) Stat(ctx context.Context, biz string, bizID, userID int64) (*InterStat, error)

Stat .

type User

type User struct {
	ID              int64     `json:"id"`
	AccountID       int64     `json:"account_id"`
	Mobile          string    `json:"mobile"`
	Email           string    `json:"email"`
	Name            string    `json:"name"`
	Avatar          string    `json:"avatar"`
	BackgroundImage string    `json:"background_image"`
	Signature       string    `json:"signature"`
	IsDeleted       bool      `json:"is_deleted"`
	CreateTime      time.Time `json:"create_time"`
	UpdateTime      time.Time `json:"update_time"`
}

User is a User model.

type UserRepo

type UserRepo interface {
	Save(context.Context, *User) error
	Update(context.Context, *User) error
	FindByID(context.Context, int64) (*User, error)
	FindByIDList(context.Context, []int64) ([]*User, error)
}

UserRepo is a Greater repo.

type UserUsecase

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

UserUsecase is a User usecase.

func NewUserUsecase

func NewUserUsecase(repo UserRepo, logger log.Logger) *UserUsecase

NewUserUsecase new a User usecase.

func (*UserUsecase) CreateUser

func (uc *UserUsecase) CreateUser(ctx context.Context, g *User) error

CreateUser creates a User, and returns the new User.

func (*UserUsecase) GetUser

func (uc *UserUsecase) GetUser(ctx context.Context, id int64) (*User, error)

GetUser gets the User by the ID.

func (*UserUsecase) GetUserByIdList

func (uc *UserUsecase) GetUserByIdList(ctx context.Context, userIdList []int64) ([]*User, error)

func (*UserUsecase) UpdateUser

func (uc *UserUsecase) UpdateUser(ctx context.Context, g *User) error

UpdateUser updates the User, and returns the updated User.

type Video

type Video struct {
	ID           int64     `json:"id"`            // 视频ID
	UserID       int64     `json:"user_id"`       // 用户ID
	Title        string    `json:"title"`         // 标题
	Description  string    `json:"description"`   // 描述
	VideoURL     string    `json:"video_url"`     // 视频URL
	CoverURL     string    `json:"cover_url"`     // 封面URL
	LikeCount    int64     `json:"like_count"`    // 点赞数
	CollectCount int64     `json:"collect_count"` // 收藏数
	ForwardCount int64     `json:"forward_count"` // 转发数
	CommentCount int64     `json:"comment_count"` // 评论数
	IsDeleted    bool      `json:"is_deleted"`    // 是否删除
	CreateTime   time.Time `json:"create_time"`   // 创建时间
	UpdateTime   time.Time `json:"update_time"`   // 更新时间

	// Extra
	Author     *User `json:"author"`      // 作者信息
	IsFavorite int64 `json:"is_favorite"` // 是否点赞
	IsCollect  int64 `json:"is_collect"`  // 是否收藏
}

Video is a Video model.

type VideoRepo

type VideoRepo interface {
	Save(context.Context, *Video) error
	Update(context.Context, *Video) error
	FindByID(context.Context, int64) (*Video, error)
	FindByIDList(context.Context, []int64) ([]*Video, error)
	FindByUserID(ctx context.Context, userID int64, lastTime int64, limit int) ([]*Video, error)
	Find(ctx context.Context, lastID int64, limit int) ([]*Video, error)
}

VideoRepo is a Greater repo.

type VideoUsecase

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

VideoUsecase is a Video usecase.

func NewVideoUsecase

func NewVideoUsecase(repo VideoRepo, userRepo UserRepo, logger log.Logger) *VideoUsecase

NewVideoUsecase new a Video usecase.

func (*VideoUsecase) CreateVideo

func (uc *VideoUsecase) CreateVideo(ctx context.Context, g *Video) error

CreateVideo creates a Video, and returns the new Video.

func (*VideoUsecase) Feed

func (uc *VideoUsecase) Feed(ctx context.Context, userID, lastTime int64, limit int) ([]*Video, error)

func (*VideoUsecase) GetVideo

func (uc *VideoUsecase) GetVideo(ctx context.Context, id int64) (*Video, error)

GetVideo gets the Video by the ID.

func (*VideoUsecase) GetVideoByIdList

func (uc *VideoUsecase) GetVideoByIdList(ctx context.Context, videoIdList []int64) ([]*Video, error)

func (*VideoUsecase) GetVideoByUserID

func (uc *VideoUsecase) GetVideoByUserID(ctx context.Context, userID, lastTime int64, limit int) ([]*Video, error)

func (*VideoUsecase) UpdateVideo

func (uc *VideoUsecase) UpdateVideo(ctx context.Context, g *Video) error

UpdateVideo updates the Video, and returns the updated Video.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳