|
- // 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 gen
-
- import (
- "context"
-
- "gorm.io/gorm"
- "gorm.io/gorm/clause"
- "gorm.io/gorm/schema"
-
- "gorm.io/gen"
- "gorm.io/gen/field"
-
- "gorm.io/plugin/dbresolver"
-
- systemroles "github.com/OpenIMSDK/OpenKF/server/internal/models/system_roles"
- )
-
- func newSysBot(db *gorm.DB, opts ...gen.DOOption) sysBot {
- _sysBot := sysBot{}
-
- _sysBot.sysBotDo.UseDB(db, opts...)
- _sysBot.sysBotDo.UseModel(&systemroles.SysBot{})
-
- tableName := _sysBot.sysBotDo.TableName()
- _sysBot.ALL = field.NewAsterisk(tableName)
- _sysBot.Id = field.NewUint(tableName, "id")
- _sysBot.CreatedAt = field.NewTime(tableName, "created_at")
- _sysBot.UpdatedAt = field.NewTime(tableName, "updated_at")
- _sysBot.DeletedAt = field.NewTime(tableName, "deleted_at")
- _sysBot.BotAddr = field.NewString(tableName, "bot_addr")
- _sysBot.BotPort = field.NewInt(tableName, "bot_port")
- _sysBot.BotToken = field.NewString(tableName, "bot_token")
- _sysBot.Nickname = field.NewString(tableName, "nickname")
- _sysBot.Avatar = field.NewString(tableName, "avatar")
- _sysBot.CommunityId = field.NewUint(tableName, "community_id")
- _sysBot.Community = sysBotBelongsToCommunity{
- db: db.Session(&gorm.Session{}),
-
- RelationField: field.NewRelation("Community", "systemroles.SysCommunity"),
- }
-
- _sysBot.fillFieldMap()
-
- return _sysBot
- }
-
- type sysBot struct {
- sysBotDo sysBotDo
-
- ALL field.Asterisk
- Id field.Uint
- CreatedAt field.Time
- UpdatedAt field.Time
- DeletedAt field.Time
- BotAddr field.String
- BotPort field.Int
- BotToken field.String
- Nickname field.String
- Avatar field.String
- CommunityId field.Uint
- Community sysBotBelongsToCommunity
-
- fieldMap map[string]field.Expr
- }
-
- func (s sysBot) Table(newTableName string) *sysBot {
- s.sysBotDo.UseTable(newTableName)
- return s.updateTableName(newTableName)
- }
-
- func (s sysBot) As(alias string) *sysBot {
- s.sysBotDo.DO = *(s.sysBotDo.As(alias).(*gen.DO))
- return s.updateTableName(alias)
- }
-
- func (s *sysBot) updateTableName(table string) *sysBot {
- s.ALL = field.NewAsterisk(table)
- s.Id = field.NewUint(table, "id")
- s.CreatedAt = field.NewTime(table, "created_at")
- s.UpdatedAt = field.NewTime(table, "updated_at")
- s.DeletedAt = field.NewTime(table, "deleted_at")
- s.BotAddr = field.NewString(table, "bot_addr")
- s.BotPort = field.NewInt(table, "bot_port")
- s.BotToken = field.NewString(table, "bot_token")
- s.Nickname = field.NewString(table, "nickname")
- s.Avatar = field.NewString(table, "avatar")
- s.CommunityId = field.NewUint(table, "community_id")
-
- s.fillFieldMap()
-
- return s
- }
-
- func (s *sysBot) WithContext(ctx context.Context) ISysBotDo { return s.sysBotDo.WithContext(ctx) }
-
- func (s sysBot) TableName() string { return s.sysBotDo.TableName() }
-
- func (s sysBot) Alias() string { return s.sysBotDo.Alias() }
-
- func (s *sysBot) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := s.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
- }
-
- func (s *sysBot) fillFieldMap() {
- s.fieldMap = make(map[string]field.Expr, 11)
- s.fieldMap["id"] = s.Id
- s.fieldMap["created_at"] = s.CreatedAt
- s.fieldMap["updated_at"] = s.UpdatedAt
- s.fieldMap["deleted_at"] = s.DeletedAt
- s.fieldMap["bot_addr"] = s.BotAddr
- s.fieldMap["bot_port"] = s.BotPort
- s.fieldMap["bot_token"] = s.BotToken
- s.fieldMap["nickname"] = s.Nickname
- s.fieldMap["avatar"] = s.Avatar
- s.fieldMap["community_id"] = s.CommunityId
-
- }
-
- func (s sysBot) clone(db *gorm.DB) sysBot {
- s.sysBotDo.ReplaceConnPool(db.Statement.ConnPool)
- return s
- }
-
- func (s sysBot) replaceDB(db *gorm.DB) sysBot {
- s.sysBotDo.ReplaceDB(db)
- return s
- }
-
- type sysBotBelongsToCommunity struct {
- db *gorm.DB
-
- field.RelationField
- }
-
- func (a sysBotBelongsToCommunity) Where(conds ...field.Expr) *sysBotBelongsToCommunity {
- if len(conds) == 0 {
- return &a
- }
-
- exprs := make([]clause.Expression, 0, len(conds))
- for _, cond := range conds {
- exprs = append(exprs, cond.BeCond().(clause.Expression))
- }
- a.db = a.db.Clauses(clause.Where{Exprs: exprs})
- return &a
- }
-
- func (a sysBotBelongsToCommunity) WithContext(ctx context.Context) *sysBotBelongsToCommunity {
- a.db = a.db.WithContext(ctx)
- return &a
- }
-
- func (a sysBotBelongsToCommunity) Session(session *gorm.Session) *sysBotBelongsToCommunity {
- a.db = a.db.Session(session)
- return &a
- }
-
- func (a sysBotBelongsToCommunity) Model(m *systemroles.SysBot) *sysBotBelongsToCommunityTx {
- return &sysBotBelongsToCommunityTx{a.db.Model(m).Association(a.Name())}
- }
-
- type sysBotBelongsToCommunityTx struct{ tx *gorm.Association }
-
- func (a sysBotBelongsToCommunityTx) Find() (result *systemroles.SysCommunity, err error) {
- return result, a.tx.Find(&result)
- }
-
- func (a sysBotBelongsToCommunityTx) Append(values ...*systemroles.SysCommunity) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Append(targetValues...)
- }
-
- func (a sysBotBelongsToCommunityTx) Replace(values ...*systemroles.SysCommunity) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Replace(targetValues...)
- }
-
- func (a sysBotBelongsToCommunityTx) Delete(values ...*systemroles.SysCommunity) (err error) {
- targetValues := make([]interface{}, len(values))
- for i, v := range values {
- targetValues[i] = v
- }
- return a.tx.Delete(targetValues...)
- }
-
- func (a sysBotBelongsToCommunityTx) Clear() error {
- return a.tx.Clear()
- }
-
- func (a sysBotBelongsToCommunityTx) Count() int64 {
- return a.tx.Count()
- }
-
- type sysBotDo struct{ gen.DO }
-
- type ISysBotDo interface {
- gen.SubQuery
- Debug() ISysBotDo
- WithContext(ctx context.Context) ISysBotDo
- WithResult(fc func(tx gen.Dao)) gen.ResultInfo
- ReplaceDB(db *gorm.DB)
- ReadDB() ISysBotDo
- WriteDB() ISysBotDo
- As(alias string) gen.Dao
- Session(config *gorm.Session) ISysBotDo
- Columns(cols ...field.Expr) gen.Columns
- Clauses(conds ...clause.Expression) ISysBotDo
- Not(conds ...gen.Condition) ISysBotDo
- Or(conds ...gen.Condition) ISysBotDo
- Select(conds ...field.Expr) ISysBotDo
- Where(conds ...gen.Condition) ISysBotDo
- Order(conds ...field.Expr) ISysBotDo
- Distinct(cols ...field.Expr) ISysBotDo
- Omit(cols ...field.Expr) ISysBotDo
- Join(table schema.Tabler, on ...field.Expr) ISysBotDo
- LeftJoin(table schema.Tabler, on ...field.Expr) ISysBotDo
- RightJoin(table schema.Tabler, on ...field.Expr) ISysBotDo
- Group(cols ...field.Expr) ISysBotDo
- Having(conds ...gen.Condition) ISysBotDo
- Limit(limit int) ISysBotDo
- Offset(offset int) ISysBotDo
- Count() (count int64, err error)
- Scopes(funcs ...func(gen.Dao) gen.Dao) ISysBotDo
- Unscoped() ISysBotDo
- Create(values ...*systemroles.SysBot) error
- CreateInBatches(values []*systemroles.SysBot, batchSize int) error
- Save(values ...*systemroles.SysBot) error
- First() (*systemroles.SysBot, error)
- Take() (*systemroles.SysBot, error)
- Last() (*systemroles.SysBot, error)
- Find() ([]*systemroles.SysBot, error)
- FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*systemroles.SysBot, err error)
- FindInBatches(result *[]*systemroles.SysBot, batchSize int, fc func(tx gen.Dao, batch int) error) error
- Pluck(column field.Expr, dest interface{}) error
- Delete(...*systemroles.SysBot) (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) ISysBotDo
- Assign(attrs ...field.AssignExpr) ISysBotDo
- Joins(fields ...field.RelationField) ISysBotDo
- Preload(fields ...field.RelationField) ISysBotDo
- FirstOrInit() (*systemroles.SysBot, error)
- FirstOrCreate() (*systemroles.SysBot, error)
- FindByPage(offset int, limit int) (result []*systemroles.SysBot, 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) ISysBotDo
- UnderlyingDB() *gorm.DB
- schema.Tabler
- }
-
- func (s sysBotDo) Debug() ISysBotDo {
- return s.withDO(s.DO.Debug())
- }
-
- func (s sysBotDo) WithContext(ctx context.Context) ISysBotDo {
- return s.withDO(s.DO.WithContext(ctx))
- }
-
- func (s sysBotDo) ReadDB() ISysBotDo {
- return s.Clauses(dbresolver.Read)
- }
-
- func (s sysBotDo) WriteDB() ISysBotDo {
- return s.Clauses(dbresolver.Write)
- }
-
- func (s sysBotDo) Session(config *gorm.Session) ISysBotDo {
- return s.withDO(s.DO.Session(config))
- }
-
- func (s sysBotDo) Clauses(conds ...clause.Expression) ISysBotDo {
- return s.withDO(s.DO.Clauses(conds...))
- }
-
- func (s sysBotDo) Returning(value interface{}, columns ...string) ISysBotDo {
- return s.withDO(s.DO.Returning(value, columns...))
- }
-
- func (s sysBotDo) Not(conds ...gen.Condition) ISysBotDo {
- return s.withDO(s.DO.Not(conds...))
- }
-
- func (s sysBotDo) Or(conds ...gen.Condition) ISysBotDo {
- return s.withDO(s.DO.Or(conds...))
- }
-
- func (s sysBotDo) Select(conds ...field.Expr) ISysBotDo {
- return s.withDO(s.DO.Select(conds...))
- }
-
- func (s sysBotDo) Where(conds ...gen.Condition) ISysBotDo {
- return s.withDO(s.DO.Where(conds...))
- }
-
- func (s sysBotDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) ISysBotDo {
- return s.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
- }
-
- func (s sysBotDo) Order(conds ...field.Expr) ISysBotDo {
- return s.withDO(s.DO.Order(conds...))
- }
-
- func (s sysBotDo) Distinct(cols ...field.Expr) ISysBotDo {
- return s.withDO(s.DO.Distinct(cols...))
- }
-
- func (s sysBotDo) Omit(cols ...field.Expr) ISysBotDo {
- return s.withDO(s.DO.Omit(cols...))
- }
-
- func (s sysBotDo) Join(table schema.Tabler, on ...field.Expr) ISysBotDo {
- return s.withDO(s.DO.Join(table, on...))
- }
-
- func (s sysBotDo) LeftJoin(table schema.Tabler, on ...field.Expr) ISysBotDo {
- return s.withDO(s.DO.LeftJoin(table, on...))
- }
-
- func (s sysBotDo) RightJoin(table schema.Tabler, on ...field.Expr) ISysBotDo {
- return s.withDO(s.DO.RightJoin(table, on...))
- }
-
- func (s sysBotDo) Group(cols ...field.Expr) ISysBotDo {
- return s.withDO(s.DO.Group(cols...))
- }
-
- func (s sysBotDo) Having(conds ...gen.Condition) ISysBotDo {
- return s.withDO(s.DO.Having(conds...))
- }
-
- func (s sysBotDo) Limit(limit int) ISysBotDo {
- return s.withDO(s.DO.Limit(limit))
- }
-
- func (s sysBotDo) Offset(offset int) ISysBotDo {
- return s.withDO(s.DO.Offset(offset))
- }
-
- func (s sysBotDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ISysBotDo {
- return s.withDO(s.DO.Scopes(funcs...))
- }
-
- func (s sysBotDo) Unscoped() ISysBotDo {
- return s.withDO(s.DO.Unscoped())
- }
-
- func (s sysBotDo) Create(values ...*systemroles.SysBot) error {
- if len(values) == 0 {
- return nil
- }
- return s.DO.Create(values)
- }
-
- func (s sysBotDo) CreateInBatches(values []*systemroles.SysBot, batchSize int) error {
- return s.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 (s sysBotDo) Save(values ...*systemroles.SysBot) error {
- if len(values) == 0 {
- return nil
- }
- return s.DO.Save(values)
- }
-
- func (s sysBotDo) First() (*systemroles.SysBot, error) {
- if result, err := s.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*systemroles.SysBot), nil
- }
- }
-
- func (s sysBotDo) Take() (*systemroles.SysBot, error) {
- if result, err := s.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*systemroles.SysBot), nil
- }
- }
-
- func (s sysBotDo) Last() (*systemroles.SysBot, error) {
- if result, err := s.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*systemroles.SysBot), nil
- }
- }
-
- func (s sysBotDo) Find() ([]*systemroles.SysBot, error) {
- result, err := s.DO.Find()
- return result.([]*systemroles.SysBot), err
- }
-
- func (s sysBotDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*systemroles.SysBot, err error) {
- buf := make([]*systemroles.SysBot, 0, batchSize)
- err = s.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 (s sysBotDo) FindInBatches(result *[]*systemroles.SysBot, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return s.DO.FindInBatches(result, batchSize, fc)
- }
-
- func (s sysBotDo) Attrs(attrs ...field.AssignExpr) ISysBotDo {
- return s.withDO(s.DO.Attrs(attrs...))
- }
-
- func (s sysBotDo) Assign(attrs ...field.AssignExpr) ISysBotDo {
- return s.withDO(s.DO.Assign(attrs...))
- }
-
- func (s sysBotDo) Joins(fields ...field.RelationField) ISysBotDo {
- for _, _f := range fields {
- s = *s.withDO(s.DO.Joins(_f))
- }
- return &s
- }
-
- func (s sysBotDo) Preload(fields ...field.RelationField) ISysBotDo {
- for _, _f := range fields {
- s = *s.withDO(s.DO.Preload(_f))
- }
- return &s
- }
-
- func (s sysBotDo) FirstOrInit() (*systemroles.SysBot, error) {
- if result, err := s.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*systemroles.SysBot), nil
- }
- }
-
- func (s sysBotDo) FirstOrCreate() (*systemroles.SysBot, error) {
- if result, err := s.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*systemroles.SysBot), nil
- }
- }
-
- func (s sysBotDo) FindByPage(offset int, limit int) (result []*systemroles.SysBot, count int64, err error) {
- result, err = s.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 = s.Offset(-1).Limit(-1).Count()
- return
- }
-
- func (s sysBotDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = s.Count()
- if err != nil {
- return
- }
-
- err = s.Offset(offset).Limit(limit).Scan(result)
- return
- }
-
- func (s sysBotDo) Scan(result interface{}) (err error) {
- return s.DO.Scan(result)
- }
-
- func (s sysBotDo) Delete(models ...*systemroles.SysBot) (result gen.ResultInfo, err error) {
- return s.DO.Delete(models)
- }
-
- func (s *sysBotDo) withDO(do gen.Dao) *sysBotDo {
- s.DO = *do.(*gen.DO)
- return s
- }
|