393 lines
11 KiB
Go
393 lines
11 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 newTrainInfo(db *gorm.DB, opts ...gen.DOOption) trainInfo {
|
|
_trainInfo := trainInfo{}
|
|
|
|
_trainInfo.trainInfoDo.UseDB(db, opts...)
|
|
_trainInfo.trainInfoDo.UseModel(&model.TrainInfo{})
|
|
|
|
tableName := _trainInfo.trainInfoDo.TableName()
|
|
_trainInfo.ALL = field.NewAsterisk(tableName)
|
|
_trainInfo.ID = field.NewInt32(tableName, "id")
|
|
_trainInfo.Name = field.NewString(tableName, "name")
|
|
_trainInfo.Proto = field.NewBytes(tableName, "proto")
|
|
_trainInfo.Description = field.NewString(tableName, "description")
|
|
|
|
_trainInfo.fillFieldMap()
|
|
|
|
return _trainInfo
|
|
}
|
|
|
|
type trainInfo struct {
|
|
trainInfoDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int32 // id
|
|
Name field.String // 列车信息
|
|
Proto field.Bytes // 列车参数信息
|
|
Description field.String // 其他描述内容
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (t trainInfo) Table(newTableName string) *trainInfo {
|
|
t.trainInfoDo.UseTable(newTableName)
|
|
return t.updateTableName(newTableName)
|
|
}
|
|
|
|
func (t trainInfo) As(alias string) *trainInfo {
|
|
t.trainInfoDo.DO = *(t.trainInfoDo.As(alias).(*gen.DO))
|
|
return t.updateTableName(alias)
|
|
}
|
|
|
|
func (t *trainInfo) updateTableName(table string) *trainInfo {
|
|
t.ALL = field.NewAsterisk(table)
|
|
t.ID = field.NewInt32(table, "id")
|
|
t.Name = field.NewString(table, "name")
|
|
t.Proto = field.NewBytes(table, "proto")
|
|
t.Description = field.NewString(table, "description")
|
|
|
|
t.fillFieldMap()
|
|
|
|
return t
|
|
}
|
|
|
|
func (t *trainInfo) 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 *trainInfo) fillFieldMap() {
|
|
t.fieldMap = make(map[string]field.Expr, 4)
|
|
t.fieldMap["id"] = t.ID
|
|
t.fieldMap["name"] = t.Name
|
|
t.fieldMap["proto"] = t.Proto
|
|
t.fieldMap["description"] = t.Description
|
|
}
|
|
|
|
func (t trainInfo) clone(db *gorm.DB) trainInfo {
|
|
t.trainInfoDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return t
|
|
}
|
|
|
|
func (t trainInfo) replaceDB(db *gorm.DB) trainInfo {
|
|
t.trainInfoDo.ReplaceDB(db)
|
|
return t
|
|
}
|
|
|
|
type trainInfoDo struct{ gen.DO }
|
|
|
|
type ITrainInfoDo interface {
|
|
gen.SubQuery
|
|
Debug() ITrainInfoDo
|
|
WithContext(ctx context.Context) ITrainInfoDo
|
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
|
ReplaceDB(db *gorm.DB)
|
|
ReadDB() ITrainInfoDo
|
|
WriteDB() ITrainInfoDo
|
|
As(alias string) gen.Dao
|
|
Session(config *gorm.Session) ITrainInfoDo
|
|
Columns(cols ...field.Expr) gen.Columns
|
|
Clauses(conds ...clause.Expression) ITrainInfoDo
|
|
Not(conds ...gen.Condition) ITrainInfoDo
|
|
Or(conds ...gen.Condition) ITrainInfoDo
|
|
Select(conds ...field.Expr) ITrainInfoDo
|
|
Where(conds ...gen.Condition) ITrainInfoDo
|
|
Order(conds ...field.Expr) ITrainInfoDo
|
|
Distinct(cols ...field.Expr) ITrainInfoDo
|
|
Omit(cols ...field.Expr) ITrainInfoDo
|
|
Join(table schema.Tabler, on ...field.Expr) ITrainInfoDo
|
|
LeftJoin(table schema.Tabler, on ...field.Expr) ITrainInfoDo
|
|
RightJoin(table schema.Tabler, on ...field.Expr) ITrainInfoDo
|
|
Group(cols ...field.Expr) ITrainInfoDo
|
|
Having(conds ...gen.Condition) ITrainInfoDo
|
|
Limit(limit int) ITrainInfoDo
|
|
Offset(offset int) ITrainInfoDo
|
|
Count() (count int64, err error)
|
|
Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainInfoDo
|
|
Unscoped() ITrainInfoDo
|
|
Create(values ...*model.TrainInfo) error
|
|
CreateInBatches(values []*model.TrainInfo, batchSize int) error
|
|
Save(values ...*model.TrainInfo) error
|
|
First() (*model.TrainInfo, error)
|
|
Take() (*model.TrainInfo, error)
|
|
Last() (*model.TrainInfo, error)
|
|
Find() ([]*model.TrainInfo, error)
|
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainInfo, err error)
|
|
FindInBatches(result *[]*model.TrainInfo, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
|
Pluck(column field.Expr, dest interface{}) error
|
|
Delete(...*model.TrainInfo) (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) ITrainInfoDo
|
|
Assign(attrs ...field.AssignExpr) ITrainInfoDo
|
|
Joins(fields ...field.RelationField) ITrainInfoDo
|
|
Preload(fields ...field.RelationField) ITrainInfoDo
|
|
FirstOrInit() (*model.TrainInfo, error)
|
|
FirstOrCreate() (*model.TrainInfo, error)
|
|
FindByPage(offset int, limit int) (result []*model.TrainInfo, 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) ITrainInfoDo
|
|
UnderlyingDB() *gorm.DB
|
|
schema.Tabler
|
|
}
|
|
|
|
func (t trainInfoDo) Debug() ITrainInfoDo {
|
|
return t.withDO(t.DO.Debug())
|
|
}
|
|
|
|
func (t trainInfoDo) WithContext(ctx context.Context) ITrainInfoDo {
|
|
return t.withDO(t.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (t trainInfoDo) ReadDB() ITrainInfoDo {
|
|
return t.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (t trainInfoDo) WriteDB() ITrainInfoDo {
|
|
return t.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (t trainInfoDo) Session(config *gorm.Session) ITrainInfoDo {
|
|
return t.withDO(t.DO.Session(config))
|
|
}
|
|
|
|
func (t trainInfoDo) Clauses(conds ...clause.Expression) ITrainInfoDo {
|
|
return t.withDO(t.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (t trainInfoDo) Returning(value interface{}, columns ...string) ITrainInfoDo {
|
|
return t.withDO(t.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (t trainInfoDo) Not(conds ...gen.Condition) ITrainInfoDo {
|
|
return t.withDO(t.DO.Not(conds...))
|
|
}
|
|
|
|
func (t trainInfoDo) Or(conds ...gen.Condition) ITrainInfoDo {
|
|
return t.withDO(t.DO.Or(conds...))
|
|
}
|
|
|
|
func (t trainInfoDo) Select(conds ...field.Expr) ITrainInfoDo {
|
|
return t.withDO(t.DO.Select(conds...))
|
|
}
|
|
|
|
func (t trainInfoDo) Where(conds ...gen.Condition) ITrainInfoDo {
|
|
return t.withDO(t.DO.Where(conds...))
|
|
}
|
|
|
|
func (t trainInfoDo) Order(conds ...field.Expr) ITrainInfoDo {
|
|
return t.withDO(t.DO.Order(conds...))
|
|
}
|
|
|
|
func (t trainInfoDo) Distinct(cols ...field.Expr) ITrainInfoDo {
|
|
return t.withDO(t.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (t trainInfoDo) Omit(cols ...field.Expr) ITrainInfoDo {
|
|
return t.withDO(t.DO.Omit(cols...))
|
|
}
|
|
|
|
func (t trainInfoDo) Join(table schema.Tabler, on ...field.Expr) ITrainInfoDo {
|
|
return t.withDO(t.DO.Join(table, on...))
|
|
}
|
|
|
|
func (t trainInfoDo) LeftJoin(table schema.Tabler, on ...field.Expr) ITrainInfoDo {
|
|
return t.withDO(t.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (t trainInfoDo) RightJoin(table schema.Tabler, on ...field.Expr) ITrainInfoDo {
|
|
return t.withDO(t.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (t trainInfoDo) Group(cols ...field.Expr) ITrainInfoDo {
|
|
return t.withDO(t.DO.Group(cols...))
|
|
}
|
|
|
|
func (t trainInfoDo) Having(conds ...gen.Condition) ITrainInfoDo {
|
|
return t.withDO(t.DO.Having(conds...))
|
|
}
|
|
|
|
func (t trainInfoDo) Limit(limit int) ITrainInfoDo {
|
|
return t.withDO(t.DO.Limit(limit))
|
|
}
|
|
|
|
func (t trainInfoDo) Offset(offset int) ITrainInfoDo {
|
|
return t.withDO(t.DO.Offset(offset))
|
|
}
|
|
|
|
func (t trainInfoDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainInfoDo {
|
|
return t.withDO(t.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (t trainInfoDo) Unscoped() ITrainInfoDo {
|
|
return t.withDO(t.DO.Unscoped())
|
|
}
|
|
|
|
func (t trainInfoDo) Create(values ...*model.TrainInfo) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return t.DO.Create(values)
|
|
}
|
|
|
|
func (t trainInfoDo) CreateInBatches(values []*model.TrainInfo, 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 trainInfoDo) Save(values ...*model.TrainInfo) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return t.DO.Save(values)
|
|
}
|
|
|
|
func (t trainInfoDo) First() (*model.TrainInfo, error) {
|
|
if result, err := t.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.TrainInfo), nil
|
|
}
|
|
}
|
|
|
|
func (t trainInfoDo) Take() (*model.TrainInfo, error) {
|
|
if result, err := t.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.TrainInfo), nil
|
|
}
|
|
}
|
|
|
|
func (t trainInfoDo) Last() (*model.TrainInfo, error) {
|
|
if result, err := t.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.TrainInfo), nil
|
|
}
|
|
}
|
|
|
|
func (t trainInfoDo) Find() ([]*model.TrainInfo, error) {
|
|
result, err := t.DO.Find()
|
|
return result.([]*model.TrainInfo), err
|
|
}
|
|
|
|
func (t trainInfoDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainInfo, err error) {
|
|
buf := make([]*model.TrainInfo, 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 trainInfoDo) FindInBatches(result *[]*model.TrainInfo, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return t.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (t trainInfoDo) Attrs(attrs ...field.AssignExpr) ITrainInfoDo {
|
|
return t.withDO(t.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (t trainInfoDo) Assign(attrs ...field.AssignExpr) ITrainInfoDo {
|
|
return t.withDO(t.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (t trainInfoDo) Joins(fields ...field.RelationField) ITrainInfoDo {
|
|
for _, _f := range fields {
|
|
t = *t.withDO(t.DO.Joins(_f))
|
|
}
|
|
return &t
|
|
}
|
|
|
|
func (t trainInfoDo) Preload(fields ...field.RelationField) ITrainInfoDo {
|
|
for _, _f := range fields {
|
|
t = *t.withDO(t.DO.Preload(_f))
|
|
}
|
|
return &t
|
|
}
|
|
|
|
func (t trainInfoDo) FirstOrInit() (*model.TrainInfo, error) {
|
|
if result, err := t.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.TrainInfo), nil
|
|
}
|
|
}
|
|
|
|
func (t trainInfoDo) FirstOrCreate() (*model.TrainInfo, error) {
|
|
if result, err := t.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.TrainInfo), nil
|
|
}
|
|
}
|
|
|
|
func (t trainInfoDo) FindByPage(offset int, limit int) (result []*model.TrainInfo, 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 trainInfoDo) 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 trainInfoDo) Scan(result interface{}) (err error) {
|
|
return t.DO.Scan(result)
|
|
}
|
|
|
|
func (t trainInfoDo) Delete(models ...*model.TrainInfo) (result gen.ResultInfo, err error) {
|
|
return t.DO.Delete(models)
|
|
}
|
|
|
|
func (t *trainInfoDo) withDO(do gen.Dao) *trainInfoDo {
|
|
t.DO = *do.(*gen.DO)
|
|
return t
|
|
}
|