// 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 query import ( "context" "gorm.io/gorm" "gorm.io/gorm/clause" "gorm.io/gorm/schema" "gorm.io/gen" "gorm.io/gen/field" "gorm.io/plugin/dbresolver" "wechat-api/database/dao/wechat/model" ) func newCreditBalance(db *gorm.DB, opts ...gen.DOOption) creditBalance { _creditBalance := creditBalance{} _creditBalance.creditBalanceDo.UseDB(db, opts...) _creditBalance.creditBalanceDo.UseModel(&model.CreditBalance{}) tableName := _creditBalance.creditBalanceDo.TableName() _creditBalance.ALL = field.NewAsterisk(tableName) _creditBalance.ID = field.NewInt64(tableName, "id") _creditBalance.CreatedAt = field.NewTime(tableName, "created_at") _creditBalance.UpdatedAt = field.NewTime(tableName, "updated_at") _creditBalance.Status = field.NewInt64(tableName, "status") _creditBalance.DeletedAt = field.NewField(tableName, "deleted_at") _creditBalance.UserID = field.NewString(tableName, "user_id") _creditBalance.Balance = field.NewField(tableName, "balance") _creditBalance.OrganizationID = field.NewInt64(tableName, "organization_id") _creditBalance.fillFieldMap() return _creditBalance } // creditBalance 积分余额表 type creditBalance struct { creditBalanceDo ALL field.Asterisk ID field.Int64 CreatedAt field.Time // Create Time | 创建日期 UpdatedAt field.Time // Update Time | 修改日期 Status field.Int64 // 状态 1 正常 2 禁用 DeletedAt field.Field // Delete Time | 删除日期 UserID field.String // 用户ID Balance field.Field // 积分余额 OrganizationID field.Int64 // 机构 ID fieldMap map[string]field.Expr } func (c creditBalance) Table(newTableName string) *creditBalance { c.creditBalanceDo.UseTable(newTableName) return c.updateTableName(newTableName) } func (c creditBalance) As(alias string) *creditBalance { c.creditBalanceDo.DO = *(c.creditBalanceDo.As(alias).(*gen.DO)) return c.updateTableName(alias) } func (c *creditBalance) updateTableName(table string) *creditBalance { c.ALL = field.NewAsterisk(table) c.ID = field.NewInt64(table, "id") c.CreatedAt = field.NewTime(table, "created_at") c.UpdatedAt = field.NewTime(table, "updated_at") c.Status = field.NewInt64(table, "status") c.DeletedAt = field.NewField(table, "deleted_at") c.UserID = field.NewString(table, "user_id") c.Balance = field.NewField(table, "balance") c.OrganizationID = field.NewInt64(table, "organization_id") c.fillFieldMap() return c } func (c *creditBalance) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := c.fieldMap[fieldName] if !ok || _f == nil { return nil, false } _oe, ok := _f.(field.OrderExpr) return _oe, ok } func (c *creditBalance) fillFieldMap() { c.fieldMap = make(map[string]field.Expr, 8) c.fieldMap["id"] = c.ID c.fieldMap["created_at"] = c.CreatedAt c.fieldMap["updated_at"] = c.UpdatedAt c.fieldMap["status"] = c.Status c.fieldMap["deleted_at"] = c.DeletedAt c.fieldMap["user_id"] = c.UserID c.fieldMap["balance"] = c.Balance c.fieldMap["organization_id"] = c.OrganizationID } func (c creditBalance) clone(db *gorm.DB) creditBalance { c.creditBalanceDo.ReplaceConnPool(db.Statement.ConnPool) return c } func (c creditBalance) replaceDB(db *gorm.DB) creditBalance { c.creditBalanceDo.ReplaceDB(db) return c } type creditBalanceDo struct{ gen.DO } type ICreditBalanceDo interface { gen.SubQuery Debug() ICreditBalanceDo WithContext(ctx context.Context) ICreditBalanceDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() ICreditBalanceDo WriteDB() ICreditBalanceDo As(alias string) gen.Dao Session(config *gorm.Session) ICreditBalanceDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) ICreditBalanceDo Not(conds ...gen.Condition) ICreditBalanceDo Or(conds ...gen.Condition) ICreditBalanceDo Select(conds ...field.Expr) ICreditBalanceDo Where(conds ...gen.Condition) ICreditBalanceDo Order(conds ...field.Expr) ICreditBalanceDo Distinct(cols ...field.Expr) ICreditBalanceDo Omit(cols ...field.Expr) ICreditBalanceDo Join(table schema.Tabler, on ...field.Expr) ICreditBalanceDo LeftJoin(table schema.Tabler, on ...field.Expr) ICreditBalanceDo RightJoin(table schema.Tabler, on ...field.Expr) ICreditBalanceDo Group(cols ...field.Expr) ICreditBalanceDo Having(conds ...gen.Condition) ICreditBalanceDo Limit(limit int) ICreditBalanceDo Offset(offset int) ICreditBalanceDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) ICreditBalanceDo Unscoped() ICreditBalanceDo Create(values ...*model.CreditBalance) error CreateInBatches(values []*model.CreditBalance, batchSize int) error Save(values ...*model.CreditBalance) error First() (*model.CreditBalance, error) Take() (*model.CreditBalance, error) Last() (*model.CreditBalance, error) Find() ([]*model.CreditBalance, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.CreditBalance, err error) FindInBatches(result *[]*model.CreditBalance, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest interface{}) error Delete(...*model.CreditBalance) (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) ICreditBalanceDo Assign(attrs ...field.AssignExpr) ICreditBalanceDo Joins(fields ...field.RelationField) ICreditBalanceDo Preload(fields ...field.RelationField) ICreditBalanceDo FirstOrInit() (*model.CreditBalance, error) FirstOrCreate() (*model.CreditBalance, error) FindByPage(offset int, limit int) (result []*model.CreditBalance, 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) ICreditBalanceDo UnderlyingDB() *gorm.DB schema.Tabler } func (c creditBalanceDo) Debug() ICreditBalanceDo { return c.withDO(c.DO.Debug()) } func (c creditBalanceDo) WithContext(ctx context.Context) ICreditBalanceDo { return c.withDO(c.DO.WithContext(ctx)) } func (c creditBalanceDo) ReadDB() ICreditBalanceDo { return c.Clauses(dbresolver.Read) } func (c creditBalanceDo) WriteDB() ICreditBalanceDo { return c.Clauses(dbresolver.Write) } func (c creditBalanceDo) Session(config *gorm.Session) ICreditBalanceDo { return c.withDO(c.DO.Session(config)) } func (c creditBalanceDo) Clauses(conds ...clause.Expression) ICreditBalanceDo { return c.withDO(c.DO.Clauses(conds...)) } func (c creditBalanceDo) Returning(value interface{}, columns ...string) ICreditBalanceDo { return c.withDO(c.DO.Returning(value, columns...)) } func (c creditBalanceDo) Not(conds ...gen.Condition) ICreditBalanceDo { return c.withDO(c.DO.Not(conds...)) } func (c creditBalanceDo) Or(conds ...gen.Condition) ICreditBalanceDo { return c.withDO(c.DO.Or(conds...)) } func (c creditBalanceDo) Select(conds ...field.Expr) ICreditBalanceDo { return c.withDO(c.DO.Select(conds...)) } func (c creditBalanceDo) Where(conds ...gen.Condition) ICreditBalanceDo { return c.withDO(c.DO.Where(conds...)) } func (c creditBalanceDo) Order(conds ...field.Expr) ICreditBalanceDo { return c.withDO(c.DO.Order(conds...)) } func (c creditBalanceDo) Distinct(cols ...field.Expr) ICreditBalanceDo { return c.withDO(c.DO.Distinct(cols...)) } func (c creditBalanceDo) Omit(cols ...field.Expr) ICreditBalanceDo { return c.withDO(c.DO.Omit(cols...)) } func (c creditBalanceDo) Join(table schema.Tabler, on ...field.Expr) ICreditBalanceDo { return c.withDO(c.DO.Join(table, on...)) } func (c creditBalanceDo) LeftJoin(table schema.Tabler, on ...field.Expr) ICreditBalanceDo { return c.withDO(c.DO.LeftJoin(table, on...)) } func (c creditBalanceDo) RightJoin(table schema.Tabler, on ...field.Expr) ICreditBalanceDo { return c.withDO(c.DO.RightJoin(table, on...)) } func (c creditBalanceDo) Group(cols ...field.Expr) ICreditBalanceDo { return c.withDO(c.DO.Group(cols...)) } func (c creditBalanceDo) Having(conds ...gen.Condition) ICreditBalanceDo { return c.withDO(c.DO.Having(conds...)) } func (c creditBalanceDo) Limit(limit int) ICreditBalanceDo { return c.withDO(c.DO.Limit(limit)) } func (c creditBalanceDo) Offset(offset int) ICreditBalanceDo { return c.withDO(c.DO.Offset(offset)) } func (c creditBalanceDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ICreditBalanceDo { return c.withDO(c.DO.Scopes(funcs...)) } func (c creditBalanceDo) Unscoped() ICreditBalanceDo { return c.withDO(c.DO.Unscoped()) } func (c creditBalanceDo) Create(values ...*model.CreditBalance) error { if len(values) == 0 { return nil } return c.DO.Create(values) } func (c creditBalanceDo) CreateInBatches(values []*model.CreditBalance, batchSize int) error { return c.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 (c creditBalanceDo) Save(values ...*model.CreditBalance) error { if len(values) == 0 { return nil } return c.DO.Save(values) } func (c creditBalanceDo) First() (*model.CreditBalance, error) { if result, err := c.DO.First(); err != nil { return nil, err } else { return result.(*model.CreditBalance), nil } } func (c creditBalanceDo) Take() (*model.CreditBalance, error) { if result, err := c.DO.Take(); err != nil { return nil, err } else { return result.(*model.CreditBalance), nil } } func (c creditBalanceDo) Last() (*model.CreditBalance, error) { if result, err := c.DO.Last(); err != nil { return nil, err } else { return result.(*model.CreditBalance), nil } } func (c creditBalanceDo) Find() ([]*model.CreditBalance, error) { result, err := c.DO.Find() return result.([]*model.CreditBalance), err } func (c creditBalanceDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.CreditBalance, err error) { buf := make([]*model.CreditBalance, 0, batchSize) err = c.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 (c creditBalanceDo) FindInBatches(result *[]*model.CreditBalance, batchSize int, fc func(tx gen.Dao, batch int) error) error { return c.DO.FindInBatches(result, batchSize, fc) } func (c creditBalanceDo) Attrs(attrs ...field.AssignExpr) ICreditBalanceDo { return c.withDO(c.DO.Attrs(attrs...)) } func (c creditBalanceDo) Assign(attrs ...field.AssignExpr) ICreditBalanceDo { return c.withDO(c.DO.Assign(attrs...)) } func (c creditBalanceDo) Joins(fields ...field.RelationField) ICreditBalanceDo { for _, _f := range fields { c = *c.withDO(c.DO.Joins(_f)) } return &c } func (c creditBalanceDo) Preload(fields ...field.RelationField) ICreditBalanceDo { for _, _f := range fields { c = *c.withDO(c.DO.Preload(_f)) } return &c } func (c creditBalanceDo) FirstOrInit() (*model.CreditBalance, error) { if result, err := c.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.CreditBalance), nil } } func (c creditBalanceDo) FirstOrCreate() (*model.CreditBalance, error) { if result, err := c.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.CreditBalance), nil } } func (c creditBalanceDo) FindByPage(offset int, limit int) (result []*model.CreditBalance, count int64, err error) { result, err = c.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 = c.Offset(-1).Limit(-1).Count() return } func (c creditBalanceDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { count, err = c.Count() if err != nil { return } err = c.Offset(offset).Limit(limit).Scan(result) return } func (c creditBalanceDo) Scan(result interface{}) (err error) { return c.DO.Scan(result) } func (c creditBalanceDo) Delete(models ...*model.CreditBalance) (result gen.ResultInfo, err error) { return c.DO.Delete(models) } func (c *creditBalanceDo) withDO(do gen.Dao) *creditBalanceDo { c.DO = *do.(*gen.DO) return c }