123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 |
- // 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
- }
|