rts-sim-testing-service/db/dbquery/published_gi.gen.go
2023-09-18 15:19:07 +08:00

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