dao

package
v0.0.0-...-f3124ab Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 4 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 User

type User struct {
	Id int64 `gorm:"primaryKey,autoIncrement"`
	// 全部用户唯一
	Email    string `gorm:"unique"`
	Password string

	// 往这面加
	Birthday string
	NickName 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) FindById

func (dao *UserDAO) FindById(ctx context.Context, id int64) (User, error)

func (*UserDAO) Insert

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

func (*UserDAO) Update

func (dao *UserDAO) Update(ctx context.Context, user User) error

Jump to

Keyboard shortcuts

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