// 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 dbquery import ( "context" "gorm.io/gorm" "gorm.io/gorm/clause" "gorm.io/gorm/schema" "gorm.io/gen" "gorm.io/gen/field" "gorm.io/plugin/dbresolver" "joylink.club/bj-rtsts-server/db/model" ) func newTrainSize(db *gorm.DB, opts ...gen.DOOption) trainSize { _trainSize := trainSize{} _trainSize.trainSizeDo.UseDB(db, opts...) _trainSize.trainSizeDo.UseModel(&model.TrainSize{}) tableName := _trainSize.trainSizeDo.TableName() _trainSize.ALL = field.NewAsterisk(tableName) _trainSize.ID = field.NewInt32(tableName, "id") _trainSize.Name = field.NewString(tableName, "name") _trainSize.CarriageLength = field.NewInt32(tableName, "carriage_length") _trainSize.TotalLength = field.NewInt32(tableName, "total_length") _trainSize.Description = field.NewString(tableName, "description") _trainSize.fillFieldMap() return _trainSize } type trainSize struct { trainSizeDo ALL field.Asterisk ID field.Int32 // 主键 Name field.String // 名称 CarriageLength field.Int32 // 列车车厢长度 TotalLength field.Int32 // 总长度 Description field.String // 其他描述内容 fieldMap map[string]field.Expr } func (t trainSize) Table(newTableName string) *trainSize { t.trainSizeDo.UseTable(newTableName) return t.updateTableName(newTableName) } func (t trainSize) As(alias string) *trainSize { t.trainSizeDo.DO = *(t.trainSizeDo.As(alias).(*gen.DO)) return t.updateTableName(alias) } func (t *trainSize) updateTableName(table string) *trainSize { t.ALL = field.NewAsterisk(table) t.ID = field.NewInt32(table, "id") t.Name = field.NewString(table, "name") t.CarriageLength = field.NewInt32(table, "carriage_length") t.TotalLength = field.NewInt32(table, "total_length") t.Description = field.NewString(table, "description") t.fillFieldMap() return t } func (t *trainSize) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := t.fieldMap[fieldName] if !ok || _f == nil { return nil, false } _oe, ok := _f.(field.OrderExpr) return _oe, ok } func (t *trainSize) fillFieldMap() { t.fieldMap = make(map[string]field.Expr, 5) t.fieldMap["id"] = t.ID t.fieldMap["name"] = t.Name t.fieldMap["carriage_length"] = t.CarriageLength t.fieldMap["total_length"] = t.TotalLength t.fieldMap["description"] = t.Description } func (t trainSize) clone(db *gorm.DB) trainSize { t.trainSizeDo.ReplaceConnPool(db.Statement.ConnPool) return t } func (t trainSize) replaceDB(db *gorm.DB) trainSize { t.trainSizeDo.ReplaceDB(db) return t } type trainSizeDo struct{ gen.DO } type ITrainSizeDo interface { gen.SubQuery Debug() ITrainSizeDo WithContext(ctx context.Context) ITrainSizeDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() ITrainSizeDo WriteDB() ITrainSizeDo As(alias string) gen.Dao Session(config *gorm.Session) ITrainSizeDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) ITrainSizeDo Not(conds ...gen.Condition) ITrainSizeDo Or(conds ...gen.Condition) ITrainSizeDo Select(conds ...field.Expr) ITrainSizeDo Where(conds ...gen.Condition) ITrainSizeDo Order(conds ...field.Expr) ITrainSizeDo Distinct(cols ...field.Expr) ITrainSizeDo Omit(cols ...field.Expr) ITrainSizeDo Join(table schema.Tabler, on ...field.Expr) ITrainSizeDo LeftJoin(table schema.Tabler, on ...field.Expr) ITrainSizeDo RightJoin(table schema.Tabler, on ...field.Expr) ITrainSizeDo Group(cols ...field.Expr) ITrainSizeDo Having(conds ...gen.Condition) ITrainSizeDo Limit(limit int) ITrainSizeDo Offset(offset int) ITrainSizeDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainSizeDo Unscoped() ITrainSizeDo Create(values ...*model.TrainSize) error CreateInBatches(values []*model.TrainSize, batchSize int) error Save(values ...*model.TrainSize) error First() (*model.TrainSize, error) Take() (*model.TrainSize, error) Last() (*model.TrainSize, error) Find() ([]*model.TrainSize, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainSize, err error) FindInBatches(result *[]*model.TrainSize, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest interface{}) error Delete(...*model.TrainSize) (info gen.ResultInfo, err error) Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) Updates(value interface{}) (info gen.ResultInfo, err error) UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) UpdateColumns(value interface{}) (info gen.ResultInfo, err error) UpdateFrom(q gen.SubQuery) gen.Dao Attrs(attrs ...field.AssignExpr) ITrainSizeDo Assign(attrs ...field.AssignExpr) ITrainSizeDo Joins(fields ...field.RelationField) ITrainSizeDo Preload(fields ...field.RelationField) ITrainSizeDo FirstOrInit() (*model.TrainSize, error) FirstOrCreate() (*model.TrainSize, error) FindByPage(offset int, limit int) (result []*model.TrainSize, count int64, err error) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) Scan(result interface{}) (err error) Returning(value interface{}, columns ...string) ITrainSizeDo UnderlyingDB() *gorm.DB schema.Tabler } func (t trainSizeDo) Debug() ITrainSizeDo { return t.withDO(t.DO.Debug()) } func (t trainSizeDo) WithContext(ctx context.Context) ITrainSizeDo { return t.withDO(t.DO.WithContext(ctx)) } func (t trainSizeDo) ReadDB() ITrainSizeDo { return t.Clauses(dbresolver.Read) } func (t trainSizeDo) WriteDB() ITrainSizeDo { return t.Clauses(dbresolver.Write) } func (t trainSizeDo) Session(config *gorm.Session) ITrainSizeDo { return t.withDO(t.DO.Session(config)) } func (t trainSizeDo) Clauses(conds ...clause.Expression) ITrainSizeDo { return t.withDO(t.DO.Clauses(conds...)) } func (t trainSizeDo) Returning(value interface{}, columns ...string) ITrainSizeDo { return t.withDO(t.DO.Returning(value, columns...)) } func (t trainSizeDo) Not(conds ...gen.Condition) ITrainSizeDo { return t.withDO(t.DO.Not(conds...)) } func (t trainSizeDo) Or(conds ...gen.Condition) ITrainSizeDo { return t.withDO(t.DO.Or(conds...)) } func (t trainSizeDo) Select(conds ...field.Expr) ITrainSizeDo { return t.withDO(t.DO.Select(conds...)) } func (t trainSizeDo) Where(conds ...gen.Condition) ITrainSizeDo { return t.withDO(t.DO.Where(conds...)) } func (t trainSizeDo) Order(conds ...field.Expr) ITrainSizeDo { return t.withDO(t.DO.Order(conds...)) } func (t trainSizeDo) Distinct(cols ...field.Expr) ITrainSizeDo { return t.withDO(t.DO.Distinct(cols...)) } func (t trainSizeDo) Omit(cols ...field.Expr) ITrainSizeDo { return t.withDO(t.DO.Omit(cols...)) } func (t trainSizeDo) Join(table schema.Tabler, on ...field.Expr) ITrainSizeDo { return t.withDO(t.DO.Join(table, on...)) } func (t trainSizeDo) LeftJoin(table schema.Tabler, on ...field.Expr) ITrainSizeDo { return t.withDO(t.DO.LeftJoin(table, on...)) } func (t trainSizeDo) RightJoin(table schema.Tabler, on ...field.Expr) ITrainSizeDo { return t.withDO(t.DO.RightJoin(table, on...)) } func (t trainSizeDo) Group(cols ...field.Expr) ITrainSizeDo { return t.withDO(t.DO.Group(cols...)) } func (t trainSizeDo) Having(conds ...gen.Condition) ITrainSizeDo { return t.withDO(t.DO.Having(conds...)) } func (t trainSizeDo) Limit(limit int) ITrainSizeDo { return t.withDO(t.DO.Limit(limit)) } func (t trainSizeDo) Offset(offset int) ITrainSizeDo { return t.withDO(t.DO.Offset(offset)) } func (t trainSizeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainSizeDo { return t.withDO(t.DO.Scopes(funcs...)) } func (t trainSizeDo) Unscoped() ITrainSizeDo { return t.withDO(t.DO.Unscoped()) } func (t trainSizeDo) Create(values ...*model.TrainSize) error { if len(values) == 0 { return nil } return t.DO.Create(values) } func (t trainSizeDo) CreateInBatches(values []*model.TrainSize, batchSize int) error { return t.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 (t trainSizeDo) Save(values ...*model.TrainSize) error { if len(values) == 0 { return nil } return t.DO.Save(values) } func (t trainSizeDo) First() (*model.TrainSize, error) { if result, err := t.DO.First(); err != nil { return nil, err } else { return result.(*model.TrainSize), nil } } func (t trainSizeDo) Take() (*model.TrainSize, error) { if result, err := t.DO.Take(); err != nil { return nil, err } else { return result.(*model.TrainSize), nil } } func (t trainSizeDo) Last() (*model.TrainSize, error) { if result, err := t.DO.Last(); err != nil { return nil, err } else { return result.(*model.TrainSize), nil } } func (t trainSizeDo) Find() ([]*model.TrainSize, error) { result, err := t.DO.Find() return result.([]*model.TrainSize), err } func (t trainSizeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainSize, err error) { buf := make([]*model.TrainSize, 0, batchSize) err = t.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 (t trainSizeDo) FindInBatches(result *[]*model.TrainSize, batchSize int, fc func(tx gen.Dao, batch int) error) error { return t.DO.FindInBatches(result, batchSize, fc) } func (t trainSizeDo) Attrs(attrs ...field.AssignExpr) ITrainSizeDo { return t.withDO(t.DO.Attrs(attrs...)) } func (t trainSizeDo) Assign(attrs ...field.AssignExpr) ITrainSizeDo { return t.withDO(t.DO.Assign(attrs...)) } func (t trainSizeDo) Joins(fields ...field.RelationField) ITrainSizeDo { for _, _f := range fields { t = *t.withDO(t.DO.Joins(_f)) } return &t } func (t trainSizeDo) Preload(fields ...field.RelationField) ITrainSizeDo { for _, _f := range fields { t = *t.withDO(t.DO.Preload(_f)) } return &t } func (t trainSizeDo) FirstOrInit() (*model.TrainSize, error) { if result, err := t.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.TrainSize), nil } } func (t trainSizeDo) FirstOrCreate() (*model.TrainSize, error) { if result, err := t.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.TrainSize), nil } } func (t trainSizeDo) FindByPage(offset int, limit int) (result []*model.TrainSize, count int64, err error) { result, err = t.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 = t.Offset(-1).Limit(-1).Count() return } func (t trainSizeDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { count, err = t.Count() if err != nil { return } err = t.Offset(offset).Limit(limit).Scan(result) return } func (t trainSizeDo) Scan(result interface{}) (err error) { return t.DO.Scan(result) } func (t trainSizeDo) Delete(models ...*model.TrainSize) (result gen.ResultInfo, err error) { return t.DO.Delete(models) } func (t *trainSizeDo) withDO(do gen.Dao) *trainSizeDo { t.DO = *do.(*gen.DO) return t }