dao

package
v0.0.0-...-d13da26 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserDuplicateEmail = errors.New("邮箱冲突")
	ErrUserNotFound       = gorm.ErrRecordNotFound
)

Functions

func InitTable

func InitTable(db *gorm.DB) error

Types

type Profile

type Profile struct {
	Id       int64 `gorm:"primaryKey, autoIncrement"`
	UserId   int64
	Nickname string
	Biology  string
	Birthday int64
	Ctime    int64
	Utime    int64
}

type ProfileDAO

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

func NewProfileDAO

func NewProfileDAO(db *gorm.DB) *ProfileDAO

func (*ProfileDAO) FindByUserId

func (dao *ProfileDAO) FindByUserId(ctx context.Context, id int64) (Profile, error)

func (*ProfileDAO) Insert

func (dao *ProfileDAO) Insert(ctx context.Context, p Profile) error

func (*ProfileDAO) Update

func (dao *ProfileDAO) Update(ctx context.Context, p Profile) error

type User

type User struct {
	Id       int64  `gorm:"primaryKey, autoIncrement"`
	Email    string `gorm:"unique"`
	Password string
	Ctime    int64
	Utime    int64
}

User 直接对应数据库表结构 有些人叫做 entity,有些人叫做 model,有些人叫做 PO(persistent object)

type UserDAO

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

func NewUserDAO

func NewUserDAO(db *gorm.DB) *UserDAO

func (*UserDAO) FindByEmail

func (dao *UserDAO) FindByEmail(ctx context.Context, email string) (User, error)

func (*UserDAO) Insert

func (dao *UserDAO) Insert(ctx context.Context, u User) (User, error)

Jump to

Keyboard shortcuts

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