// 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 newTrainWheelDiameter(db *gorm.DB, opts ...gen.DOOption) trainWheelDiameter { _trainWheelDiameter := trainWheelDiameter{} _trainWheelDiameter.trainWheelDiameterDo.UseDB(db, opts...) _trainWheelDiameter.trainWheelDiameterDo.UseModel(&model.TrainWheelDiameter{}) tableName := _trainWheelDiameter.trainWheelDiameterDo.TableName() _trainWheelDiameter.ALL = field.NewAsterisk(tableName) _trainWheelDiameter.ID = field.NewInt32(tableName, "id") _trainWheelDiameter.Name = field.NewString(tableName, "name") _trainWheelDiameter.Diameter = field.NewInt32(tableName, "diameter") _trainWheelDiameter.MinDiameter = field.NewInt32(tableName, "min_diameter") _trainWheelDiameter.MaxDiameter = field.NewInt32(tableName, "max_diameter") _trainWheelDiameter.AxialPosition = field.NewInt32(tableName, "axial_position") _trainWheelDiameter.InstallDirection = field.NewString(tableName, "install_direction") _trainWheelDiameter.fillFieldMap() return _trainWheelDiameter } type trainWheelDiameter struct { trainWheelDiameterDo ALL field.Asterisk ID field.Int32 Name field.String // 名称 Diameter field.Int32 // 速度传感器安装处车轮的出厂直径(mm) MinDiameter field.Int32 // 速度传感器安装处车轮的最小直径(mm) MaxDiameter field.Int32 // 速度传感器安装处车轮的最大直径(mm) AxialPosition field.Int32 // 速度传感器安装轴位,本端车前进方向的第几轴 /* 速度传感器安装方向, 本端车前进方向的左侧或右侧 */ InstallDirection field.String fieldMap map[string]field.Expr } func (t trainWheelDiameter) Table(newTableName string) *trainWheelDiameter { t.trainWheelDiameterDo.UseTable(newTableName) return t.updateTableName(newTableName) } func (t trainWheelDiameter) As(alias string) *trainWheelDiameter { t.trainWheelDiameterDo.DO = *(t.trainWheelDiameterDo.As(alias).(*gen.DO)) return t.updateTableName(alias) } func (t *trainWheelDiameter) updateTableName(table string) *trainWheelDiameter { t.ALL = field.NewAsterisk(table) t.ID = field.NewInt32(table, "id") t.Name = field.NewString(table, "name") t.Diameter = field.NewInt32(table, "diameter") t.MinDiameter = field.NewInt32(table, "min_diameter") t.MaxDiameter = field.NewInt32(table, "max_diameter") t.AxialPosition = field.NewInt32(table, "axial_position") t.InstallDirection = field.NewString(table, "install_direction") t.fillFieldMap() return t } func (t *trainWheelDiameter) 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 *trainWheelDiameter) fillFieldMap() { t.fieldMap = make(map[string]field.Expr, 7) t.fieldMap["id"] = t.ID t.fieldMap["name"] = t.Name t.fieldMap["diameter"] = t.Diameter t.fieldMap["min_diameter"] = t.MinDiameter t.fieldMap["max_diameter"] = t.MaxDiameter t.fieldMap["axial_position"] = t.AxialPosition t.fieldMap["install_direction"] = t.InstallDirection } func (t trainWheelDiameter) clone(db *gorm.DB) trainWheelDiameter { t.trainWheelDiameterDo.ReplaceConnPool(db.Statement.ConnPool) return t } func (t trainWheelDiameter) replaceDB(db *gorm.DB) trainWheelDiameter { t.trainWheelDiameterDo.ReplaceDB(db) return t } type trainWheelDiameterDo struct{ gen.DO } type ITrainWheelDiameterDo interface { gen.SubQuery Debug() ITrainWheelDiameterDo WithContext(ctx context.Context) ITrainWheelDiameterDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() ITrainWheelDiameterDo WriteDB() ITrainWheelDiameterDo As(alias string) gen.Dao Session(config *gorm.Session) ITrainWheelDiameterDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) ITrainWheelDiameterDo Not(conds ...gen.Condition) ITrainWheelDiameterDo Or(conds ...gen.Condition) ITrainWheelDiameterDo Select(conds ...field.Expr) ITrainWheelDiameterDo Where(conds ...gen.Condition) ITrainWheelDiameterDo Order(conds ...field.Expr) ITrainWheelDiameterDo Distinct(cols ...field.Expr) ITrainWheelDiameterDo Omit(cols ...field.Expr) ITrainWheelDiameterDo Join(table schema.Tabler, on ...field.Expr) ITrainWheelDiameterDo LeftJoin(table schema.Tabler, on ...field.Expr) ITrainWheelDiameterDo RightJoin(table schema.Tabler, on ...field.Expr) ITrainWheelDiameterDo Group(cols ...field.Expr) ITrainWheelDiameterDo Having(conds ...gen.Condition) ITrainWheelDiameterDo Limit(limit int) ITrainWheelDiameterDo Offset(offset int) ITrainWheelDiameterDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainWheelDiameterDo Unscoped() ITrainWheelDiameterDo Create(values ...*model.TrainWheelDiameter) error CreateInBatches(values []*model.TrainWheelDiameter, batchSize int) error Save(values ...*model.TrainWheelDiameter) error First() (*model.TrainWheelDiameter, error) Take() (*model.TrainWheelDiameter, error) Last() (*model.TrainWheelDiameter, error) Find() ([]*model.TrainWheelDiameter, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainWheelDiameter, err error) FindInBatches(result *[]*model.TrainWheelDiameter, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest interface{}) error Delete(...*model.TrainWheelDiameter) (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) ITrainWheelDiameterDo Assign(attrs ...field.AssignExpr) ITrainWheelDiameterDo Joins(fields ...field.RelationField) ITrainWheelDiameterDo Preload(fields ...field.RelationField) ITrainWheelDiameterDo FirstOrInit() (*model.TrainWheelDiameter, error) FirstOrCreate() (*model.TrainWheelDiameter, error) FindByPage(offset int, limit int) (result []*model.TrainWheelDiameter, 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) ITrainWheelDiameterDo UnderlyingDB() *gorm.DB schema.Tabler } func (t trainWheelDiameterDo) Debug() ITrainWheelDiameterDo { return t.withDO(t.DO.Debug()) } func (t trainWheelDiameterDo) WithContext(ctx context.Context) ITrainWheelDiameterDo { return t.withDO(t.DO.WithContext(ctx)) } func (t trainWheelDiameterDo) ReadDB() ITrainWheelDiameterDo { return t.Clauses(dbresolver.Read) } func (t trainWheelDiameterDo) WriteDB() ITrainWheelDiameterDo { return t.Clauses(dbresolver.Write) } func (t trainWheelDiameterDo) Session(config *gorm.Session) ITrainWheelDiameterDo { return t.withDO(t.DO.Session(config)) } func (t trainWheelDiameterDo) Clauses(conds ...clause.Expression) ITrainWheelDiameterDo { return t.withDO(t.DO.Clauses(conds...)) } func (t trainWheelDiameterDo) Returning(value interface{}, columns ...string) ITrainWheelDiameterDo { return t.withDO(t.DO.Returning(value, columns...)) } func (t trainWheelDiameterDo) Not(conds ...gen.Condition) ITrainWheelDiameterDo { return t.withDO(t.DO.Not(conds...)) } func (t trainWheelDiameterDo) Or(conds ...gen.Condition) ITrainWheelDiameterDo { return t.withDO(t.DO.Or(conds...)) } func (t trainWheelDiameterDo) Select(conds ...field.Expr) ITrainWheelDiameterDo { return t.withDO(t.DO.Select(conds...)) } func (t trainWheelDiameterDo) Where(conds ...gen.Condition) ITrainWheelDiameterDo { return t.withDO(t.DO.Where(conds...)) } func (t trainWheelDiameterDo) Order(conds ...field.Expr) ITrainWheelDiameterDo { return t.withDO(t.DO.Order(conds...)) } func (t trainWheelDiameterDo) Distinct(cols ...field.Expr) ITrainWheelDiameterDo { return t.withDO(t.DO.Distinct(cols...)) } func (t trainWheelDiameterDo) Omit(cols ...field.Expr) ITrainWheelDiameterDo { return t.withDO(t.DO.Omit(cols...)) } func (t trainWheelDiameterDo) Join(table schema.Tabler, on ...field.Expr) ITrainWheelDiameterDo { return t.withDO(t.DO.Join(table, on...)) } func (t trainWheelDiameterDo) LeftJoin(table schema.Tabler, on ...field.Expr) ITrainWheelDiameterDo { return t.withDO(t.DO.LeftJoin(table, on...)) } func (t trainWheelDiameterDo) RightJoin(table schema.Tabler, on ...field.Expr) ITrainWheelDiameterDo { return t.withDO(t.DO.RightJoin(table, on...)) } func (t trainWheelDiameterDo) Group(cols ...field.Expr) ITrainWheelDiameterDo { return t.withDO(t.DO.Group(cols...)) } func (t trainWheelDiameterDo) Having(conds ...gen.Condition) ITrainWheelDiameterDo { return t.withDO(t.DO.Having(conds...)) } func (t trainWheelDiameterDo) Limit(limit int) ITrainWheelDiameterDo { return t.withDO(t.DO.Limit(limit)) } func (t trainWheelDiameterDo) Offset(offset int) ITrainWheelDiameterDo { return t.withDO(t.DO.Offset(offset)) } func (t trainWheelDiameterDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainWheelDiameterDo { return t.withDO(t.DO.Scopes(funcs...)) } func (t trainWheelDiameterDo) Unscoped() ITrainWheelDiameterDo { return t.withDO(t.DO.Unscoped()) } func (t trainWheelDiameterDo) Create(values ...*model.TrainWheelDiameter) error { if len(values) == 0 { return nil } return t.DO.Create(values) } func (t trainWheelDiameterDo) CreateInBatches(values []*model.TrainWheelDiameter, 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 trainWheelDiameterDo) Save(values ...*model.TrainWheelDiameter) error { if len(values) == 0 { return nil } return t.DO.Save(values) } func (t trainWheelDiameterDo) First() (*model.TrainWheelDiameter, error) { if result, err := t.DO.First(); err != nil { return nil, err } else { return result.(*model.TrainWheelDiameter), nil } } func (t trainWheelDiameterDo) Take() (*model.TrainWheelDiameter, error) { if result, err := t.DO.Take(); err != nil { return nil, err } else { return result.(*model.TrainWheelDiameter), nil } } func (t trainWheelDiameterDo) Last() (*model.TrainWheelDiameter, error) { if result, err := t.DO.Last(); err != nil { return nil, err } else { return result.(*model.TrainWheelDiameter), nil } } func (t trainWheelDiameterDo) Find() ([]*model.TrainWheelDiameter, error) { result, err := t.DO.Find() return result.([]*model.TrainWheelDiameter), err } func (t trainWheelDiameterDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainWheelDiameter, err error) { buf := make([]*model.TrainWheelDiameter, 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 trainWheelDiameterDo) FindInBatches(result *[]*model.TrainWheelDiameter, batchSize int, fc func(tx gen.Dao, batch int) error) error { return t.DO.FindInBatches(result, batchSize, fc) } func (t trainWheelDiameterDo) Attrs(attrs ...field.AssignExpr) ITrainWheelDiameterDo { return t.withDO(t.DO.Attrs(attrs...)) } func (t trainWheelDiameterDo) Assign(attrs ...field.AssignExpr) ITrainWheelDiameterDo { return t.withDO(t.DO.Assign(attrs...)) } func (t trainWheelDiameterDo) Joins(fields ...field.RelationField) ITrainWheelDiameterDo { for _, _f := range fields { t = *t.withDO(t.DO.Joins(_f)) } return &t } func (t trainWheelDiameterDo) Preload(fields ...field.RelationField) ITrainWheelDiameterDo { for _, _f := range fields { t = *t.withDO(t.DO.Preload(_f)) } return &t } func (t trainWheelDiameterDo) FirstOrInit() (*model.TrainWheelDiameter, error) { if result, err := t.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.TrainWheelDiameter), nil } } func (t trainWheelDiameterDo) FirstOrCreate() (*model.TrainWheelDiameter, error) { if result, err := t.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.TrainWheelDiameter), nil } } func (t trainWheelDiameterDo) FindByPage(offset int, limit int) (result []*model.TrainWheelDiameter, 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 trainWheelDiameterDo) 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 trainWheelDiameterDo) Scan(result interface{}) (err error) { return t.DO.Scan(result) } func (t trainWheelDiameterDo) Delete(models ...*model.TrainWheelDiameter) (result gen.ResultInfo, err error) { return t.DO.Delete(models) } func (t *trainWheelDiameterDo) withDO(do gen.Dao) *trainWheelDiameterDo { t.DO = *do.(*gen.DO) return t }