// 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" "schisandra-album-cloud-microservices/app/auth/model/mysql/model" ) func newScaAuthRole(db *gorm.DB, opts ...gen.DOOption) scaAuthRole { _scaAuthRole := scaAuthRole{} _scaAuthRole.scaAuthRoleDo.UseDB(db, opts...) _scaAuthRole.scaAuthRoleDo.UseModel(&model.ScaAuthRole{}) tableName := _scaAuthRole.scaAuthRoleDo.TableName() _scaAuthRole.ALL = field.NewAsterisk(tableName) _scaAuthRole.ID = field.NewInt64(tableName, "id") _scaAuthRole.RoleName = field.NewString(tableName, "role_name") _scaAuthRole.RoleKey = field.NewString(tableName, "role_key") _scaAuthRole.CreatedAt = field.NewTime(tableName, "created_at") _scaAuthRole.UpdatedAt = field.NewTime(tableName, "updated_at") _scaAuthRole.DeletedAt = field.NewField(tableName, "deleted_at") _scaAuthRole.fillFieldMap() return _scaAuthRole } // scaAuthRole 角色表 type scaAuthRole struct { scaAuthRoleDo ALL field.Asterisk ID field.Int64 // 主键ID RoleName field.String // 角色名称 RoleKey field.String // 角色关键字 CreatedAt field.Time // 创建时间 UpdatedAt field.Time // 更新时间 DeletedAt field.Field // 删除时间 fieldMap map[string]field.Expr } func (s scaAuthRole) Table(newTableName string) *scaAuthRole { s.scaAuthRoleDo.UseTable(newTableName) return s.updateTableName(newTableName) } func (s scaAuthRole) As(alias string) *scaAuthRole { s.scaAuthRoleDo.DO = *(s.scaAuthRoleDo.As(alias).(*gen.DO)) return s.updateTableName(alias) } func (s *scaAuthRole) updateTableName(table string) *scaAuthRole { s.ALL = field.NewAsterisk(table) s.ID = field.NewInt64(table, "id") s.RoleName = field.NewString(table, "role_name") s.RoleKey = field.NewString(table, "role_key") s.CreatedAt = field.NewTime(table, "created_at") s.UpdatedAt = field.NewTime(table, "updated_at") s.DeletedAt = field.NewField(table, "deleted_at") s.fillFieldMap() return s } func (s *scaAuthRole) 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 *scaAuthRole) fillFieldMap() { s.fieldMap = make(map[string]field.Expr, 6) s.fieldMap["id"] = s.ID s.fieldMap["role_name"] = s.RoleName s.fieldMap["role_key"] = s.RoleKey s.fieldMap["created_at"] = s.CreatedAt s.fieldMap["updated_at"] = s.UpdatedAt s.fieldMap["deleted_at"] = s.DeletedAt } func (s scaAuthRole) clone(db *gorm.DB) scaAuthRole { s.scaAuthRoleDo.ReplaceConnPool(db.Statement.ConnPool) return s } func (s scaAuthRole) replaceDB(db *gorm.DB) scaAuthRole { s.scaAuthRoleDo.ReplaceDB(db) return s } type scaAuthRoleDo struct{ gen.DO } type IScaAuthRoleDo interface { gen.SubQuery Debug() IScaAuthRoleDo WithContext(ctx context.Context) IScaAuthRoleDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() IScaAuthRoleDo WriteDB() IScaAuthRoleDo As(alias string) gen.Dao Session(config *gorm.Session) IScaAuthRoleDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) IScaAuthRoleDo Not(conds ...gen.Condition) IScaAuthRoleDo Or(conds ...gen.Condition) IScaAuthRoleDo Select(conds ...field.Expr) IScaAuthRoleDo Where(conds ...gen.Condition) IScaAuthRoleDo Order(conds ...field.Expr) IScaAuthRoleDo Distinct(cols ...field.Expr) IScaAuthRoleDo Omit(cols ...field.Expr) IScaAuthRoleDo Join(table schema.Tabler, on ...field.Expr) IScaAuthRoleDo LeftJoin(table schema.Tabler, on ...field.Expr) IScaAuthRoleDo RightJoin(table schema.Tabler, on ...field.Expr) IScaAuthRoleDo Group(cols ...field.Expr) IScaAuthRoleDo Having(conds ...gen.Condition) IScaAuthRoleDo Limit(limit int) IScaAuthRoleDo Offset(offset int) IScaAuthRoleDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) IScaAuthRoleDo Unscoped() IScaAuthRoleDo Create(values ...*model.ScaAuthRole) error CreateInBatches(values []*model.ScaAuthRole, batchSize int) error Save(values ...*model.ScaAuthRole) error First() (*model.ScaAuthRole, error) Take() (*model.ScaAuthRole, error) Last() (*model.ScaAuthRole, error) Find() ([]*model.ScaAuthRole, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ScaAuthRole, err error) FindInBatches(result *[]*model.ScaAuthRole, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest interface{}) error Delete(...*model.ScaAuthRole) (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) IScaAuthRoleDo Assign(attrs ...field.AssignExpr) IScaAuthRoleDo Joins(fields ...field.RelationField) IScaAuthRoleDo Preload(fields ...field.RelationField) IScaAuthRoleDo FirstOrInit() (*model.ScaAuthRole, error) FirstOrCreate() (*model.ScaAuthRole, error) FindByPage(offset int, limit int) (result []*model.ScaAuthRole, 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) IScaAuthRoleDo UnderlyingDB() *gorm.DB schema.Tabler } func (s scaAuthRoleDo) Debug() IScaAuthRoleDo { return s.withDO(s.DO.Debug()) } func (s scaAuthRoleDo) WithContext(ctx context.Context) IScaAuthRoleDo { return s.withDO(s.DO.WithContext(ctx)) } func (s scaAuthRoleDo) ReadDB() IScaAuthRoleDo { return s.Clauses(dbresolver.Read) } func (s scaAuthRoleDo) WriteDB() IScaAuthRoleDo { return s.Clauses(dbresolver.Write) } func (s scaAuthRoleDo) Session(config *gorm.Session) IScaAuthRoleDo { return s.withDO(s.DO.Session(config)) } func (s scaAuthRoleDo) Clauses(conds ...clause.Expression) IScaAuthRoleDo { return s.withDO(s.DO.Clauses(conds...)) } func (s scaAuthRoleDo) Returning(value interface{}, columns ...string) IScaAuthRoleDo { return s.withDO(s.DO.Returning(value, columns...)) } func (s scaAuthRoleDo) Not(conds ...gen.Condition) IScaAuthRoleDo { return s.withDO(s.DO.Not(conds...)) } func (s scaAuthRoleDo) Or(conds ...gen.Condition) IScaAuthRoleDo { return s.withDO(s.DO.Or(conds...)) } func (s scaAuthRoleDo) Select(conds ...field.Expr) IScaAuthRoleDo { return s.withDO(s.DO.Select(conds...)) } func (s scaAuthRoleDo) Where(conds ...gen.Condition) IScaAuthRoleDo { return s.withDO(s.DO.Where(conds...)) } func (s scaAuthRoleDo) Order(conds ...field.Expr) IScaAuthRoleDo { return s.withDO(s.DO.Order(conds...)) } func (s scaAuthRoleDo) Distinct(cols ...field.Expr) IScaAuthRoleDo { return s.withDO(s.DO.Distinct(cols...)) } func (s scaAuthRoleDo) Omit(cols ...field.Expr) IScaAuthRoleDo { return s.withDO(s.DO.Omit(cols...)) } func (s scaAuthRoleDo) Join(table schema.Tabler, on ...field.Expr) IScaAuthRoleDo { return s.withDO(s.DO.Join(table, on...)) } func (s scaAuthRoleDo) LeftJoin(table schema.Tabler, on ...field.Expr) IScaAuthRoleDo { return s.withDO(s.DO.LeftJoin(table, on...)) } func (s scaAuthRoleDo) RightJoin(table schema.Tabler, on ...field.Expr) IScaAuthRoleDo { return s.withDO(s.DO.RightJoin(table, on...)) } func (s scaAuthRoleDo) Group(cols ...field.Expr) IScaAuthRoleDo { return s.withDO(s.DO.Group(cols...)) } func (s scaAuthRoleDo) Having(conds ...gen.Condition) IScaAuthRoleDo { return s.withDO(s.DO.Having(conds...)) } func (s scaAuthRoleDo) Limit(limit int) IScaAuthRoleDo { return s.withDO(s.DO.Limit(limit)) } func (s scaAuthRoleDo) Offset(offset int) IScaAuthRoleDo { return s.withDO(s.DO.Offset(offset)) } func (s scaAuthRoleDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IScaAuthRoleDo { return s.withDO(s.DO.Scopes(funcs...)) } func (s scaAuthRoleDo) Unscoped() IScaAuthRoleDo { return s.withDO(s.DO.Unscoped()) } func (s scaAuthRoleDo) Create(values ...*model.ScaAuthRole) error { if len(values) == 0 { return nil } return s.DO.Create(values) } func (s scaAuthRoleDo) CreateInBatches(values []*model.ScaAuthRole, 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 scaAuthRoleDo) Save(values ...*model.ScaAuthRole) error { if len(values) == 0 { return nil } return s.DO.Save(values) } func (s scaAuthRoleDo) First() (*model.ScaAuthRole, error) { if result, err := s.DO.First(); err != nil { return nil, err } else { return result.(*model.ScaAuthRole), nil } } func (s scaAuthRoleDo) Take() (*model.ScaAuthRole, error) { if result, err := s.DO.Take(); err != nil { return nil, err } else { return result.(*model.ScaAuthRole), nil } } func (s scaAuthRoleDo) Last() (*model.ScaAuthRole, error) { if result, err := s.DO.Last(); err != nil { return nil, err } else { return result.(*model.ScaAuthRole), nil } } func (s scaAuthRoleDo) Find() ([]*model.ScaAuthRole, error) { result, err := s.DO.Find() return result.([]*model.ScaAuthRole), err } func (s scaAuthRoleDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ScaAuthRole, err error) { buf := make([]*model.ScaAuthRole, 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 scaAuthRoleDo) FindInBatches(result *[]*model.ScaAuthRole, batchSize int, fc func(tx gen.Dao, batch int) error) error { return s.DO.FindInBatches(result, batchSize, fc) } func (s scaAuthRoleDo) Attrs(attrs ...field.AssignExpr) IScaAuthRoleDo { return s.withDO(s.DO.Attrs(attrs...)) } func (s scaAuthRoleDo) Assign(attrs ...field.AssignExpr) IScaAuthRoleDo { return s.withDO(s.DO.Assign(attrs...)) } func (s scaAuthRoleDo) Joins(fields ...field.RelationField) IScaAuthRoleDo { for _, _f := range fields { s = *s.withDO(s.DO.Joins(_f)) } return &s } func (s scaAuthRoleDo) Preload(fields ...field.RelationField) IScaAuthRoleDo { for _, _f := range fields { s = *s.withDO(s.DO.Preload(_f)) } return &s } func (s scaAuthRoleDo) FirstOrInit() (*model.ScaAuthRole, error) { if result, err := s.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.ScaAuthRole), nil } } func (s scaAuthRoleDo) FirstOrCreate() (*model.ScaAuthRole, error) { if result, err := s.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.ScaAuthRole), nil } } func (s scaAuthRoleDo) FindByPage(offset int, limit int) (result []*model.ScaAuthRole, 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 scaAuthRoleDo) 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 scaAuthRoleDo) Scan(result interface{}) (err error) { return s.DO.Scan(result) } func (s scaAuthRoleDo) Delete(models ...*model.ScaAuthRole) (result gen.ResultInfo, err error) { return s.DO.Delete(models) } func (s *scaAuthRoleDo) withDO(do gen.Dao) *scaAuthRoleDo { s.DO = *do.(*gen.DO) return s }