389 lines
13 KiB
Go
389 lines
13 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 newProjectTrainSizeLink(db *gorm.DB, opts ...gen.DOOption) projectTrainSizeLink {
|
||
|
_projectTrainSizeLink := projectTrainSizeLink{}
|
||
|
|
||
|
_projectTrainSizeLink.projectTrainSizeLinkDo.UseDB(db, opts...)
|
||
|
_projectTrainSizeLink.projectTrainSizeLinkDo.UseModel(&model.ProjectTrainSizeLink{})
|
||
|
|
||
|
tableName := _projectTrainSizeLink.projectTrainSizeLinkDo.TableName()
|
||
|
_projectTrainSizeLink.ALL = field.NewAsterisk(tableName)
|
||
|
_projectTrainSizeLink.ID = field.NewInt32(tableName, "id")
|
||
|
_projectTrainSizeLink.Pid = field.NewInt32(tableName, "pid")
|
||
|
_projectTrainSizeLink.Sid = field.NewInt32(tableName, "sid")
|
||
|
|
||
|
_projectTrainSizeLink.fillFieldMap()
|
||
|
|
||
|
return _projectTrainSizeLink
|
||
|
}
|
||
|
|
||
|
type projectTrainSizeLink struct {
|
||
|
projectTrainSizeLinkDo
|
||
|
|
||
|
ALL field.Asterisk
|
||
|
ID field.Int32 // 主键
|
||
|
Pid field.Int32 // 项目主键
|
||
|
Sid field.Int32 // 列车尺寸主键
|
||
|
|
||
|
fieldMap map[string]field.Expr
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLink) Table(newTableName string) *projectTrainSizeLink {
|
||
|
p.projectTrainSizeLinkDo.UseTable(newTableName)
|
||
|
return p.updateTableName(newTableName)
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLink) As(alias string) *projectTrainSizeLink {
|
||
|
p.projectTrainSizeLinkDo.DO = *(p.projectTrainSizeLinkDo.As(alias).(*gen.DO))
|
||
|
return p.updateTableName(alias)
|
||
|
}
|
||
|
|
||
|
func (p *projectTrainSizeLink) updateTableName(table string) *projectTrainSizeLink {
|
||
|
p.ALL = field.NewAsterisk(table)
|
||
|
p.ID = field.NewInt32(table, "id")
|
||
|
p.Pid = field.NewInt32(table, "pid")
|
||
|
p.Sid = field.NewInt32(table, "sid")
|
||
|
|
||
|
p.fillFieldMap()
|
||
|
|
||
|
return p
|
||
|
}
|
||
|
|
||
|
func (p *projectTrainSizeLink) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||
|
_f, ok := p.fieldMap[fieldName]
|
||
|
if !ok || _f == nil {
|
||
|
return nil, false
|
||
|
}
|
||
|
_oe, ok := _f.(field.OrderExpr)
|
||
|
return _oe, ok
|
||
|
}
|
||
|
|
||
|
func (p *projectTrainSizeLink) fillFieldMap() {
|
||
|
p.fieldMap = make(map[string]field.Expr, 3)
|
||
|
p.fieldMap["id"] = p.ID
|
||
|
p.fieldMap["pid"] = p.Pid
|
||
|
p.fieldMap["sid"] = p.Sid
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLink) clone(db *gorm.DB) projectTrainSizeLink {
|
||
|
p.projectTrainSizeLinkDo.ReplaceConnPool(db.Statement.ConnPool)
|
||
|
return p
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLink) replaceDB(db *gorm.DB) projectTrainSizeLink {
|
||
|
p.projectTrainSizeLinkDo.ReplaceDB(db)
|
||
|
return p
|
||
|
}
|
||
|
|
||
|
type projectTrainSizeLinkDo struct{ gen.DO }
|
||
|
|
||
|
type IProjectTrainSizeLinkDo interface {
|
||
|
gen.SubQuery
|
||
|
Debug() IProjectTrainSizeLinkDo
|
||
|
WithContext(ctx context.Context) IProjectTrainSizeLinkDo
|
||
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||
|
ReplaceDB(db *gorm.DB)
|
||
|
ReadDB() IProjectTrainSizeLinkDo
|
||
|
WriteDB() IProjectTrainSizeLinkDo
|
||
|
As(alias string) gen.Dao
|
||
|
Session(config *gorm.Session) IProjectTrainSizeLinkDo
|
||
|
Columns(cols ...field.Expr) gen.Columns
|
||
|
Clauses(conds ...clause.Expression) IProjectTrainSizeLinkDo
|
||
|
Not(conds ...gen.Condition) IProjectTrainSizeLinkDo
|
||
|
Or(conds ...gen.Condition) IProjectTrainSizeLinkDo
|
||
|
Select(conds ...field.Expr) IProjectTrainSizeLinkDo
|
||
|
Where(conds ...gen.Condition) IProjectTrainSizeLinkDo
|
||
|
Order(conds ...field.Expr) IProjectTrainSizeLinkDo
|
||
|
Distinct(cols ...field.Expr) IProjectTrainSizeLinkDo
|
||
|
Omit(cols ...field.Expr) IProjectTrainSizeLinkDo
|
||
|
Join(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo
|
||
|
LeftJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo
|
||
|
RightJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo
|
||
|
Group(cols ...field.Expr) IProjectTrainSizeLinkDo
|
||
|
Having(conds ...gen.Condition) IProjectTrainSizeLinkDo
|
||
|
Limit(limit int) IProjectTrainSizeLinkDo
|
||
|
Offset(offset int) IProjectTrainSizeLinkDo
|
||
|
Count() (count int64, err error)
|
||
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IProjectTrainSizeLinkDo
|
||
|
Unscoped() IProjectTrainSizeLinkDo
|
||
|
Create(values ...*model.ProjectTrainSizeLink) error
|
||
|
CreateInBatches(values []*model.ProjectTrainSizeLink, batchSize int) error
|
||
|
Save(values ...*model.ProjectTrainSizeLink) error
|
||
|
First() (*model.ProjectTrainSizeLink, error)
|
||
|
Take() (*model.ProjectTrainSizeLink, error)
|
||
|
Last() (*model.ProjectTrainSizeLink, error)
|
||
|
Find() ([]*model.ProjectTrainSizeLink, error)
|
||
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectTrainSizeLink, err error)
|
||
|
FindInBatches(result *[]*model.ProjectTrainSizeLink, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||
|
Pluck(column field.Expr, dest interface{}) error
|
||
|
Delete(...*model.ProjectTrainSizeLink) (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) IProjectTrainSizeLinkDo
|
||
|
Assign(attrs ...field.AssignExpr) IProjectTrainSizeLinkDo
|
||
|
Joins(fields ...field.RelationField) IProjectTrainSizeLinkDo
|
||
|
Preload(fields ...field.RelationField) IProjectTrainSizeLinkDo
|
||
|
FirstOrInit() (*model.ProjectTrainSizeLink, error)
|
||
|
FirstOrCreate() (*model.ProjectTrainSizeLink, error)
|
||
|
FindByPage(offset int, limit int) (result []*model.ProjectTrainSizeLink, 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) IProjectTrainSizeLinkDo
|
||
|
UnderlyingDB() *gorm.DB
|
||
|
schema.Tabler
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Debug() IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Debug())
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) WithContext(ctx context.Context) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.WithContext(ctx))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) ReadDB() IProjectTrainSizeLinkDo {
|
||
|
return p.Clauses(dbresolver.Read)
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) WriteDB() IProjectTrainSizeLinkDo {
|
||
|
return p.Clauses(dbresolver.Write)
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Session(config *gorm.Session) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Session(config))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Clauses(conds ...clause.Expression) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Clauses(conds...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Returning(value interface{}, columns ...string) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Returning(value, columns...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Not(conds ...gen.Condition) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Not(conds...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Or(conds ...gen.Condition) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Or(conds...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Select(conds ...field.Expr) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Select(conds...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Where(conds ...gen.Condition) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Where(conds...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Order(conds ...field.Expr) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Order(conds...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Distinct(cols ...field.Expr) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Distinct(cols...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Omit(cols ...field.Expr) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Omit(cols...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Join(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Join(table, on...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) LeftJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.LeftJoin(table, on...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) RightJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.RightJoin(table, on...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Group(cols ...field.Expr) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Group(cols...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Having(conds ...gen.Condition) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Having(conds...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Limit(limit int) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Limit(limit))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Offset(offset int) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Offset(offset))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Scopes(funcs...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Unscoped() IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Unscoped())
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Create(values ...*model.ProjectTrainSizeLink) error {
|
||
|
if len(values) == 0 {
|
||
|
return nil
|
||
|
}
|
||
|
return p.DO.Create(values)
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) CreateInBatches(values []*model.ProjectTrainSizeLink, batchSize int) error {
|
||
|
return p.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 (p projectTrainSizeLinkDo) Save(values ...*model.ProjectTrainSizeLink) error {
|
||
|
if len(values) == 0 {
|
||
|
return nil
|
||
|
}
|
||
|
return p.DO.Save(values)
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) First() (*model.ProjectTrainSizeLink, error) {
|
||
|
if result, err := p.DO.First(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*model.ProjectTrainSizeLink), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Take() (*model.ProjectTrainSizeLink, error) {
|
||
|
if result, err := p.DO.Take(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*model.ProjectTrainSizeLink), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Last() (*model.ProjectTrainSizeLink, error) {
|
||
|
if result, err := p.DO.Last(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*model.ProjectTrainSizeLink), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Find() ([]*model.ProjectTrainSizeLink, error) {
|
||
|
result, err := p.DO.Find()
|
||
|
return result.([]*model.ProjectTrainSizeLink), err
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectTrainSizeLink, err error) {
|
||
|
buf := make([]*model.ProjectTrainSizeLink, 0, batchSize)
|
||
|
err = p.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 (p projectTrainSizeLinkDo) FindInBatches(result *[]*model.ProjectTrainSizeLink, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||
|
return p.DO.FindInBatches(result, batchSize, fc)
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Attrs(attrs ...field.AssignExpr) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Attrs(attrs...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Assign(attrs ...field.AssignExpr) IProjectTrainSizeLinkDo {
|
||
|
return p.withDO(p.DO.Assign(attrs...))
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Joins(fields ...field.RelationField) IProjectTrainSizeLinkDo {
|
||
|
for _, _f := range fields {
|
||
|
p = *p.withDO(p.DO.Joins(_f))
|
||
|
}
|
||
|
return &p
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Preload(fields ...field.RelationField) IProjectTrainSizeLinkDo {
|
||
|
for _, _f := range fields {
|
||
|
p = *p.withDO(p.DO.Preload(_f))
|
||
|
}
|
||
|
return &p
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) FirstOrInit() (*model.ProjectTrainSizeLink, error) {
|
||
|
if result, err := p.DO.FirstOrInit(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*model.ProjectTrainSizeLink), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) FirstOrCreate() (*model.ProjectTrainSizeLink, error) {
|
||
|
if result, err := p.DO.FirstOrCreate(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*model.ProjectTrainSizeLink), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) FindByPage(offset int, limit int) (result []*model.ProjectTrainSizeLink, count int64, err error) {
|
||
|
result, err = p.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 = p.Offset(-1).Limit(-1).Count()
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||
|
count, err = p.Count()
|
||
|
if err != nil {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
err = p.Offset(offset).Limit(limit).Scan(result)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Scan(result interface{}) (err error) {
|
||
|
return p.DO.Scan(result)
|
||
|
}
|
||
|
|
||
|
func (p projectTrainSizeLinkDo) Delete(models ...*model.ProjectTrainSizeLink) (result gen.ResultInfo, err error) {
|
||
|
return p.DO.Delete(models)
|
||
|
}
|
||
|
|
||
|
func (p *projectTrainSizeLinkDo) withDO(do gen.Dao) *projectTrainSizeLinkDo {
|
||
|
p.DO = *do.(*gen.DO)
|
||
|
return p
|
||
|
}
|