// 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 newUsageStatisticMonth(db *gorm.DB, opts ...gen.DOOption) usageStatisticMonth { _usageStatisticMonth := usageStatisticMonth{} _usageStatisticMonth.usageStatisticMonthDo.UseDB(db, opts...) _usageStatisticMonth.usageStatisticMonthDo.UseModel(&model.UsageStatisticMonth{}) tableName := _usageStatisticMonth.usageStatisticMonthDo.TableName() _usageStatisticMonth.ALL = field.NewAsterisk(tableName) _usageStatisticMonth.ID = field.NewInt64(tableName, "id") _usageStatisticMonth.CreatedAt = field.NewTime(tableName, "created_at") _usageStatisticMonth.UpdatedAt = field.NewTime(tableName, "updated_at") _usageStatisticMonth.Status = field.NewInt64(tableName, "status") _usageStatisticMonth.DeletedAt = field.NewField(tableName, "deleted_at") _usageStatisticMonth.Addtime = field.NewInt64(tableName, "addtime") _usageStatisticMonth.Type = field.NewInt64(tableName, "type") _usageStatisticMonth.BotID = field.NewString(tableName, "bot_id") _usageStatisticMonth.OrganizationID = field.NewInt64(tableName, "organization_id") _usageStatisticMonth.AiResponse = field.NewInt64(tableName, "ai_response") _usageStatisticMonth.SopRun = field.NewInt64(tableName, "sop_run") _usageStatisticMonth.TotalFriend = field.NewInt64(tableName, "total_friend") _usageStatisticMonth.TotalGroup = field.NewInt64(tableName, "total_group") _usageStatisticMonth.AccountBalance = field.NewInt64(tableName, "account_balance") _usageStatisticMonth.ConsumeToken = field.NewInt64(tableName, "consume_token") _usageStatisticMonth.ActiveUser = field.NewInt64(tableName, "active_user") _usageStatisticMonth.NewUser = field.NewInt64(tableName, "new_user") _usageStatisticMonth.LabelDist = field.NewString(tableName, "label_dist") _usageStatisticMonth.fillFieldMap() return _usageStatisticMonth } type usageStatisticMonth struct { usageStatisticMonthDo 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 | 删除日期 Addtime field.Int64 // 写入年月 Type field.Int64 // 1-微信 2-名片 BotID field.String // 微信或名片id OrganizationID field.Int64 // 机构 ID AiResponse field.Int64 // AI回复次数 SopRun field.Int64 // SOP运行次数 TotalFriend field.Int64 // 好友总数 TotalGroup field.Int64 // 群总数 AccountBalance field.Int64 // 账户余额(单位:分) ConsumeToken field.Int64 // 消耗token数 ActiveUser field.Int64 // 活跃用户数 NewUser field.Int64 // 新增用户数 LabelDist field.String // 标签分布 fieldMap map[string]field.Expr } func (u usageStatisticMonth) Table(newTableName string) *usageStatisticMonth { u.usageStatisticMonthDo.UseTable(newTableName) return u.updateTableName(newTableName) } func (u usageStatisticMonth) As(alias string) *usageStatisticMonth { u.usageStatisticMonthDo.DO = *(u.usageStatisticMonthDo.As(alias).(*gen.DO)) return u.updateTableName(alias) } func (u *usageStatisticMonth) updateTableName(table string) *usageStatisticMonth { u.ALL = field.NewAsterisk(table) u.ID = field.NewInt64(table, "id") u.CreatedAt = field.NewTime(table, "created_at") u.UpdatedAt = field.NewTime(table, "updated_at") u.Status = field.NewInt64(table, "status") u.DeletedAt = field.NewField(table, "deleted_at") u.Addtime = field.NewInt64(table, "addtime") u.Type = field.NewInt64(table, "type") u.BotID = field.NewString(table, "bot_id") u.OrganizationID = field.NewInt64(table, "organization_id") u.AiResponse = field.NewInt64(table, "ai_response") u.SopRun = field.NewInt64(table, "sop_run") u.TotalFriend = field.NewInt64(table, "total_friend") u.TotalGroup = field.NewInt64(table, "total_group") u.AccountBalance = field.NewInt64(table, "account_balance") u.ConsumeToken = field.NewInt64(table, "consume_token") u.ActiveUser = field.NewInt64(table, "active_user") u.NewUser = field.NewInt64(table, "new_user") u.LabelDist = field.NewString(table, "label_dist") u.fillFieldMap() return u } func (u *usageStatisticMonth) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := u.fieldMap[fieldName] if !ok || _f == nil { return nil, false } _oe, ok := _f.(field.OrderExpr) return _oe, ok } func (u *usageStatisticMonth) fillFieldMap() { u.fieldMap = make(map[string]field.Expr, 18) u.fieldMap["id"] = u.ID u.fieldMap["created_at"] = u.CreatedAt u.fieldMap["updated_at"] = u.UpdatedAt u.fieldMap["status"] = u.Status u.fieldMap["deleted_at"] = u.DeletedAt u.fieldMap["addtime"] = u.Addtime u.fieldMap["type"] = u.Type u.fieldMap["bot_id"] = u.BotID u.fieldMap["organization_id"] = u.OrganizationID u.fieldMap["ai_response"] = u.AiResponse u.fieldMap["sop_run"] = u.SopRun u.fieldMap["total_friend"] = u.TotalFriend u.fieldMap["total_group"] = u.TotalGroup u.fieldMap["account_balance"] = u.AccountBalance u.fieldMap["consume_token"] = u.ConsumeToken u.fieldMap["active_user"] = u.ActiveUser u.fieldMap["new_user"] = u.NewUser u.fieldMap["label_dist"] = u.LabelDist } func (u usageStatisticMonth) clone(db *gorm.DB) usageStatisticMonth { u.usageStatisticMonthDo.ReplaceConnPool(db.Statement.ConnPool) return u } func (u usageStatisticMonth) replaceDB(db *gorm.DB) usageStatisticMonth { u.usageStatisticMonthDo.ReplaceDB(db) return u } type usageStatisticMonthDo struct{ gen.DO } type IUsageStatisticMonthDo interface { gen.SubQuery Debug() IUsageStatisticMonthDo WithContext(ctx context.Context) IUsageStatisticMonthDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() IUsageStatisticMonthDo WriteDB() IUsageStatisticMonthDo As(alias string) gen.Dao Session(config *gorm.Session) IUsageStatisticMonthDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) IUsageStatisticMonthDo Not(conds ...gen.Condition) IUsageStatisticMonthDo Or(conds ...gen.Condition) IUsageStatisticMonthDo Select(conds ...field.Expr) IUsageStatisticMonthDo Where(conds ...gen.Condition) IUsageStatisticMonthDo Order(conds ...field.Expr) IUsageStatisticMonthDo Distinct(cols ...field.Expr) IUsageStatisticMonthDo Omit(cols ...field.Expr) IUsageStatisticMonthDo Join(table schema.Tabler, on ...field.Expr) IUsageStatisticMonthDo LeftJoin(table schema.Tabler, on ...field.Expr) IUsageStatisticMonthDo RightJoin(table schema.Tabler, on ...field.Expr) IUsageStatisticMonthDo Group(cols ...field.Expr) IUsageStatisticMonthDo Having(conds ...gen.Condition) IUsageStatisticMonthDo Limit(limit int) IUsageStatisticMonthDo Offset(offset int) IUsageStatisticMonthDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) IUsageStatisticMonthDo Unscoped() IUsageStatisticMonthDo Create(values ...*model.UsageStatisticMonth) error CreateInBatches(values []*model.UsageStatisticMonth, batchSize int) error Save(values ...*model.UsageStatisticMonth) error First() (*model.UsageStatisticMonth, error) Take() (*model.UsageStatisticMonth, error) Last() (*model.UsageStatisticMonth, error) Find() ([]*model.UsageStatisticMonth, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.UsageStatisticMonth, err error) FindInBatches(result *[]*model.UsageStatisticMonth, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest interface{}) error Delete(...*model.UsageStatisticMonth) (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) IUsageStatisticMonthDo Assign(attrs ...field.AssignExpr) IUsageStatisticMonthDo Joins(fields ...field.RelationField) IUsageStatisticMonthDo Preload(fields ...field.RelationField) IUsageStatisticMonthDo FirstOrInit() (*model.UsageStatisticMonth, error) FirstOrCreate() (*model.UsageStatisticMonth, error) FindByPage(offset int, limit int) (result []*model.UsageStatisticMonth, 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) IUsageStatisticMonthDo UnderlyingDB() *gorm.DB schema.Tabler } func (u usageStatisticMonthDo) Debug() IUsageStatisticMonthDo { return u.withDO(u.DO.Debug()) } func (u usageStatisticMonthDo) WithContext(ctx context.Context) IUsageStatisticMonthDo { return u.withDO(u.DO.WithContext(ctx)) } func (u usageStatisticMonthDo) ReadDB() IUsageStatisticMonthDo { return u.Clauses(dbresolver.Read) } func (u usageStatisticMonthDo) WriteDB() IUsageStatisticMonthDo { return u.Clauses(dbresolver.Write) } func (u usageStatisticMonthDo) Session(config *gorm.Session) IUsageStatisticMonthDo { return u.withDO(u.DO.Session(config)) } func (u usageStatisticMonthDo) Clauses(conds ...clause.Expression) IUsageStatisticMonthDo { return u.withDO(u.DO.Clauses(conds...)) } func (u usageStatisticMonthDo) Returning(value interface{}, columns ...string) IUsageStatisticMonthDo { return u.withDO(u.DO.Returning(value, columns...)) } func (u usageStatisticMonthDo) Not(conds ...gen.Condition) IUsageStatisticMonthDo { return u.withDO(u.DO.Not(conds...)) } func (u usageStatisticMonthDo) Or(conds ...gen.Condition) IUsageStatisticMonthDo { return u.withDO(u.DO.Or(conds...)) } func (u usageStatisticMonthDo) Select(conds ...field.Expr) IUsageStatisticMonthDo { return u.withDO(u.DO.Select(conds...)) } func (u usageStatisticMonthDo) Where(conds ...gen.Condition) IUsageStatisticMonthDo { return u.withDO(u.DO.Where(conds...)) } func (u usageStatisticMonthDo) Order(conds ...field.Expr) IUsageStatisticMonthDo { return u.withDO(u.DO.Order(conds...)) } func (u usageStatisticMonthDo) Distinct(cols ...field.Expr) IUsageStatisticMonthDo { return u.withDO(u.DO.Distinct(cols...)) } func (u usageStatisticMonthDo) Omit(cols ...field.Expr) IUsageStatisticMonthDo { return u.withDO(u.DO.Omit(cols...)) } func (u usageStatisticMonthDo) Join(table schema.Tabler, on ...field.Expr) IUsageStatisticMonthDo { return u.withDO(u.DO.Join(table, on...)) } func (u usageStatisticMonthDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUsageStatisticMonthDo { return u.withDO(u.DO.LeftJoin(table, on...)) } func (u usageStatisticMonthDo) RightJoin(table schema.Tabler, on ...field.Expr) IUsageStatisticMonthDo { return u.withDO(u.DO.RightJoin(table, on...)) } func (u usageStatisticMonthDo) Group(cols ...field.Expr) IUsageStatisticMonthDo { return u.withDO(u.DO.Group(cols...)) } func (u usageStatisticMonthDo) Having(conds ...gen.Condition) IUsageStatisticMonthDo { return u.withDO(u.DO.Having(conds...)) } func (u usageStatisticMonthDo) Limit(limit int) IUsageStatisticMonthDo { return u.withDO(u.DO.Limit(limit)) } func (u usageStatisticMonthDo) Offset(offset int) IUsageStatisticMonthDo { return u.withDO(u.DO.Offset(offset)) } func (u usageStatisticMonthDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUsageStatisticMonthDo { return u.withDO(u.DO.Scopes(funcs...)) } func (u usageStatisticMonthDo) Unscoped() IUsageStatisticMonthDo { return u.withDO(u.DO.Unscoped()) } func (u usageStatisticMonthDo) Create(values ...*model.UsageStatisticMonth) error { if len(values) == 0 { return nil } return u.DO.Create(values) } func (u usageStatisticMonthDo) CreateInBatches(values []*model.UsageStatisticMonth, batchSize int) error { return u.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 (u usageStatisticMonthDo) Save(values ...*model.UsageStatisticMonth) error { if len(values) == 0 { return nil } return u.DO.Save(values) } func (u usageStatisticMonthDo) First() (*model.UsageStatisticMonth, error) { if result, err := u.DO.First(); err != nil { return nil, err } else { return result.(*model.UsageStatisticMonth), nil } } func (u usageStatisticMonthDo) Take() (*model.UsageStatisticMonth, error) { if result, err := u.DO.Take(); err != nil { return nil, err } else { return result.(*model.UsageStatisticMonth), nil } } func (u usageStatisticMonthDo) Last() (*model.UsageStatisticMonth, error) { if result, err := u.DO.Last(); err != nil { return nil, err } else { return result.(*model.UsageStatisticMonth), nil } } func (u usageStatisticMonthDo) Find() ([]*model.UsageStatisticMonth, error) { result, err := u.DO.Find() return result.([]*model.UsageStatisticMonth), err } func (u usageStatisticMonthDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.UsageStatisticMonth, err error) { buf := make([]*model.UsageStatisticMonth, 0, batchSize) err = u.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 (u usageStatisticMonthDo) FindInBatches(result *[]*model.UsageStatisticMonth, batchSize int, fc func(tx gen.Dao, batch int) error) error { return u.DO.FindInBatches(result, batchSize, fc) } func (u usageStatisticMonthDo) Attrs(attrs ...field.AssignExpr) IUsageStatisticMonthDo { return u.withDO(u.DO.Attrs(attrs...)) } func (u usageStatisticMonthDo) Assign(attrs ...field.AssignExpr) IUsageStatisticMonthDo { return u.withDO(u.DO.Assign(attrs...)) } func (u usageStatisticMonthDo) Joins(fields ...field.RelationField) IUsageStatisticMonthDo { for _, _f := range fields { u = *u.withDO(u.DO.Joins(_f)) } return &u } func (u usageStatisticMonthDo) Preload(fields ...field.RelationField) IUsageStatisticMonthDo { for _, _f := range fields { u = *u.withDO(u.DO.Preload(_f)) } return &u } func (u usageStatisticMonthDo) FirstOrInit() (*model.UsageStatisticMonth, error) { if result, err := u.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.UsageStatisticMonth), nil } } func (u usageStatisticMonthDo) FirstOrCreate() (*model.UsageStatisticMonth, error) { if result, err := u.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.UsageStatisticMonth), nil } } func (u usageStatisticMonthDo) FindByPage(offset int, limit int) (result []*model.UsageStatisticMonth, count int64, err error) { result, err = u.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 = u.Offset(-1).Limit(-1).Count() return } func (u usageStatisticMonthDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { count, err = u.Count() if err != nil { return } err = u.Offset(offset).Limit(limit).Scan(result) return } func (u usageStatisticMonthDo) Scan(result interface{}) (err error) { return u.DO.Scan(result) } func (u usageStatisticMonthDo) Delete(models ...*model.UsageStatisticMonth) (result gen.ResultInfo, err error) { return u.DO.Delete(models) } func (u *usageStatisticMonthDo) withDO(do gen.Dao) *usageStatisticMonthDo { u.DO = *do.(*gen.DO) return u }