// 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 newDrafting(db *gorm.DB, opts ...gen.DOOption) drafting { _drafting := drafting{} _drafting.draftingDo.UseDB(db, opts...) _drafting.draftingDo.UseModel(&model.Drafting{}) tableName := _drafting.draftingDo.TableName() _drafting.ALL = field.NewAsterisk(tableName) _drafting.ID = field.NewInt32(tableName, "id") _drafting.Name = field.NewString(tableName, "name") _drafting.Category = field.NewString(tableName, "category") _drafting.Type = field.NewInt32(tableName, "type") _drafting.Proto = field.NewBytes(tableName, "proto") _drafting.CreatorID = field.NewInt32(tableName, "creator_id") _drafting.CreatedAt = field.NewTime(tableName, "created_at") _drafting.UpdateAt = field.NewTime(tableName, "update_at") _drafting.fillFieldMap() return _drafting } type drafting struct { draftingDo ALL field.Asterisk ID field.Int32 // id Name field.String // 草稿图名称 Category field.String // 厂家编码 Type field.Int32 // 数据类型 Proto field.Bytes // 绘图数据 CreatorID field.Int32 // 创建人id CreatedAt field.Time // 创建时间 UpdateAt field.Time // 修改时间 fieldMap map[string]field.Expr } func (d drafting) Table(newTableName string) *drafting { d.draftingDo.UseTable(newTableName) return d.updateTableName(newTableName) } func (d drafting) As(alias string) *drafting { d.draftingDo.DO = *(d.draftingDo.As(alias).(*gen.DO)) return d.updateTableName(alias) } func (d *drafting) updateTableName(table string) *drafting { d.ALL = field.NewAsterisk(table) d.ID = field.NewInt32(table, "id") d.Name = field.NewString(table, "name") d.Category = field.NewString(table, "category") d.Type = field.NewInt32(table, "type") d.Proto = field.NewBytes(table, "proto") d.CreatorID = field.NewInt32(table, "creator_id") d.CreatedAt = field.NewTime(table, "created_at") d.UpdateAt = field.NewTime(table, "update_at") d.fillFieldMap() return d } func (d *drafting) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := d.fieldMap[fieldName] if !ok || _f == nil { return nil, false } _oe, ok := _f.(field.OrderExpr) return _oe, ok } func (d *drafting) fillFieldMap() { d.fieldMap = make(map[string]field.Expr, 8) d.fieldMap["id"] = d.ID d.fieldMap["name"] = d.Name d.fieldMap["category"] = d.Category d.fieldMap["type"] = d.Type d.fieldMap["proto"] = d.Proto d.fieldMap["creator_id"] = d.CreatorID d.fieldMap["created_at"] = d.CreatedAt d.fieldMap["update_at"] = d.UpdateAt } func (d drafting) clone(db *gorm.DB) drafting { d.draftingDo.ReplaceConnPool(db.Statement.ConnPool) return d } func (d drafting) replaceDB(db *gorm.DB) drafting { d.draftingDo.ReplaceDB(db) return d } type draftingDo struct{ gen.DO } type IDraftingDo interface { gen.SubQuery Debug() IDraftingDo WithContext(ctx context.Context) IDraftingDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() IDraftingDo WriteDB() IDraftingDo As(alias string) gen.Dao Session(config *gorm.Session) IDraftingDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) IDraftingDo Not(conds ...gen.Condition) IDraftingDo Or(conds ...gen.Condition) IDraftingDo Select(conds ...field.Expr) IDraftingDo Where(conds ...gen.Condition) IDraftingDo Order(conds ...field.Expr) IDraftingDo Distinct(cols ...field.Expr) IDraftingDo Omit(cols ...field.Expr) IDraftingDo Join(table schema.Tabler, on ...field.Expr) IDraftingDo LeftJoin(table schema.Tabler, on ...field.Expr) IDraftingDo RightJoin(table schema.Tabler, on ...field.Expr) IDraftingDo Group(cols ...field.Expr) IDraftingDo Having(conds ...gen.Condition) IDraftingDo Limit(limit int) IDraftingDo Offset(offset int) IDraftingDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) IDraftingDo Unscoped() IDraftingDo Create(values ...*model.Drafting) error CreateInBatches(values []*model.Drafting, batchSize int) error Save(values ...*model.Drafting) error First() (*model.Drafting, error) Take() (*model.Drafting, error) Last() (*model.Drafting, error) Find() ([]*model.Drafting, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Drafting, err error) FindInBatches(result *[]*model.Drafting, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest interface{}) error Delete(...*model.Drafting) (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) IDraftingDo Assign(attrs ...field.AssignExpr) IDraftingDo Joins(fields ...field.RelationField) IDraftingDo Preload(fields ...field.RelationField) IDraftingDo FirstOrInit() (*model.Drafting, error) FirstOrCreate() (*model.Drafting, error) FindByPage(offset int, limit int) (result []*model.Drafting, 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) IDraftingDo UnderlyingDB() *gorm.DB schema.Tabler } func (d draftingDo) Debug() IDraftingDo { return d.withDO(d.DO.Debug()) } func (d draftingDo) WithContext(ctx context.Context) IDraftingDo { return d.withDO(d.DO.WithContext(ctx)) } func (d draftingDo) ReadDB() IDraftingDo { return d.Clauses(dbresolver.Read) } func (d draftingDo) WriteDB() IDraftingDo { return d.Clauses(dbresolver.Write) } func (d draftingDo) Session(config *gorm.Session) IDraftingDo { return d.withDO(d.DO.Session(config)) } func (d draftingDo) Clauses(conds ...clause.Expression) IDraftingDo { return d.withDO(d.DO.Clauses(conds...)) } func (d draftingDo) Returning(value interface{}, columns ...string) IDraftingDo { return d.withDO(d.DO.Returning(value, columns...)) } func (d draftingDo) Not(conds ...gen.Condition) IDraftingDo { return d.withDO(d.DO.Not(conds...)) } func (d draftingDo) Or(conds ...gen.Condition) IDraftingDo { return d.withDO(d.DO.Or(conds...)) } func (d draftingDo) Select(conds ...field.Expr) IDraftingDo { return d.withDO(d.DO.Select(conds...)) } func (d draftingDo) Where(conds ...gen.Condition) IDraftingDo { return d.withDO(d.DO.Where(conds...)) } func (d draftingDo) Order(conds ...field.Expr) IDraftingDo { return d.withDO(d.DO.Order(conds...)) } func (d draftingDo) Distinct(cols ...field.Expr) IDraftingDo { return d.withDO(d.DO.Distinct(cols...)) } func (d draftingDo) Omit(cols ...field.Expr) IDraftingDo { return d.withDO(d.DO.Omit(cols...)) } func (d draftingDo) Join(table schema.Tabler, on ...field.Expr) IDraftingDo { return d.withDO(d.DO.Join(table, on...)) } func (d draftingDo) LeftJoin(table schema.Tabler, on ...field.Expr) IDraftingDo { return d.withDO(d.DO.LeftJoin(table, on...)) } func (d draftingDo) RightJoin(table schema.Tabler, on ...field.Expr) IDraftingDo { return d.withDO(d.DO.RightJoin(table, on...)) } func (d draftingDo) Group(cols ...field.Expr) IDraftingDo { return d.withDO(d.DO.Group(cols...)) } func (d draftingDo) Having(conds ...gen.Condition) IDraftingDo { return d.withDO(d.DO.Having(conds...)) } func (d draftingDo) Limit(limit int) IDraftingDo { return d.withDO(d.DO.Limit(limit)) } func (d draftingDo) Offset(offset int) IDraftingDo { return d.withDO(d.DO.Offset(offset)) } func (d draftingDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IDraftingDo { return d.withDO(d.DO.Scopes(funcs...)) } func (d draftingDo) Unscoped() IDraftingDo { return d.withDO(d.DO.Unscoped()) } func (d draftingDo) Create(values ...*model.Drafting) error { if len(values) == 0 { return nil } return d.DO.Create(values) } func (d draftingDo) CreateInBatches(values []*model.Drafting, batchSize int) error { return d.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 (d draftingDo) Save(values ...*model.Drafting) error { if len(values) == 0 { return nil } return d.DO.Save(values) } func (d draftingDo) First() (*model.Drafting, error) { if result, err := d.DO.First(); err != nil { return nil, err } else { return result.(*model.Drafting), nil } } func (d draftingDo) Take() (*model.Drafting, error) { if result, err := d.DO.Take(); err != nil { return nil, err } else { return result.(*model.Drafting), nil } } func (d draftingDo) Last() (*model.Drafting, error) { if result, err := d.DO.Last(); err != nil { return nil, err } else { return result.(*model.Drafting), nil } } func (d draftingDo) Find() ([]*model.Drafting, error) { result, err := d.DO.Find() return result.([]*model.Drafting), err } func (d draftingDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Drafting, err error) { buf := make([]*model.Drafting, 0, batchSize) err = d.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 (d draftingDo) FindInBatches(result *[]*model.Drafting, batchSize int, fc func(tx gen.Dao, batch int) error) error { return d.DO.FindInBatches(result, batchSize, fc) } func (d draftingDo) Attrs(attrs ...field.AssignExpr) IDraftingDo { return d.withDO(d.DO.Attrs(attrs...)) } func (d draftingDo) Assign(attrs ...field.AssignExpr) IDraftingDo { return d.withDO(d.DO.Assign(attrs...)) } func (d draftingDo) Joins(fields ...field.RelationField) IDraftingDo { for _, _f := range fields { d = *d.withDO(d.DO.Joins(_f)) } return &d } func (d draftingDo) Preload(fields ...field.RelationField) IDraftingDo { for _, _f := range fields { d = *d.withDO(d.DO.Preload(_f)) } return &d } func (d draftingDo) FirstOrInit() (*model.Drafting, error) { if result, err := d.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.Drafting), nil } } func (d draftingDo) FirstOrCreate() (*model.Drafting, error) { if result, err := d.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.Drafting), nil } } func (d draftingDo) FindByPage(offset int, limit int) (result []*model.Drafting, count int64, err error) { result, err = d.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 = d.Offset(-1).Limit(-1).Count() return } func (d draftingDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { count, err = d.Count() if err != nil { return } err = d.Offset(offset).Limit(limit).Scan(result) return } func (d draftingDo) Scan(result interface{}) (err error) { return d.DO.Scan(result) } func (d draftingDo) Delete(models ...*model.Drafting) (result gen.ResultInfo, err error) { return d.DO.Delete(models) } func (d *draftingDo) withDO(do gen.Dao) *draftingDo { d.DO = *do.(*gen.DO) return d }