rts-sim-testing-service/db/dbquery/train_model.gen.go

397 lines
11 KiB
Go
Raw Normal View History

2023-08-22 16:44:34 +08:00
// 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 newTrainModel(db *gorm.DB, opts ...gen.DOOption) trainModel {
_trainModel := trainModel{}
_trainModel.trainModelDo.UseDB(db, opts...)
_trainModel.trainModelDo.UseModel(&model.TrainModel{})
tableName := _trainModel.trainModelDo.TableName()
_trainModel.ALL = field.NewAsterisk(tableName)
_trainModel.ID = field.NewInt32(tableName, "id")
_trainModel.Name = field.NewString(tableName, "name")
_trainModel.CarriageLength = field.NewInt32(tableName, "carriage_length")
_trainModel.CreatedAt = field.NewTime(tableName, "created_at")
_trainModel.UpdateAt = field.NewTime(tableName, "update_at")
_trainModel.fillFieldMap()
return _trainModel
}
type trainModel struct {
trainModelDo
ALL field.Asterisk
ID field.Int32
Name field.String // 组次名称
CarriageLength field.Int32 // 单个车厢长度
CreatedAt field.Time // 创建时间
UpdateAt field.Time // 更新时间
fieldMap map[string]field.Expr
}
func (t trainModel) Table(newTableName string) *trainModel {
t.trainModelDo.UseTable(newTableName)
return t.updateTableName(newTableName)
}
func (t trainModel) As(alias string) *trainModel {
t.trainModelDo.DO = *(t.trainModelDo.As(alias).(*gen.DO))
return t.updateTableName(alias)
}
func (t *trainModel) updateTableName(table string) *trainModel {
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.CreatedAt = field.NewTime(table, "created_at")
t.UpdateAt = field.NewTime(table, "update_at")
t.fillFieldMap()
return t
}
func (t *trainModel) 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 *trainModel) 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["created_at"] = t.CreatedAt
t.fieldMap["update_at"] = t.UpdateAt
}
func (t trainModel) clone(db *gorm.DB) trainModel {
t.trainModelDo.ReplaceConnPool(db.Statement.ConnPool)
return t
}
func (t trainModel) replaceDB(db *gorm.DB) trainModel {
t.trainModelDo.ReplaceDB(db)
return t
}
type trainModelDo struct{ gen.DO }
type ITrainModelDo interface {
gen.SubQuery
Debug() ITrainModelDo
WithContext(ctx context.Context) ITrainModelDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() ITrainModelDo
WriteDB() ITrainModelDo
As(alias string) gen.Dao
Session(config *gorm.Session) ITrainModelDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) ITrainModelDo
Not(conds ...gen.Condition) ITrainModelDo
Or(conds ...gen.Condition) ITrainModelDo
Select(conds ...field.Expr) ITrainModelDo
Where(conds ...gen.Condition) ITrainModelDo
Order(conds ...field.Expr) ITrainModelDo
Distinct(cols ...field.Expr) ITrainModelDo
Omit(cols ...field.Expr) ITrainModelDo
Join(table schema.Tabler, on ...field.Expr) ITrainModelDo
LeftJoin(table schema.Tabler, on ...field.Expr) ITrainModelDo
RightJoin(table schema.Tabler, on ...field.Expr) ITrainModelDo
Group(cols ...field.Expr) ITrainModelDo
Having(conds ...gen.Condition) ITrainModelDo
Limit(limit int) ITrainModelDo
Offset(offset int) ITrainModelDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainModelDo
Unscoped() ITrainModelDo
Create(values ...*model.TrainModel) error
CreateInBatches(values []*model.TrainModel, batchSize int) error
Save(values ...*model.TrainModel) error
First() (*model.TrainModel, error)
Take() (*model.TrainModel, error)
Last() (*model.TrainModel, error)
Find() ([]*model.TrainModel, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainModel, err error)
FindInBatches(result *[]*model.TrainModel, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.TrainModel) (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) ITrainModelDo
Assign(attrs ...field.AssignExpr) ITrainModelDo
Joins(fields ...field.RelationField) ITrainModelDo
Preload(fields ...field.RelationField) ITrainModelDo
FirstOrInit() (*model.TrainModel, error)
FirstOrCreate() (*model.TrainModel, error)
FindByPage(offset int, limit int) (result []*model.TrainModel, 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) ITrainModelDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (t trainModelDo) Debug() ITrainModelDo {
return t.withDO(t.DO.Debug())
}
func (t trainModelDo) WithContext(ctx context.Context) ITrainModelDo {
return t.withDO(t.DO.WithContext(ctx))
}
func (t trainModelDo) ReadDB() ITrainModelDo {
return t.Clauses(dbresolver.Read)
}
func (t trainModelDo) WriteDB() ITrainModelDo {
return t.Clauses(dbresolver.Write)
}
func (t trainModelDo) Session(config *gorm.Session) ITrainModelDo {
return t.withDO(t.DO.Session(config))
}
func (t trainModelDo) Clauses(conds ...clause.Expression) ITrainModelDo {
return t.withDO(t.DO.Clauses(conds...))
}
func (t trainModelDo) Returning(value interface{}, columns ...string) ITrainModelDo {
return t.withDO(t.DO.Returning(value, columns...))
}
func (t trainModelDo) Not(conds ...gen.Condition) ITrainModelDo {
return t.withDO(t.DO.Not(conds...))
}
func (t trainModelDo) Or(conds ...gen.Condition) ITrainModelDo {
return t.withDO(t.DO.Or(conds...))
}
func (t trainModelDo) Select(conds ...field.Expr) ITrainModelDo {
return t.withDO(t.DO.Select(conds...))
}
func (t trainModelDo) Where(conds ...gen.Condition) ITrainModelDo {
return t.withDO(t.DO.Where(conds...))
}
func (t trainModelDo) Order(conds ...field.Expr) ITrainModelDo {
return t.withDO(t.DO.Order(conds...))
}
func (t trainModelDo) Distinct(cols ...field.Expr) ITrainModelDo {
return t.withDO(t.DO.Distinct(cols...))
}
func (t trainModelDo) Omit(cols ...field.Expr) ITrainModelDo {
return t.withDO(t.DO.Omit(cols...))
}
func (t trainModelDo) Join(table schema.Tabler, on ...field.Expr) ITrainModelDo {
return t.withDO(t.DO.Join(table, on...))
}
func (t trainModelDo) LeftJoin(table schema.Tabler, on ...field.Expr) ITrainModelDo {
return t.withDO(t.DO.LeftJoin(table, on...))
}
func (t trainModelDo) RightJoin(table schema.Tabler, on ...field.Expr) ITrainModelDo {
return t.withDO(t.DO.RightJoin(table, on...))
}
func (t trainModelDo) Group(cols ...field.Expr) ITrainModelDo {
return t.withDO(t.DO.Group(cols...))
}
func (t trainModelDo) Having(conds ...gen.Condition) ITrainModelDo {
return t.withDO(t.DO.Having(conds...))
}
func (t trainModelDo) Limit(limit int) ITrainModelDo {
return t.withDO(t.DO.Limit(limit))
}
func (t trainModelDo) Offset(offset int) ITrainModelDo {
return t.withDO(t.DO.Offset(offset))
}
func (t trainModelDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainModelDo {
return t.withDO(t.DO.Scopes(funcs...))
}
func (t trainModelDo) Unscoped() ITrainModelDo {
return t.withDO(t.DO.Unscoped())
}
func (t trainModelDo) Create(values ...*model.TrainModel) error {
if len(values) == 0 {
return nil
}
return t.DO.Create(values)
}
func (t trainModelDo) CreateInBatches(values []*model.TrainModel, 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 trainModelDo) Save(values ...*model.TrainModel) error {
if len(values) == 0 {
return nil
}
return t.DO.Save(values)
}
func (t trainModelDo) First() (*model.TrainModel, error) {
if result, err := t.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.TrainModel), nil
}
}
func (t trainModelDo) Take() (*model.TrainModel, error) {
if result, err := t.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.TrainModel), nil
}
}
func (t trainModelDo) Last() (*model.TrainModel, error) {
if result, err := t.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.TrainModel), nil
}
}
func (t trainModelDo) Find() ([]*model.TrainModel, error) {
result, err := t.DO.Find()
return result.([]*model.TrainModel), err
}
func (t trainModelDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainModel, err error) {
buf := make([]*model.TrainModel, 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 trainModelDo) FindInBatches(result *[]*model.TrainModel, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return t.DO.FindInBatches(result, batchSize, fc)
}
func (t trainModelDo) Attrs(attrs ...field.AssignExpr) ITrainModelDo {
return t.withDO(t.DO.Attrs(attrs...))
}
func (t trainModelDo) Assign(attrs ...field.AssignExpr) ITrainModelDo {
return t.withDO(t.DO.Assign(attrs...))
}
func (t trainModelDo) Joins(fields ...field.RelationField) ITrainModelDo {
for _, _f := range fields {
t = *t.withDO(t.DO.Joins(_f))
}
return &t
}
func (t trainModelDo) Preload(fields ...field.RelationField) ITrainModelDo {
for _, _f := range fields {
t = *t.withDO(t.DO.Preload(_f))
}
return &t
}
func (t trainModelDo) FirstOrInit() (*model.TrainModel, error) {
if result, err := t.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.TrainModel), nil
}
}
func (t trainModelDo) FirstOrCreate() (*model.TrainModel, error) {
if result, err := t.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.TrainModel), nil
}
}
func (t trainModelDo) FindByPage(offset int, limit int) (result []*model.TrainModel, 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 trainModelDo) 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 trainModelDo) Scan(result interface{}) (err error) {
return t.DO.Scan(result)
}
func (t trainModelDo) Delete(models ...*model.TrainModel) (result gen.ResultInfo, err error) {
return t.DO.Delete(models)
}
func (t *trainModelDo) withDO(do gen.Dao) *trainModelDo {
t.DO = *do.(*gen.DO)
return t
}