data

package
v0.0.0-...-7d1b39b Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OccupyKey   = "-1"
	OccupyValue = ""
)

Variables

View Source
var (
	ErrInvalidComment      = errors.New("invalid comment")
	ErrCopy                = errors.New("copy error")
	ErrJsonMarshal         = errors.New("json marshal error")
	ErrRedisSet            = errors.New("redis set error")
	ErrRedisQuery          = errors.New("redis query error")
	ErrMysqlDelete         = errors.New("mysql delete error")
	ErrMysqlInsert         = errors.New("mysql insert error")
	ErrMysqlQuery          = errors.New("mysql query error")
	ErrRedisDelete         = errors.New("redis delete error")
	ErrRedisTransaction    = errors.New("redis transaction error")
	ErrUserServiceResponse = errors.New("user service response error")
)

Functions

func InitDB

func InitDB(db *gorm.DB)

InitDB 创建Comments数据表,并自动迁移

func NewCommentRepo

func NewCommentRepo(
	data *Data, userConn userv1.UserServiceClient, logger log.Logger,
) biz.CommentRepo

func NewKafkaWriter

func NewKafkaWriter(c *conf.Data, l log.Logger) *kafka.Writer

func NewMysqlConn

func NewMysqlConn(c *conf.Data, l log.Logger) *gorm.DB

NewMysqlConn mysql数据库连接

func NewRedisConn

func NewRedisConn(c *conf.Data, l log.Logger) *redis.Client

NewRedisConn Redis数据库连接

Types

type Comment

type Comment struct {
	Id       uint32 `gorm:"primary_key"`
	UserId   uint32 `gorm:"column:user_id;not null"`
	VideoId  uint32 `gorm:"column:video_id;not null;index:idx_video_id"`
	Content  string `gorm:"column:content;not null"`
	CreateAt string `gorm:"column:created_at;default:''" copier:"CreateDate"`
}

func (Comment) TableName

func (Comment) TableName() string

type Data

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

func NewData

func NewData(db *gorm.DB, cacheClient *redis.Client, kfk *kafka.Writer, logger log.Logger) (*Data, func(), error)

type UserRepo

type UserRepo interface {
	GetUserInfos(context.Context, uint32, []uint32) ([]*biz.User, error)
}

func NewUserRepo

func NewUserRepo(conn pb.UserServiceClient) UserRepo

Jump to

Keyboard shortcuts

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