rts-sim-testing-service/db/dbquery/train_sensor.gen.go
2023-11-13 14:20:45 +08:00

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