Documentation ¶
Index ¶
- Variables
- func InitTables(db *gorm.DB) error
- type Article
- type ArticleDAO
- type ArticleGormDAO
- func (d *ArticleGormDAO) GetByAuthorId(ctx context.Context, authorId int64, limit int, offset int) ([]Article, error)
- func (d *ArticleGormDAO) GetById(ctx context.Context, id int64) (Article, error)
- func (d *ArticleGormDAO) GetByPublishedId(ctx context.Context, id int64) (PublishedArticle, error)
- func (d *ArticleGormDAO) Insert(ctx context.Context, article Article) (int64, error)
- func (d *ArticleGormDAO) ListPub(ctx context.Context, start time.Time, offset int, batchSize int) ([]PublishedArticle, error)
- func (d *ArticleGormDAO) Sync(ctx context.Context, art Article) (int64, error)
- func (d *ArticleGormDAO) SyncStatus(ctx context.Context, userId int64, artId int64, status domain.ArticleStatus) error
- func (d *ArticleGormDAO) UpdateById(ctx context.Context, art Article) error
- type AsyncGormSmsDAO
- func (a *AsyncGormSmsDAO) GetPreemptiveSms(ctx context.Context) (AsyncSms, error)
- func (a *AsyncGormSmsDAO) Insert(ctx context.Context, sms AsyncSms) error
- func (a *AsyncGormSmsDAO) MarkFailure(ctx context.Context, smsId int64) error
- func (a *AsyncGormSmsDAO) MarkSuccess(ctx context.Context, smsId int64) error
- type AsyncSms
- type AsyncSmsDAO
- type PublishedArticle
- type SmsConfig
- type User
- type UserActivity
- type UserActivityDAO
- type UserDAO
- type UserGormDAO
- func (dao *UserGormDAO) Create(ctx context.Context, user User) error
- func (dao *UserGormDAO) FindByEmail(ctx context.Context, email string) (User, error)
- func (dao *UserGormDAO) FindById(ctx context.Context, uid int64) (User, error)
- func (dao *UserGormDAO) FindByPhone(ctx context.Context, phone string) (User, error)
- func (dao *UserGormDAO) Insert(ctx context.Context, user User) error
- func (dao *UserGormDAO) UpdateById(ctx context.Context, user User) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUserDuplicate = errors.New("邮箱冲突") ErrRecordNotFound = gorm.ErrRecordNotFound )
Functions ¶
Types ¶
type Article ¶
type Article struct { Id int64 `gorm:"primaryKey,autoIncrement"` // create an index for frequently queried column AuthorId int64 `gorm:"index"` Topic string `gorm:"type=varchar(4096)"` Content string `gorm:"type=BLOB"` // why use int64 here // bson doesn't support time.Time? Status uint8 Ctime int64 Utime int64 }
type ArticleDAO ¶
type ArticleDAO interface { GetById(context.Context, int64) (Article, error) GetByPublishedId(context.Context, int64) (PublishedArticle, error) Insert(context.Context, Article) (int64, error) GetByAuthorId(context.Context, int64, int, int) ([]Article, error) Sync(context.Context, Article) (int64, error) UpdateById(context.Context, Article) error SyncStatus(ctx context.Context, userId int64, artId int64, status domain.ArticleStatus) error ListPub(context.Context, time.Time, int, int) ([]PublishedArticle, error) }
func NewArticleGormDAO ¶
func NewArticleGormDAO(db *gorm.DB) ArticleDAO
type ArticleGormDAO ¶
type ArticleGormDAO struct {
// contains filtered or unexported fields
}
func (*ArticleGormDAO) GetByAuthorId ¶
func (*ArticleGormDAO) GetByPublishedId ¶
func (d *ArticleGormDAO) GetByPublishedId(ctx context.Context, id int64) (PublishedArticle, error)
func (*ArticleGormDAO) ListPub ¶
func (d *ArticleGormDAO) ListPub(ctx context.Context, start time.Time, offset int, batchSize int) ([]PublishedArticle, error)
func (*ArticleGormDAO) SyncStatus ¶
func (d *ArticleGormDAO) SyncStatus(ctx context.Context, userId int64, artId int64, status domain.ArticleStatus) error
func (*ArticleGormDAO) UpdateById ¶
func (d *ArticleGormDAO) UpdateById(ctx context.Context, art Article) error
type AsyncGormSmsDAO ¶
type AsyncGormSmsDAO struct {
// contains filtered or unexported fields
}
func (*AsyncGormSmsDAO) GetPreemptiveSms ¶
func (a *AsyncGormSmsDAO) GetPreemptiveSms(ctx context.Context) (AsyncSms, error)
func (*AsyncGormSmsDAO) Insert ¶
func (a *AsyncGormSmsDAO) Insert(ctx context.Context, sms AsyncSms) error
func (*AsyncGormSmsDAO) MarkFailure ¶
func (a *AsyncGormSmsDAO) MarkFailure(ctx context.Context, smsId int64) error
func (*AsyncGormSmsDAO) MarkSuccess ¶
func (a *AsyncGormSmsDAO) MarkSuccess(ctx context.Context, smsId int64) error
type AsyncSmsDAO ¶
type AsyncSmsDAO interface { Insert(ctx context.Context, sms AsyncSms) error GetPreemptiveSms(ctx context.Context) (AsyncSms, error) MarkSuccess(ctx context.Context, smsId int64) error MarkFailure(ctx context.Context, smsId int64) error }
func NewAsyncSmsDao ¶
func NewAsyncSmsDao(db *gorm.DB) AsyncSmsDAO
type PublishedArticle ¶
type PublishedArticle struct {
Article
}
type User ¶
type User struct { Id int64 `gorm:"primaryKey, autoIncrement"` Email sql.NullString `gorm:"unique"` Password string Phone sql.NullString `gorm:"unique"` Nickname string `gorm:"type=varchar(128)"` // YYYY-MM-DD Birthday int64 AboutMe string `gorm:"type=varchar(4096)"` // 数据库溯源 Ctime int64 Utime int64 }
type UserActivity ¶
type UserActivityDAO ¶
type UserActivityDAO interface { IncrReadCntIfPresent(ctx context.Context, biz string, bizId int64) error BatchIncrReadCntIfPresent(ctx context.Context, bizs []string, bizIds []int64) error GetReadByIds(ctx context.Context, biz string, bizIds []int64) ([]UserActivity, error) }
func NewUserActivityDAO ¶
func NewUserActivityDAO(db *gorm.DB) UserActivityDAO
type UserDAO ¶
type UserDAO interface { Insert(context.Context, User) error Create(context.Context, User) error FindByEmail(context.Context, string) (User, error) FindByPhone(context.Context, string) (User, error) FindById(context.Context, int64) (User, error) UpdateById(context.Context, User) error }
func NewUserDAO ¶
type UserGormDAO ¶
type UserGormDAO struct {
// contains filtered or unexported fields
}
func (*UserGormDAO) FindByEmail ¶
func (*UserGormDAO) FindByPhone ¶
func (*UserGormDAO) UpdateById ¶
func (dao *UserGormDAO) UpdateById(ctx context.Context, user User) error
Click to show internal directories.
Click to hide internal directories.