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

401 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 newPublished(db *gorm.DB, opts ...gen.DOOption) published {
_published := published{}
_published.publishedDo.UseDB(db, opts...)
_published.publishedDo.UseModel(&model.Published{})
tableName := _published.publishedDo.TableName()
_published.ALL = field.NewAsterisk(tableName)
_published.ID = field.NewInt32(tableName, "id")
_published.Code = field.NewString(tableName, "code")
_published.Category = field.NewString(tableName, "category")
_published.DataID = field.NewInt32(tableName, "data_id")
_published.Type = field.NewInt32(tableName, "type")
_published.Status = field.NewInt32(tableName, "status")
_published.fillFieldMap()
return _published
}
type published struct {
publishedDo
ALL field.Asterisk
ID field.Int32 // id
Code field.String // 发布名称
Category field.String // 厂家信息
DataID field.Int32 // 版本Id
Type field.Int32 // 数据类型
Status field.Int32 // 显示状态
fieldMap map[string]field.Expr
}
func (p published) Table(newTableName string) *published {
p.publishedDo.UseTable(newTableName)
return p.updateTableName(newTableName)
}
func (p published) As(alias string) *published {
p.publishedDo.DO = *(p.publishedDo.As(alias).(*gen.DO))
return p.updateTableName(alias)
}
func (p *published) updateTableName(table string) *published {
p.ALL = field.NewAsterisk(table)
p.ID = field.NewInt32(table, "id")
p.Code = field.NewString(table, "code")
p.Category = field.NewString(table, "category")
p.DataID = field.NewInt32(table, "data_id")
p.Type = field.NewInt32(table, "type")
p.Status = field.NewInt32(table, "status")
p.fillFieldMap()
return p
}
func (p *published) 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 *published) fillFieldMap() {
p.fieldMap = make(map[string]field.Expr, 6)
p.fieldMap["id"] = p.ID
p.fieldMap["code"] = p.Code
p.fieldMap["category"] = p.Category
p.fieldMap["data_id"] = p.DataID
p.fieldMap["type"] = p.Type
p.fieldMap["status"] = p.Status
}
func (p published) clone(db *gorm.DB) published {
p.publishedDo.ReplaceConnPool(db.Statement.ConnPool)
return p
}
func (p published) replaceDB(db *gorm.DB) published {
p.publishedDo.ReplaceDB(db)
return p
}
type publishedDo struct{ gen.DO }
type IPublishedDo interface {
gen.SubQuery
Debug() IPublishedDo
WithContext(ctx context.Context) IPublishedDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IPublishedDo
WriteDB() IPublishedDo
As(alias string) gen.Dao
Session(config *gorm.Session) IPublishedDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IPublishedDo
Not(conds ...gen.Condition) IPublishedDo
Or(conds ...gen.Condition) IPublishedDo
Select(conds ...field.Expr) IPublishedDo
Where(conds ...gen.Condition) IPublishedDo
Order(conds ...field.Expr) IPublishedDo
Distinct(cols ...field.Expr) IPublishedDo
Omit(cols ...field.Expr) IPublishedDo
Join(table schema.Tabler, on ...field.Expr) IPublishedDo
LeftJoin(table schema.Tabler, on ...field.Expr) IPublishedDo
RightJoin(table schema.Tabler, on ...field.Expr) IPublishedDo
Group(cols ...field.Expr) IPublishedDo
Having(conds ...gen.Condition) IPublishedDo
Limit(limit int) IPublishedDo
Offset(offset int) IPublishedDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IPublishedDo
Unscoped() IPublishedDo
Create(values ...*model.Published) error
CreateInBatches(values []*model.Published, batchSize int) error
Save(values ...*model.Published) error
First() (*model.Published, error)
Take() (*model.Published, error)
Last() (*model.Published, error)
Find() ([]*model.Published, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Published, err error)
FindInBatches(result *[]*model.Published, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.Published) (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) IPublishedDo
Assign(attrs ...field.AssignExpr) IPublishedDo
Joins(fields ...field.RelationField) IPublishedDo
Preload(fields ...field.RelationField) IPublishedDo
FirstOrInit() (*model.Published, error)
FirstOrCreate() (*model.Published, error)
FindByPage(offset int, limit int) (result []*model.Published, 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) IPublishedDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (p publishedDo) Debug() IPublishedDo {
return p.withDO(p.DO.Debug())
}
func (p publishedDo) WithContext(ctx context.Context) IPublishedDo {
return p.withDO(p.DO.WithContext(ctx))
}
func (p publishedDo) ReadDB() IPublishedDo {
return p.Clauses(dbresolver.Read)
}
func (p publishedDo) WriteDB() IPublishedDo {
return p.Clauses(dbresolver.Write)
}
func (p publishedDo) Session(config *gorm.Session) IPublishedDo {
return p.withDO(p.DO.Session(config))
}
func (p publishedDo) Clauses(conds ...clause.Expression) IPublishedDo {
return p.withDO(p.DO.Clauses(conds...))
}
func (p publishedDo) Returning(value interface{}, columns ...string) IPublishedDo {
return p.withDO(p.DO.Returning(value, columns...))
}
func (p publishedDo) Not(conds ...gen.Condition) IPublishedDo {
return p.withDO(p.DO.Not(conds...))
}
func (p publishedDo) Or(conds ...gen.Condition) IPublishedDo {
return p.withDO(p.DO.Or(conds...))
}
func (p publishedDo) Select(conds ...field.Expr) IPublishedDo {
return p.withDO(p.DO.Select(conds...))
}
func (p publishedDo) Where(conds ...gen.Condition) IPublishedDo {
return p.withDO(p.DO.Where(conds...))
}
func (p publishedDo) Order(conds ...field.Expr) IPublishedDo {
return p.withDO(p.DO.Order(conds...))
}
func (p publishedDo) Distinct(cols ...field.Expr) IPublishedDo {
return p.withDO(p.DO.Distinct(cols...))
}
func (p publishedDo) Omit(cols ...field.Expr) IPublishedDo {
return p.withDO(p.DO.Omit(cols...))
}
func (p publishedDo) Join(table schema.Tabler, on ...field.Expr) IPublishedDo {
return p.withDO(p.DO.Join(table, on...))
}
func (p publishedDo) LeftJoin(table schema.Tabler, on ...field.Expr) IPublishedDo {
return p.withDO(p.DO.LeftJoin(table, on...))
}
func (p publishedDo) RightJoin(table schema.Tabler, on ...field.Expr) IPublishedDo {
return p.withDO(p.DO.RightJoin(table, on...))
}
func (p publishedDo) Group(cols ...field.Expr) IPublishedDo {
return p.withDO(p.DO.Group(cols...))
}
func (p publishedDo) Having(conds ...gen.Condition) IPublishedDo {
return p.withDO(p.DO.Having(conds...))
}
func (p publishedDo) Limit(limit int) IPublishedDo {
return p.withDO(p.DO.Limit(limit))
}
func (p publishedDo) Offset(offset int) IPublishedDo {
return p.withDO(p.DO.Offset(offset))
}
func (p publishedDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IPublishedDo {
return p.withDO(p.DO.Scopes(funcs...))
}
func (p publishedDo) Unscoped() IPublishedDo {
return p.withDO(p.DO.Unscoped())
}
func (p publishedDo) Create(values ...*model.Published) error {
if len(values) == 0 {
return nil
}
return p.DO.Create(values)
}
func (p publishedDo) CreateInBatches(values []*model.Published, 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 publishedDo) Save(values ...*model.Published) error {
if len(values) == 0 {
return nil
}
return p.DO.Save(values)
}
func (p publishedDo) First() (*model.Published, error) {
if result, err := p.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.Published), nil
}
}
func (p publishedDo) Take() (*model.Published, error) {
if result, err := p.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.Published), nil
}
}
func (p publishedDo) Last() (*model.Published, error) {
if result, err := p.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.Published), nil
}
}
func (p publishedDo) Find() ([]*model.Published, error) {
result, err := p.DO.Find()
return result.([]*model.Published), err
}
func (p publishedDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Published, err error) {
buf := make([]*model.Published, 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 publishedDo) FindInBatches(result *[]*model.Published, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return p.DO.FindInBatches(result, batchSize, fc)
}
func (p publishedDo) Attrs(attrs ...field.AssignExpr) IPublishedDo {
return p.withDO(p.DO.Attrs(attrs...))
}
func (p publishedDo) Assign(attrs ...field.AssignExpr) IPublishedDo {
return p.withDO(p.DO.Assign(attrs...))
}
func (p publishedDo) Joins(fields ...field.RelationField) IPublishedDo {
for _, _f := range fields {
p = *p.withDO(p.DO.Joins(_f))
}
return &p
}
func (p publishedDo) Preload(fields ...field.RelationField) IPublishedDo {
for _, _f := range fields {
p = *p.withDO(p.DO.Preload(_f))
}
return &p
}
func (p publishedDo) FirstOrInit() (*model.Published, error) {
if result, err := p.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.Published), nil
}
}
func (p publishedDo) FirstOrCreate() (*model.Published, error) {
if result, err := p.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.Published), nil
}
}
func (p publishedDo) FindByPage(offset int, limit int) (result []*model.Published, 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 publishedDo) 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 publishedDo) Scan(result interface{}) (err error) {
return p.DO.Scan(result)
}
func (p publishedDo) Delete(models ...*model.Published) (result gen.ResultInfo, err error) {
return p.DO.Delete(models)
}
func (p *publishedDo) withDO(do gen.Dao) *publishedDo {
p.DO = *do.(*gen.DO)
return p
}