345 lines
10 KiB
Go
345 lines
10 KiB
Go
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
|
|
package dao
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
"gorm.io/gorm/schema"
|
|
|
|
"gorm.io/gen"
|
|
"gorm.io/gen/field"
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
"mini-chat/internal/repository/mysql/model"
|
|
)
|
|
|
|
func newSmsVerificationCode(db *gorm.DB, opts ...gen.DOOption) smsVerificationCode {
|
|
_smsVerificationCode := smsVerificationCode{}
|
|
|
|
_smsVerificationCode.smsVerificationCodeDo.UseDB(db, opts...)
|
|
_smsVerificationCode.smsVerificationCodeDo.UseModel(&model.SmsVerificationCode{})
|
|
|
|
tableName := _smsVerificationCode.smsVerificationCodeDo.TableName()
|
|
_smsVerificationCode.ALL = field.NewAsterisk(tableName)
|
|
_smsVerificationCode.ID = field.NewInt32(tableName, "id")
|
|
_smsVerificationCode.PhoneNumber = field.NewString(tableName, "phone_number")
|
|
_smsVerificationCode.VerificationCode = field.NewString(tableName, "verification_code")
|
|
_smsVerificationCode.Type = field.NewInt32(tableName, "type")
|
|
_smsVerificationCode.IsUsed = field.NewInt32(tableName, "is_used")
|
|
_smsVerificationCode.CreatedUser = field.NewString(tableName, "created_user")
|
|
_smsVerificationCode.CreatedAt = field.NewTime(tableName, "created_at")
|
|
|
|
_smsVerificationCode.fillFieldMap()
|
|
|
|
return _smsVerificationCode
|
|
}
|
|
|
|
// smsVerificationCode 短信验证码表
|
|
type smsVerificationCode struct {
|
|
smsVerificationCodeDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int32 // 主键
|
|
PhoneNumber field.String // 手机号码
|
|
VerificationCode field.String // 验证码
|
|
Type field.Int32 // 类型(1=登录 2=忘记密码)
|
|
IsUsed field.Int32 // 是否已使用(0:未使用,1:已使用)
|
|
CreatedUser field.String // 创建人
|
|
CreatedAt field.Time // 创建时间
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (s smsVerificationCode) Table(newTableName string) *smsVerificationCode {
|
|
s.smsVerificationCodeDo.UseTable(newTableName)
|
|
return s.updateTableName(newTableName)
|
|
}
|
|
|
|
func (s smsVerificationCode) As(alias string) *smsVerificationCode {
|
|
s.smsVerificationCodeDo.DO = *(s.smsVerificationCodeDo.As(alias).(*gen.DO))
|
|
return s.updateTableName(alias)
|
|
}
|
|
|
|
func (s *smsVerificationCode) updateTableName(table string) *smsVerificationCode {
|
|
s.ALL = field.NewAsterisk(table)
|
|
s.ID = field.NewInt32(table, "id")
|
|
s.PhoneNumber = field.NewString(table, "phone_number")
|
|
s.VerificationCode = field.NewString(table, "verification_code")
|
|
s.Type = field.NewInt32(table, "type")
|
|
s.IsUsed = field.NewInt32(table, "is_used")
|
|
s.CreatedUser = field.NewString(table, "created_user")
|
|
s.CreatedAt = field.NewTime(table, "created_at")
|
|
|
|
s.fillFieldMap()
|
|
|
|
return s
|
|
}
|
|
|
|
func (s *smsVerificationCode) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
_f, ok := s.fieldMap[fieldName]
|
|
if !ok || _f == nil {
|
|
return nil, false
|
|
}
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
return _oe, ok
|
|
}
|
|
|
|
func (s *smsVerificationCode) fillFieldMap() {
|
|
s.fieldMap = make(map[string]field.Expr, 7)
|
|
s.fieldMap["id"] = s.ID
|
|
s.fieldMap["phone_number"] = s.PhoneNumber
|
|
s.fieldMap["verification_code"] = s.VerificationCode
|
|
s.fieldMap["type"] = s.Type
|
|
s.fieldMap["is_used"] = s.IsUsed
|
|
s.fieldMap["created_user"] = s.CreatedUser
|
|
s.fieldMap["created_at"] = s.CreatedAt
|
|
}
|
|
|
|
func (s smsVerificationCode) clone(db *gorm.DB) smsVerificationCode {
|
|
s.smsVerificationCodeDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return s
|
|
}
|
|
|
|
func (s smsVerificationCode) replaceDB(db *gorm.DB) smsVerificationCode {
|
|
s.smsVerificationCodeDo.ReplaceDB(db)
|
|
return s
|
|
}
|
|
|
|
type smsVerificationCodeDo struct{ gen.DO }
|
|
|
|
func (s smsVerificationCodeDo) Debug() *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Debug())
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) WithContext(ctx context.Context) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) ReadDB() *smsVerificationCodeDo {
|
|
return s.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) WriteDB() *smsVerificationCodeDo {
|
|
return s.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Session(config *gorm.Session) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Session(config))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Clauses(conds ...clause.Expression) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Returning(value interface{}, columns ...string) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Not(conds ...gen.Condition) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Not(conds...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Or(conds ...gen.Condition) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Or(conds...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Select(conds ...field.Expr) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Select(conds...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Where(conds ...gen.Condition) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Where(conds...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Order(conds ...field.Expr) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Order(conds...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Distinct(cols ...field.Expr) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Omit(cols ...field.Expr) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Omit(cols...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Join(table schema.Tabler, on ...field.Expr) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Join(table, on...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) LeftJoin(table schema.Tabler, on ...field.Expr) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) RightJoin(table schema.Tabler, on ...field.Expr) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Group(cols ...field.Expr) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Group(cols...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Having(conds ...gen.Condition) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Having(conds...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Limit(limit int) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Limit(limit))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Offset(offset int) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Offset(offset))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Unscoped() *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Unscoped())
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Create(values ...*model.SmsVerificationCode) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return s.DO.Create(values)
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) CreateInBatches(values []*model.SmsVerificationCode, batchSize int) error {
|
|
return s.DO.CreateInBatches(values, batchSize)
|
|
}
|
|
|
|
// Save : !!! underlying implementation is different with GORM
|
|
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
|
func (s smsVerificationCodeDo) Save(values ...*model.SmsVerificationCode) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return s.DO.Save(values)
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) First() (*model.SmsVerificationCode, error) {
|
|
if result, err := s.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.SmsVerificationCode), nil
|
|
}
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Take() (*model.SmsVerificationCode, error) {
|
|
if result, err := s.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.SmsVerificationCode), nil
|
|
}
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Last() (*model.SmsVerificationCode, error) {
|
|
if result, err := s.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.SmsVerificationCode), nil
|
|
}
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Find() ([]*model.SmsVerificationCode, error) {
|
|
result, err := s.DO.Find()
|
|
return result.([]*model.SmsVerificationCode), err
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.SmsVerificationCode, err error) {
|
|
buf := make([]*model.SmsVerificationCode, 0, batchSize)
|
|
err = s.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
|
defer func() { results = append(results, buf...) }()
|
|
return fc(tx, batch)
|
|
})
|
|
return results, err
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) FindInBatches(result *[]*model.SmsVerificationCode, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return s.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Attrs(attrs ...field.AssignExpr) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Assign(attrs ...field.AssignExpr) *smsVerificationCodeDo {
|
|
return s.withDO(s.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Joins(fields ...field.RelationField) *smsVerificationCodeDo {
|
|
for _, _f := range fields {
|
|
s = *s.withDO(s.DO.Joins(_f))
|
|
}
|
|
return &s
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Preload(fields ...field.RelationField) *smsVerificationCodeDo {
|
|
for _, _f := range fields {
|
|
s = *s.withDO(s.DO.Preload(_f))
|
|
}
|
|
return &s
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) FirstOrInit() (*model.SmsVerificationCode, error) {
|
|
if result, err := s.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.SmsVerificationCode), nil
|
|
}
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) FirstOrCreate() (*model.SmsVerificationCode, error) {
|
|
if result, err := s.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.SmsVerificationCode), nil
|
|
}
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) FindByPage(offset int, limit int) (result []*model.SmsVerificationCode, count int64, err error) {
|
|
result, err = s.Offset(offset).Limit(limit).Find()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
if size := len(result); 0 < limit && 0 < size && size < limit {
|
|
count = int64(size + offset)
|
|
return
|
|
}
|
|
|
|
count, err = s.Offset(-1).Limit(-1).Count()
|
|
return
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
count, err = s.Count()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = s.Offset(offset).Limit(limit).Scan(result)
|
|
return
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Scan(result interface{}) (err error) {
|
|
return s.DO.Scan(result)
|
|
}
|
|
|
|
func (s smsVerificationCodeDo) Delete(models ...*model.SmsVerificationCode) (result gen.ResultInfo, err error) {
|
|
return s.DO.Delete(models)
|
|
}
|
|
|
|
func (s *smsVerificationCodeDo) withDO(do gen.Dao) *smsVerificationCodeDo {
|
|
s.DO = *do.(*gen.DO)
|
|
return s
|
|
}
|