// 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" "database/sql" "gorm.io/gorm" "gorm.io/gorm/clause" "gorm.io/gorm/schema" "gorm.io/gen" "gorm.io/gen/field" "gorm.io/plugin/dbresolver" "kra/internal/data/model" ) func newSysAuthority(db *gorm.DB, opts ...gen.DOOption) sysAuthority { _sysAuthority := sysAuthority{} _sysAuthority.sysAuthorityDo.UseDB(db, opts...) _sysAuthority.sysAuthorityDo.UseModel(&model.SysAuthority{}) tableName := _sysAuthority.sysAuthorityDo.TableName() _sysAuthority.ALL = field.NewAsterisk(tableName) _sysAuthority.CreatedAt = field.NewTime(tableName, "created_at") _sysAuthority.UpdatedAt = field.NewTime(tableName, "updated_at") _sysAuthority.DeletedAt = field.NewField(tableName, "deleted_at") _sysAuthority.AuthorityID = field.NewInt64(tableName, "authority_id") _sysAuthority.AuthorityName = field.NewString(tableName, "authority_name") _sysAuthority.ParentID = field.NewInt64(tableName, "parent_id") _sysAuthority.DefaultRouter = field.NewString(tableName, "default_router") _sysAuthority.fillFieldMap() return _sysAuthority } type sysAuthority struct { sysAuthorityDo sysAuthorityDo ALL field.Asterisk CreatedAt field.Time UpdatedAt field.Time DeletedAt field.Field AuthorityID field.Int64 // 角色ID AuthorityName field.String // 角色名 ParentID field.Int64 // 父角色ID DefaultRouter field.String // 默认菜单 fieldMap map[string]field.Expr } func (s sysAuthority) Table(newTableName string) *sysAuthority { s.sysAuthorityDo.UseTable(newTableName) return s.updateTableName(newTableName) } func (s sysAuthority) As(alias string) *sysAuthority { s.sysAuthorityDo.DO = *(s.sysAuthorityDo.As(alias).(*gen.DO)) return s.updateTableName(alias) } func (s *sysAuthority) updateTableName(table string) *sysAuthority { s.ALL = field.NewAsterisk(table) s.CreatedAt = field.NewTime(table, "created_at") s.UpdatedAt = field.NewTime(table, "updated_at") s.DeletedAt = field.NewField(table, "deleted_at") s.AuthorityID = field.NewInt64(table, "authority_id") s.AuthorityName = field.NewString(table, "authority_name") s.ParentID = field.NewInt64(table, "parent_id") s.DefaultRouter = field.NewString(table, "default_router") s.fillFieldMap() return s } func (s *sysAuthority) WithContext(ctx context.Context) ISysAuthorityDo { return s.sysAuthorityDo.WithContext(ctx) } func (s sysAuthority) TableName() string { return s.sysAuthorityDo.TableName() } func (s sysAuthority) Alias() string { return s.sysAuthorityDo.Alias() } func (s sysAuthority) Columns(cols ...field.Expr) gen.Columns { return s.sysAuthorityDo.Columns(cols...) } func (s *sysAuthority) 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 *sysAuthority) fillFieldMap() { s.fieldMap = make(map[string]field.Expr, 7) s.fieldMap["created_at"] = s.CreatedAt s.fieldMap["updated_at"] = s.UpdatedAt s.fieldMap["deleted_at"] = s.DeletedAt s.fieldMap["authority_id"] = s.AuthorityID s.fieldMap["authority_name"] = s.AuthorityName s.fieldMap["parent_id"] = s.ParentID s.fieldMap["default_router"] = s.DefaultRouter } func (s sysAuthority) clone(db *gorm.DB) sysAuthority { s.sysAuthorityDo.ReplaceConnPool(db.Statement.ConnPool) return s } func (s sysAuthority) replaceDB(db *gorm.DB) sysAuthority { s.sysAuthorityDo.ReplaceDB(db) return s } type sysAuthorityDo struct{ gen.DO } type ISysAuthorityDo interface { gen.SubQuery Debug() ISysAuthorityDo WithContext(ctx context.Context) ISysAuthorityDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() ISysAuthorityDo WriteDB() ISysAuthorityDo As(alias string) gen.Dao Session(config *gorm.Session) ISysAuthorityDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) ISysAuthorityDo Not(conds ...gen.Condition) ISysAuthorityDo Or(conds ...gen.Condition) ISysAuthorityDo Select(conds ...field.Expr) ISysAuthorityDo Where(conds ...gen.Condition) ISysAuthorityDo Order(conds ...field.Expr) ISysAuthorityDo Distinct(cols ...field.Expr) ISysAuthorityDo Omit(cols ...field.Expr) ISysAuthorityDo Join(table schema.Tabler, on ...field.Expr) ISysAuthorityDo LeftJoin(table schema.Tabler, on ...field.Expr) ISysAuthorityDo RightJoin(table schema.Tabler, on ...field.Expr) ISysAuthorityDo Group(cols ...field.Expr) ISysAuthorityDo Having(conds ...gen.Condition) ISysAuthorityDo Limit(limit int) ISysAuthorityDo Offset(offset int) ISysAuthorityDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) ISysAuthorityDo Unscoped() ISysAuthorityDo Create(values ...*model.SysAuthority) error CreateInBatches(values []*model.SysAuthority, batchSize int) error Save(values ...*model.SysAuthority) error First() (*model.SysAuthority, error) Take() (*model.SysAuthority, error) Last() (*model.SysAuthority, error) Find() ([]*model.SysAuthority, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.SysAuthority, err error) FindInBatches(result *[]*model.SysAuthority, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest interface{}) error Delete(...*model.SysAuthority) (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) ISysAuthorityDo Assign(attrs ...field.AssignExpr) ISysAuthorityDo Joins(fields ...field.RelationField) ISysAuthorityDo Preload(fields ...field.RelationField) ISysAuthorityDo FirstOrInit() (*model.SysAuthority, error) FirstOrCreate() (*model.SysAuthority, error) FindByPage(offset int, limit int) (result []*model.SysAuthority, count int64, err error) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) Rows() (*sql.Rows, error) Row() *sql.Row Scan(result interface{}) (err error) Returning(value interface{}, columns ...string) ISysAuthorityDo UnderlyingDB() *gorm.DB schema.Tabler } func (s sysAuthorityDo) Debug() ISysAuthorityDo { return s.withDO(s.DO.Debug()) } func (s sysAuthorityDo) WithContext(ctx context.Context) ISysAuthorityDo { return s.withDO(s.DO.WithContext(ctx)) } func (s sysAuthorityDo) ReadDB() ISysAuthorityDo { return s.Clauses(dbresolver.Read) } func (s sysAuthorityDo) WriteDB() ISysAuthorityDo { return s.Clauses(dbresolver.Write) } func (s sysAuthorityDo) Session(config *gorm.Session) ISysAuthorityDo { return s.withDO(s.DO.Session(config)) } func (s sysAuthorityDo) Clauses(conds ...clause.Expression) ISysAuthorityDo { return s.withDO(s.DO.Clauses(conds...)) } func (s sysAuthorityDo) Returning(value interface{}, columns ...string) ISysAuthorityDo { return s.withDO(s.DO.Returning(value, columns...)) } func (s sysAuthorityDo) Not(conds ...gen.Condition) ISysAuthorityDo { return s.withDO(s.DO.Not(conds...)) } func (s sysAuthorityDo) Or(conds ...gen.Condition) ISysAuthorityDo { return s.withDO(s.DO.Or(conds...)) } func (s sysAuthorityDo) Select(conds ...field.Expr) ISysAuthorityDo { return s.withDO(s.DO.Select(conds...)) } func (s sysAuthorityDo) Where(conds ...gen.Condition) ISysAuthorityDo { return s.withDO(s.DO.Where(conds...)) } func (s sysAuthorityDo) Order(conds ...field.Expr) ISysAuthorityDo { return s.withDO(s.DO.Order(conds...)) } func (s sysAuthorityDo) Distinct(cols ...field.Expr) ISysAuthorityDo { return s.withDO(s.DO.Distinct(cols...)) } func (s sysAuthorityDo) Omit(cols ...field.Expr) ISysAuthorityDo { return s.withDO(s.DO.Omit(cols...)) } func (s sysAuthorityDo) Join(table schema.Tabler, on ...field.Expr) ISysAuthorityDo { return s.withDO(s.DO.Join(table, on...)) } func (s sysAuthorityDo) LeftJoin(table schema.Tabler, on ...field.Expr) ISysAuthorityDo { return s.withDO(s.DO.LeftJoin(table, on...)) } func (s sysAuthorityDo) RightJoin(table schema.Tabler, on ...field.Expr) ISysAuthorityDo { return s.withDO(s.DO.RightJoin(table, on...)) } func (s sysAuthorityDo) Group(cols ...field.Expr) ISysAuthorityDo { return s.withDO(s.DO.Group(cols...)) } func (s sysAuthorityDo) Having(conds ...gen.Condition) ISysAuthorityDo { return s.withDO(s.DO.Having(conds...)) } func (s sysAuthorityDo) Limit(limit int) ISysAuthorityDo { return s.withDO(s.DO.Limit(limit)) } func (s sysAuthorityDo) Offset(offset int) ISysAuthorityDo { return s.withDO(s.DO.Offset(offset)) } func (s sysAuthorityDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ISysAuthorityDo { return s.withDO(s.DO.Scopes(funcs...)) } func (s sysAuthorityDo) Unscoped() ISysAuthorityDo { return s.withDO(s.DO.Unscoped()) } func (s sysAuthorityDo) Create(values ...*model.SysAuthority) error { if len(values) == 0 { return nil } return s.DO.Create(values) } func (s sysAuthorityDo) CreateInBatches(values []*model.SysAuthority, 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 sysAuthorityDo) Save(values ...*model.SysAuthority) error { if len(values) == 0 { return nil } return s.DO.Save(values) } func (s sysAuthorityDo) First() (*model.SysAuthority, error) { if result, err := s.DO.First(); err != nil { return nil, err } else { return result.(*model.SysAuthority), nil } } func (s sysAuthorityDo) Take() (*model.SysAuthority, error) { if result, err := s.DO.Take(); err != nil { return nil, err } else { return result.(*model.SysAuthority), nil } } func (s sysAuthorityDo) Last() (*model.SysAuthority, error) { if result, err := s.DO.Last(); err != nil { return nil, err } else { return result.(*model.SysAuthority), nil } } func (s sysAuthorityDo) Find() ([]*model.SysAuthority, error) { result, err := s.DO.Find() return result.([]*model.SysAuthority), err } func (s sysAuthorityDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.SysAuthority, err error) { buf := make([]*model.SysAuthority, 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 sysAuthorityDo) FindInBatches(result *[]*model.SysAuthority, batchSize int, fc func(tx gen.Dao, batch int) error) error { return s.DO.FindInBatches(result, batchSize, fc) } func (s sysAuthorityDo) Attrs(attrs ...field.AssignExpr) ISysAuthorityDo { return s.withDO(s.DO.Attrs(attrs...)) } func (s sysAuthorityDo) Assign(attrs ...field.AssignExpr) ISysAuthorityDo { return s.withDO(s.DO.Assign(attrs...)) } func (s sysAuthorityDo) Joins(fields ...field.RelationField) ISysAuthorityDo { for _, _f := range fields { s = *s.withDO(s.DO.Joins(_f)) } return &s } func (s sysAuthorityDo) Preload(fields ...field.RelationField) ISysAuthorityDo { for _, _f := range fields { s = *s.withDO(s.DO.Preload(_f)) } return &s } func (s sysAuthorityDo) FirstOrInit() (*model.SysAuthority, error) { if result, err := s.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.SysAuthority), nil } } func (s sysAuthorityDo) FirstOrCreate() (*model.SysAuthority, error) { if result, err := s.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.SysAuthority), nil } } func (s sysAuthorityDo) FindByPage(offset int, limit int) (result []*model.SysAuthority, 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 sysAuthorityDo) 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 sysAuthorityDo) Scan(result interface{}) (err error) { return s.DO.Scan(result) } func (s sysAuthorityDo) Delete(models ...*model.SysAuthority) (result gen.ResultInfo, err error) { return s.DO.Delete(models) } func (s *sysAuthorityDo) withDO(do gen.Dao) *sysAuthorityDo { s.DO = *do.(*gen.DO) return s }