dao

package
v0.0.0-...-02d2a03 Latest Latest
Warning

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

Go to latest
Published: May 3, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func InitTables

func InitTables(db *gorm.DB)

Types

type Article

type Article struct {
	Id       int64  `gorm:"primaryKey,autoIncrement"`
	Title    string `gorm:"type:varchar(1024);not null"`
	Content  string `gorm:"type:BLOB;not null"`
	AuthorId int64  `gorm:"index:aid_utime"`
	Status   uint8
	UTime    int64 `gorm:"index:aid_utime"`
	CTime    int64
}

type ArticleDao

type ArticleDao interface {
	Insert(ctx context.Context, article Article) (int64, error)
	UpdateById(ctx context.Context, article Article) error
	Sync(ctx context.Context, article Article) (int64, error)
	Upsert(ctx context.Context, article PublishArticle) (int64, error)
	SyncStatus(ctx context.Context, article Article) error
	List(ctx context.Context, id int64, offset int, limit int) ([]Article, error)
	GetByArtId(ctx context.Context, id int64) (Article, error)
}

func NewArticleDao

func NewArticleDao(db *gorm.DB) ArticleDao

type GormArticleDao

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

func (*GormArticleDao) GetByArtId

func (d *GormArticleDao) GetByArtId(ctx context.Context, id int64) (Article, error)

func (*GormArticleDao) Insert

func (d *GormArticleDao) Insert(ctx context.Context, article Article) (int64, error)

func (*GormArticleDao) List

func (d *GormArticleDao) List(ctx context.Context, id int64, offset int, limit int) ([]Article, error)

func (*GormArticleDao) Sync

func (d *GormArticleDao) Sync(ctx context.Context, article Article) (int64, error)

func (*GormArticleDao) SyncStatus

func (d *GormArticleDao) SyncStatus(ctx context.Context, article Article) error

func (*GormArticleDao) UpdateById

func (d *GormArticleDao) UpdateById(ctx context.Context, article Article) error

func (*GormArticleDao) Upsert

func (d *GormArticleDao) Upsert(ctx context.Context, article PublishArticle) (int64, error)

type GormUserDao

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

func (*GormUserDao) Edit

func (dao *GormUserDao) Edit(ctx context.Context, u User) error

func (*GormUserDao) FindByEmail

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

func (*GormUserDao) FindById

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

func (*GormUserDao) FindByPhone

func (dao *GormUserDao) FindByPhone(ctx context.Context, phone string) (User, error)

func (*GormUserDao) Insert

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

type PublishArticle

type PublishArticle struct {
	Article
}

type User

type User struct {
	Id       int64          `gorm:"primaryKey,autoIncrement"`
	Email    sql.NullString `gorm:"unique"`
	Phone    sql.NullString `gorm:"unique"`
	Password string
	UserName string
	Birthday string
	Intro    string

	CreateTime int64
	UpdateTime int64
}

type UserDao

type UserDao interface {
	Insert(ctx context.Context, u User) error
	FindByEmail(ctx context.Context, email string) (User, error)
	FindById(ctx context.Context, id int64) (User, error)
	FindByPhone(ctx context.Context, phone string) (User, error)
	Edit(ctx context.Context, u User) error
}

func NewUserDao

func NewUserDao(db *gorm.DB) UserDao

Jump to

Keyboard shortcuts

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