// 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 model import ( "context" "gorm.io/gorm" "gorm.io/gorm/clause" "gorm.io/gorm/schema" "gorm.io/gen" "gorm.io/gen/field" "gorm.io/plugin/dbresolver" "icloudapp.cn/tools/service/entity" ) func newRole(db *gorm.DB, opts ...gen.DOOption) MRole { _MRole := MRole{} _MRole.MRoleDo.UseDB(db, opts...) _MRole.MRoleDo.UseModel(&entity.Role{}) tableName := _MRole.MRoleDo.TableName() _MRole.ALL = field.NewAsterisk(tableName) _MRole.RoleID = field.NewInt64(tableName, "role_id") _MRole.RoleName = field.NewString(tableName, "role_name") _MRole.ModelIds = field.NewString(tableName, "model_ids") _MRole.RoleStatus = field.NewInt64(tableName, "role_status") _MRole.OperatorUID = field.NewInt64(tableName, "operator_uid") _MRole.CreateAt = field.NewTime(tableName, "create_at") _MRole.UpdateAt = field.NewTime(tableName, "update_at") _MRole.fillFieldMap() return _MRole } type MRole struct { MRoleDo MRoleDo ALL field.Asterisk RoleID field.Int64 // 权限ID RoleName field.String // 权限名称 ModelIds field.String // 权限对应的模块名 RoleStatus field.Int64 // 模块状态 OperatorUID field.Int64 // 操作人 CreateAt field.Time // 添加时间 UpdateAt field.Time // 更新时间 fieldMap map[string]field.Expr } func (r MRole) Table(newTableName string) *MRole { r.MRoleDo.UseTable(newTableName) return r.updateTableName(newTableName) } func (r MRole) As(alias string) *MRole { r.MRoleDo.DO = *(r.MRoleDo.As(alias).(*gen.DO)) return r.updateTableName(alias) } func (r *MRole) updateTableName(table string) *MRole { r.ALL = field.NewAsterisk(table) r.RoleID = field.NewInt64(table, "role_id") r.RoleName = field.NewString(table, "role_name") r.ModelIds = field.NewString(table, "model_ids") r.RoleStatus = field.NewInt64(table, "role_status") r.OperatorUID = field.NewInt64(table, "operator_uid") r.CreateAt = field.NewTime(table, "create_at") r.UpdateAt = field.NewTime(table, "update_at") r.fillFieldMap() return r } func (r *MRole) WithContext(ctx context.Context) IRoleDo { return r.MRoleDo.WithContext(ctx) } func (r MRole) TableName() string { return r.MRoleDo.TableName() } func (r MRole) Alias() string { return r.MRoleDo.Alias() } func (r *MRole) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := r.fieldMap[fieldName] if !ok || _f == nil { return nil, false } _oe, ok := _f.(field.OrderExpr) return _oe, ok } func (r *MRole) fillFieldMap() { r.fieldMap = make(map[string]field.Expr, 7) r.fieldMap["role_id"] = r.RoleID r.fieldMap["role_name"] = r.RoleName r.fieldMap["model_ids"] = r.ModelIds r.fieldMap["role_status"] = r.RoleStatus r.fieldMap["operator_uid"] = r.OperatorUID r.fieldMap["create_at"] = r.CreateAt r.fieldMap["update_at"] = r.UpdateAt } func (r MRole) clone(db *gorm.DB) MRole { r.MRoleDo.ReplaceConnPool(db.Statement.ConnPool) return r } func (r MRole) replaceDB(db *gorm.DB) MRole { r.MRoleDo.ReplaceDB(db) return r } type MRoleDo struct{ gen.DO } type IRoleDo interface { gen.SubQuery Debug() IRoleDo WithContext(ctx context.Context) IRoleDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() IRoleDo WriteDB() IRoleDo As(alias string) gen.Dao Session(config *gorm.Session) IRoleDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) IRoleDo Not(conds ...gen.Condition) IRoleDo Or(conds ...gen.Condition) IRoleDo Select(conds ...field.Expr) IRoleDo Where(conds ...gen.Condition) IRoleDo Order(conds ...field.Expr) IRoleDo Distinct(cols ...field.Expr) IRoleDo Omit(cols ...field.Expr) IRoleDo Join(table schema.Tabler, on ...field.Expr) IRoleDo LeftJoin(table schema.Tabler, on ...field.Expr) IRoleDo RightJoin(table schema.Tabler, on ...field.Expr) IRoleDo Group(cols ...field.Expr) IRoleDo Having(conds ...gen.Condition) IRoleDo Limit(limit int) IRoleDo Offset(offset int) IRoleDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) IRoleDo Unscoped() IRoleDo Create(values ...*entity.Role) error CreateInBatches(values []*entity.Role, batchSize int) error Save(values ...*entity.Role) error First() (*entity.Role, error) Take() (*entity.Role, error) Last() (*entity.Role, error) Find() ([]*entity.Role, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.Role, err error) FindInBatches(result *[]*entity.Role, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest interface{}) error Delete(...*entity.Role) (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) IRoleDo Assign(attrs ...field.AssignExpr) IRoleDo Joins(fields ...field.RelationField) IRoleDo Preload(fields ...field.RelationField) IRoleDo FirstOrInit() (*entity.Role, error) FirstOrCreate() (*entity.Role, error) FindByPage(offset int, limit int) (result []*entity.Role, 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) IRoleDo UnderlyingDB() *gorm.DB schema.Tabler } func (r MRoleDo) Debug() IRoleDo { return r.withDO(r.DO.Debug()) } func (r MRoleDo) WithContext(ctx context.Context) IRoleDo { return r.withDO(r.DO.WithContext(ctx)) } func (r MRoleDo) ReadDB() IRoleDo { return r.Clauses(dbresolver.Read) } func (r MRoleDo) WriteDB() IRoleDo { return r.Clauses(dbresolver.Write) } func (r MRoleDo) Session(config *gorm.Session) IRoleDo { return r.withDO(r.DO.Session(config)) } func (r MRoleDo) Clauses(conds ...clause.Expression) IRoleDo { return r.withDO(r.DO.Clauses(conds...)) } func (r MRoleDo) Returning(value interface{}, columns ...string) IRoleDo { return r.withDO(r.DO.Returning(value, columns...)) } func (r MRoleDo) Not(conds ...gen.Condition) IRoleDo { return r.withDO(r.DO.Not(conds...)) } func (r MRoleDo) Or(conds ...gen.Condition) IRoleDo { return r.withDO(r.DO.Or(conds...)) } func (r MRoleDo) Select(conds ...field.Expr) IRoleDo { return r.withDO(r.DO.Select(conds...)) } func (r MRoleDo) Where(conds ...gen.Condition) IRoleDo { return r.withDO(r.DO.Where(conds...)) } func (r MRoleDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) IRoleDo { return r.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB())) } func (r MRoleDo) Order(conds ...field.Expr) IRoleDo { return r.withDO(r.DO.Order(conds...)) } func (r MRoleDo) Distinct(cols ...field.Expr) IRoleDo { return r.withDO(r.DO.Distinct(cols...)) } func (r MRoleDo) Omit(cols ...field.Expr) IRoleDo { return r.withDO(r.DO.Omit(cols...)) } func (r MRoleDo) Join(table schema.Tabler, on ...field.Expr) IRoleDo { return r.withDO(r.DO.Join(table, on...)) } func (r MRoleDo) LeftJoin(table schema.Tabler, on ...field.Expr) IRoleDo { return r.withDO(r.DO.LeftJoin(table, on...)) } func (r MRoleDo) RightJoin(table schema.Tabler, on ...field.Expr) IRoleDo { return r.withDO(r.DO.RightJoin(table, on...)) } func (r MRoleDo) Group(cols ...field.Expr) IRoleDo { return r.withDO(r.DO.Group(cols...)) } func (r MRoleDo) Having(conds ...gen.Condition) IRoleDo { return r.withDO(r.DO.Having(conds...)) } func (r MRoleDo) Limit(limit int) IRoleDo { return r.withDO(r.DO.Limit(limit)) } func (r MRoleDo) Offset(offset int) IRoleDo { return r.withDO(r.DO.Offset(offset)) } func (r MRoleDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IRoleDo { return r.withDO(r.DO.Scopes(funcs...)) } func (r MRoleDo) Unscoped() IRoleDo { return r.withDO(r.DO.Unscoped()) } func (r MRoleDo) Create(values ...*entity.Role) error { if len(values) == 0 { return nil } return r.DO.Create(values) } func (r MRoleDo) CreateInBatches(values []*entity.Role, batchSize int) error { return r.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 (r MRoleDo) Save(values ...*entity.Role) error { if len(values) == 0 { return nil } return r.DO.Save(values) } func (r MRoleDo) First() (*entity.Role, error) { if result, err := r.DO.First(); err != nil { return nil, err } else { return result.(*entity.Role), nil } } func (r MRoleDo) Take() (*entity.Role, error) { if result, err := r.DO.Take(); err != nil { return nil, err } else { return result.(*entity.Role), nil } } func (r MRoleDo) Last() (*entity.Role, error) { if result, err := r.DO.Last(); err != nil { return nil, err } else { return result.(*entity.Role), nil } } func (r MRoleDo) Find() ([]*entity.Role, error) { result, err := r.DO.Find() return result.([]*entity.Role), err } func (r MRoleDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.Role, err error) { buf := make([]*entity.Role, 0, batchSize) err = r.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 (r MRoleDo) FindInBatches(result *[]*entity.Role, batchSize int, fc func(tx gen.Dao, batch int) error) error { return r.DO.FindInBatches(result, batchSize, fc) } func (r MRoleDo) Attrs(attrs ...field.AssignExpr) IRoleDo { return r.withDO(r.DO.Attrs(attrs...)) } func (r MRoleDo) Assign(attrs ...field.AssignExpr) IRoleDo { return r.withDO(r.DO.Assign(attrs...)) } func (r MRoleDo) Joins(fields ...field.RelationField) IRoleDo { for _, _f := range fields { r = *r.withDO(r.DO.Joins(_f)) } return &r } func (r MRoleDo) Preload(fields ...field.RelationField) IRoleDo { for _, _f := range fields { r = *r.withDO(r.DO.Preload(_f)) } return &r } func (r MRoleDo) FirstOrInit() (*entity.Role, error) { if result, err := r.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*entity.Role), nil } } func (r MRoleDo) FirstOrCreate() (*entity.Role, error) { if result, err := r.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*entity.Role), nil } } func (r MRoleDo) FindByPage(offset int, limit int) (result []*entity.Role, count int64, err error) { result, err = r.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 = r.Offset(-1).Limit(-1).Count() return } func (r MRoleDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { count, err = r.Count() if err != nil { return } err = r.Offset(offset).Limit(limit).Scan(result) return } func (r MRoleDo) Scan(result interface{}) (err error) { return r.DO.Scan(result) } func (r MRoleDo) Delete(models ...*entity.Role) (result gen.ResultInfo, err error) { return r.DO.Delete(models) } func (r *MRoleDo) withDO(do gen.Dao) *MRoleDo { r.DO = *do.(*gen.DO) return r }