// 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 dao import ( "context" "gorm.io/gorm" "gorm.io/gorm/clause" "gorm.io/gorm/schema" "gorm.io/gen" "gorm.io/gen/field" "gorm.io/plugin/dbresolver" "bindbox-game/internal/repository/mysql/model" ) func newChannels(db *gorm.DB, opts ...gen.DOOption) channels { _channels := channels{} _channels.channelsDo.UseDB(db, opts...) _channels.channelsDo.UseModel(&model.Channels{}) tableName := _channels.channelsDo.TableName() _channels.ALL = field.NewAsterisk(tableName) _channels.ID = field.NewInt64(tableName, "id") _channels.Name = field.NewString(tableName, "name") _channels.Code = field.NewString(tableName, "code") _channels.Type = field.NewString(tableName, "type") _channels.Remarks = field.NewString(tableName, "remarks") _channels.CreatedAt = field.NewTime(tableName, "created_at") _channels.UpdatedAt = field.NewTime(tableName, "updated_at") _channels.DeletedAt = field.NewField(tableName, "deleted_at") _channels.fillFieldMap() return _channels } // channels 推广渠道表 type channels struct { channelsDo ALL field.Asterisk ID field.Int64 // 主键ID Name field.String // 渠道名称 Code field.String // 渠道唯一标识 Type field.String // 渠道类型 Remarks field.String // 备注 CreatedAt field.Time // 创建时间 UpdatedAt field.Time // 更新时间 DeletedAt field.Field // 删除时间 fieldMap map[string]field.Expr } func (c channels) Table(newTableName string) *channels { c.channelsDo.UseTable(newTableName) return c.updateTableName(newTableName) } func (c channels) As(alias string) *channels { c.channelsDo.DO = *(c.channelsDo.As(alias).(*gen.DO)) return c.updateTableName(alias) } func (c *channels) updateTableName(table string) *channels { c.ALL = field.NewAsterisk(table) c.ID = field.NewInt64(table, "id") c.Name = field.NewString(table, "name") c.Code = field.NewString(table, "code") c.Type = field.NewString(table, "type") c.Remarks = field.NewString(table, "remarks") c.CreatedAt = field.NewTime(table, "created_at") c.UpdatedAt = field.NewTime(table, "updated_at") c.DeletedAt = field.NewField(table, "deleted_at") c.fillFieldMap() return c } func (c *channels) 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 *channels) fillFieldMap() { c.fieldMap = make(map[string]field.Expr, 8) c.fieldMap["id"] = c.ID c.fieldMap["name"] = c.Name c.fieldMap["code"] = c.Code c.fieldMap["type"] = c.Type c.fieldMap["remarks"] = c.Remarks c.fieldMap["created_at"] = c.CreatedAt c.fieldMap["updated_at"] = c.UpdatedAt c.fieldMap["deleted_at"] = c.DeletedAt } func (c channels) clone(db *gorm.DB) channels { c.channelsDo.ReplaceConnPool(db.Statement.ConnPool) return c } func (c channels) replaceDB(db *gorm.DB) channels { c.channelsDo.ReplaceDB(db) return c } type channelsDo struct{ gen.DO } func (c channelsDo) Debug() *channelsDo { return c.withDO(c.DO.Debug()) } func (c channelsDo) WithContext(ctx context.Context) *channelsDo { return c.withDO(c.DO.WithContext(ctx)) } func (c channelsDo) ReadDB() *channelsDo { return c.Clauses(dbresolver.Read) } func (c channelsDo) WriteDB() *channelsDo { return c.Clauses(dbresolver.Write) } func (c channelsDo) Session(config *gorm.Session) *channelsDo { return c.withDO(c.DO.Session(config)) } func (c channelsDo) Clauses(conds ...clause.Expression) *channelsDo { return c.withDO(c.DO.Clauses(conds...)) } func (c channelsDo) Returning(value interface{}, columns ...string) *channelsDo { return c.withDO(c.DO.Returning(value, columns...)) } func (c channelsDo) Not(conds ...gen.Condition) *channelsDo { return c.withDO(c.DO.Not(conds...)) } func (c channelsDo) Or(conds ...gen.Condition) *channelsDo { return c.withDO(c.DO.Or(conds...)) } func (c channelsDo) Select(conds ...field.Expr) *channelsDo { return c.withDO(c.DO.Select(conds...)) } func (c channelsDo) Where(conds ...gen.Condition) *channelsDo { return c.withDO(c.DO.Where(conds...)) } func (c channelsDo) Order(conds ...field.Expr) *channelsDo { return c.withDO(c.DO.Order(conds...)) } func (c channelsDo) Distinct(cols ...field.Expr) *channelsDo { return c.withDO(c.DO.Distinct(cols...)) } func (c channelsDo) Omit(cols ...field.Expr) *channelsDo { return c.withDO(c.DO.Omit(cols...)) } func (c channelsDo) Join(table schema.Tabler, on ...field.Expr) *channelsDo { return c.withDO(c.DO.Join(table, on...)) } func (c channelsDo) LeftJoin(table schema.Tabler, on ...field.Expr) *channelsDo { return c.withDO(c.DO.LeftJoin(table, on...)) } func (c channelsDo) RightJoin(table schema.Tabler, on ...field.Expr) *channelsDo { return c.withDO(c.DO.RightJoin(table, on...)) } func (c channelsDo) Group(cols ...field.Expr) *channelsDo { return c.withDO(c.DO.Group(cols...)) } func (c channelsDo) Having(conds ...gen.Condition) *channelsDo { return c.withDO(c.DO.Having(conds...)) } func (c channelsDo) Limit(limit int) *channelsDo { return c.withDO(c.DO.Limit(limit)) } func (c channelsDo) Offset(offset int) *channelsDo { return c.withDO(c.DO.Offset(offset)) } func (c channelsDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *channelsDo { return c.withDO(c.DO.Scopes(funcs...)) } func (c channelsDo) Unscoped() *channelsDo { return c.withDO(c.DO.Unscoped()) } func (c channelsDo) Create(values ...*model.Channels) error { if len(values) == 0 { return nil } return c.DO.Create(values) } func (c channelsDo) CreateInBatches(values []*model.Channels, 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 channelsDo) Save(values ...*model.Channels) error { if len(values) == 0 { return nil } return c.DO.Save(values) } func (c channelsDo) First() (*model.Channels, error) { if result, err := c.DO.First(); err != nil { return nil, err } else { return result.(*model.Channels), nil } } func (c channelsDo) Take() (*model.Channels, error) { if result, err := c.DO.Take(); err != nil { return nil, err } else { return result.(*model.Channels), nil } } func (c channelsDo) Last() (*model.Channels, error) { if result, err := c.DO.Last(); err != nil { return nil, err } else { return result.(*model.Channels), nil } } func (c channelsDo) Find() ([]*model.Channels, error) { result, err := c.DO.Find() return result.([]*model.Channels), err } func (c channelsDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Channels, err error) { buf := make([]*model.Channels, 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 channelsDo) FindInBatches(result *[]*model.Channels, batchSize int, fc func(tx gen.Dao, batch int) error) error { return c.DO.FindInBatches(result, batchSize, fc) } func (c channelsDo) Attrs(attrs ...field.AssignExpr) *channelsDo { return c.withDO(c.DO.Attrs(attrs...)) } func (c channelsDo) Assign(attrs ...field.AssignExpr) *channelsDo { return c.withDO(c.DO.Assign(attrs...)) } func (c channelsDo) Joins(fields ...field.RelationField) *channelsDo { for _, _f := range fields { c = *c.withDO(c.DO.Joins(_f)) } return &c } func (c channelsDo) Preload(fields ...field.RelationField) *channelsDo { for _, _f := range fields { c = *c.withDO(c.DO.Preload(_f)) } return &c } func (c channelsDo) FirstOrInit() (*model.Channels, error) { if result, err := c.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.Channels), nil } } func (c channelsDo) FirstOrCreate() (*model.Channels, error) { if result, err := c.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.Channels), nil } } func (c channelsDo) FindByPage(offset int, limit int) (result []*model.Channels, 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 channelsDo) 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 channelsDo) Scan(result interface{}) (err error) { return c.DO.Scan(result) } func (c channelsDo) Delete(models ...*model.Channels) (result gen.ResultInfo, err error) { return c.DO.Delete(models) } func (c *channelsDo) withDO(do gen.Dao) *channelsDo { c.DO = *do.(*gen.DO) return c }