data

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUserRepo

func NewUserRepo(
	db *gorm.DB,
) repo.UserRepo

NewUserRepo returns a new user adapter implemented userRepo.

Types

type User

type User struct {
	Id                uint32    `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
	Uid               int64     `gorm:"column:uid" json:"uid"`
	NickName          string    `gorm:"column:nick_name" json:"nick_name"`
	AvatarUri         string    `gorm:"column:avatar_uri" json:"avatar_uri"`
	ReadingPreference int8      `gorm:"column:reading_preference" json:"reading_preference"`
	CreateTime        time.Time `gorm:"column:create_time" json:"create_time"`
	UpdateTime        time.Time `gorm:"column:update_time" json:"update_time"`
	AutoBuy           int8      `gorm:"column:auto_buy" json:"auto_buy"`
	IsAutoBuy         int8      `gorm:"column:is_auto_buy" json:"is_auto_buy"`
}

User represents a user struct data.

func (*User) TableName

func (m *User) TableName() string

TableName returns the table name. it implemented by gorm.Tabler.

type UserAdapter

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

UserAdapter represents a user adapter.

func (*UserAdapter) Count

func (m *UserAdapter) Count(ctx context.Context, query *gormx.Query) (int64, error)

Count count user.

func (*UserAdapter) Create

func (m *UserAdapter) Create(ctx context.Context, es ...*entity.User) error

Create creates user data.

func (*UserAdapter) DB

func (m *UserAdapter) DB(ctx context.Context) *gorm.DB

func (*UserAdapter) Delete

func (m *UserAdapter) Delete(ctx context.Context, id int64) error

Delete delete user.

func (*UserAdapter) GetByID

func (r *UserAdapter) GetByID(ctx context.Context, id int64) (*entity.User, error)

GetByID get user by id.

func (*UserAdapter) IsDuplicatedKeyError

func (m *UserAdapter) IsDuplicatedKeyError(err error) bool

IsDuplicatedKeyError use to check error is unique key conflict error.

func (*UserAdapter) IsNotFoundError

func (m *UserAdapter) IsNotFoundError(err error) bool

IsNotFoundError use to check error is record not found error.

func (*UserAdapter) List

func (m *UserAdapter) List(ctx context.Context, query *gormx.Query) ([]*entity.User, error)

List list user.

func (*UserAdapter) Update

func (m *UserAdapter) Update(ctx context.Context, e *entity.User) error

Update update user.

Jump to

Keyboard shortcuts

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