// 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 repo import ( "context" "gorm.io/gorm" "gorm.io/gorm/clause" "gorm.io/gorm/schema" "gorm.io/gen" "gorm.io/gen/field" "gorm.io/plugin/dbresolver" "gitea.ddegame.cn/open/servicebase/pkg/model" ) func newAdminPrivilege(db *gorm.DB, opts ...gen.DOOption) adminPrivilege { _adminPrivilege := adminPrivilege{} _adminPrivilege.adminPrivilegeDo.UseDB(db, opts...) _adminPrivilege.adminPrivilegeDo.UseModel(&model.AdminPrivilege{}) tableName := _adminPrivilege.adminPrivilegeDo.TableName() _adminPrivilege.ALL = field.NewAsterisk(tableName) _adminPrivilege.ID = field.NewString(tableName, "id") _adminPrivilege.TenantID = field.NewString(tableName, "tenant_id") _adminPrivilege.ScopeID = field.NewString(tableName, "scope_id") _adminPrivilege.ParentID = field.NewString(tableName, "parent_id") _adminPrivilege.Code = field.NewString(tableName, "code") _adminPrivilege.Name = field.NewString(tableName, "name") _adminPrivilege.Level = field.NewInt32(tableName, "level") _adminPrivilege.SourceType = field.NewString(tableName, "source_type") _adminPrivilege.TargetType = field.NewString(tableName, "target_type") _adminPrivilege.Target = field.NewString(tableName, "target") _adminPrivilege.Desc = field.NewString(tableName, "desc") _adminPrivilege.DeleteAt = field.NewField(tableName, "delete_at") _adminPrivilege.CreateAt = field.NewTime(tableName, "create_at") _adminPrivilege.CreateBy = field.NewString(tableName, "create_by") _adminPrivilege.UpdateAt = field.NewTime(tableName, "update_at") _adminPrivilege.UpdateBy = field.NewString(tableName, "update_by") _adminPrivilege.fillFieldMap() return _adminPrivilege } // adminPrivilege 租户-权限表 type adminPrivilege struct { adminPrivilegeDo adminPrivilegeDo ALL field.Asterisk ID field.String // 业务ID TenantID field.String // 企业ID ScopeID field.String // 范围 ParentID field.String // 父ID Code field.String // 代码 Name field.String // 权限名称 Level field.Int32 // 权限级别 SourceType field.String // 类型:resource、interface等 TargetType field.String Target field.String // 权限值 resource:菜单路径; api=url-pre Desc field.String // 描述 DeleteAt field.Field // del标志 CreateAt field.Time // 创建时间 CreateBy field.String // 创建人 UpdateAt field.Time // 更新时间 UpdateBy field.String // 更新人 fieldMap map[string]field.Expr } func (a adminPrivilege) Table(newTableName string) *adminPrivilege { a.adminPrivilegeDo.UseTable(newTableName) return a.updateTableName(newTableName) } func (a adminPrivilege) As(alias string) *adminPrivilege { a.adminPrivilegeDo.DO = *(a.adminPrivilegeDo.As(alias).(*gen.DO)) return a.updateTableName(alias) } func (a *adminPrivilege) updateTableName(table string) *adminPrivilege { a.ALL = field.NewAsterisk(table) a.ID = field.NewString(table, "id") a.TenantID = field.NewString(table, "tenant_id") a.ScopeID = field.NewString(table, "scope_id") a.ParentID = field.NewString(table, "parent_id") a.Code = field.NewString(table, "code") a.Name = field.NewString(table, "name") a.Level = field.NewInt32(table, "level") a.SourceType = field.NewString(table, "source_type") a.TargetType = field.NewString(table, "target_type") a.Target = field.NewString(table, "target") a.Desc = field.NewString(table, "desc") a.DeleteAt = field.NewField(table, "delete_at") a.CreateAt = field.NewTime(table, "create_at") a.CreateBy = field.NewString(table, "create_by") a.UpdateAt = field.NewTime(table, "update_at") a.UpdateBy = field.NewString(table, "update_by") a.fillFieldMap() return a } func (a *adminPrivilege) WithContext(ctx context.Context) IAdminPrivilegeDo { return a.adminPrivilegeDo.WithContext(ctx) } func (a adminPrivilege) TableName() string { return a.adminPrivilegeDo.TableName() } func (a adminPrivilege) Alias() string { return a.adminPrivilegeDo.Alias() } func (a adminPrivilege) Columns(cols ...field.Expr) gen.Columns { return a.adminPrivilegeDo.Columns(cols...) } func (a *adminPrivilege) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := a.fieldMap[fieldName] if !ok || _f == nil { return nil, false } _oe, ok := _f.(field.OrderExpr) return _oe, ok } func (a *adminPrivilege) fillFieldMap() { a.fieldMap = make(map[string]field.Expr, 16) a.fieldMap["id"] = a.ID a.fieldMap["tenant_id"] = a.TenantID a.fieldMap["scope_id"] = a.ScopeID a.fieldMap["parent_id"] = a.ParentID a.fieldMap["code"] = a.Code a.fieldMap["name"] = a.Name a.fieldMap["level"] = a.Level a.fieldMap["source_type"] = a.SourceType a.fieldMap["target_type"] = a.TargetType a.fieldMap["target"] = a.Target a.fieldMap["desc"] = a.Desc a.fieldMap["delete_at"] = a.DeleteAt a.fieldMap["create_at"] = a.CreateAt a.fieldMap["create_by"] = a.CreateBy a.fieldMap["update_at"] = a.UpdateAt a.fieldMap["update_by"] = a.UpdateBy } func (a adminPrivilege) clone(db *gorm.DB) adminPrivilege { a.adminPrivilegeDo.ReplaceConnPool(db.Statement.ConnPool) return a } func (a adminPrivilege) replaceDB(db *gorm.DB) adminPrivilege { a.adminPrivilegeDo.ReplaceDB(db) return a } type adminPrivilegeDo struct{ gen.DO } type IAdminPrivilegeDo interface { gen.SubQuery Debug() IAdminPrivilegeDo WithContext(ctx context.Context) IAdminPrivilegeDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() IAdminPrivilegeDo WriteDB() IAdminPrivilegeDo As(alias string) gen.Dao Session(config *gorm.Session) IAdminPrivilegeDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) IAdminPrivilegeDo Not(conds ...gen.Condition) IAdminPrivilegeDo Or(conds ...gen.Condition) IAdminPrivilegeDo Select(conds ...field.Expr) IAdminPrivilegeDo Where(conds ...gen.Condition) IAdminPrivilegeDo Order(conds ...field.Expr) IAdminPrivilegeDo Distinct(cols ...field.Expr) IAdminPrivilegeDo Omit(cols ...field.Expr) IAdminPrivilegeDo Join(table schema.Tabler, on ...field.Expr) IAdminPrivilegeDo LeftJoin(table schema.Tabler, on ...field.Expr) IAdminPrivilegeDo RightJoin(table schema.Tabler, on ...field.Expr) IAdminPrivilegeDo Group(cols ...field.Expr) IAdminPrivilegeDo Having(conds ...gen.Condition) IAdminPrivilegeDo Limit(limit int) IAdminPrivilegeDo Offset(offset int) IAdminPrivilegeDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) IAdminPrivilegeDo Unscoped() IAdminPrivilegeDo Create(values ...*model.AdminPrivilege) error CreateInBatches(values []*model.AdminPrivilege, batchSize int) error Save(values ...*model.AdminPrivilege) error First() (*model.AdminPrivilege, error) Take() (*model.AdminPrivilege, error) Last() (*model.AdminPrivilege, error) Find() ([]*model.AdminPrivilege, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AdminPrivilege, err error) FindInBatches(result *[]*model.AdminPrivilege, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest any) error Delete(...*model.AdminPrivilege) (info gen.ResultInfo, err error) Update(column field.Expr, value any) (info gen.ResultInfo, err error) UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) Updates(value any) (info gen.ResultInfo, err error) UpdateColumn(column field.Expr, value any) (info gen.ResultInfo, err error) UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) UpdateColumns(value any) (info gen.ResultInfo, err error) UpdateFrom(q gen.SubQuery) gen.Dao Attrs(attrs ...field.AssignExpr) IAdminPrivilegeDo Assign(attrs ...field.AssignExpr) IAdminPrivilegeDo Joins(fields ...field.RelationField) IAdminPrivilegeDo Preload(fields ...field.RelationField) IAdminPrivilegeDo FirstOrInit() (*model.AdminPrivilege, error) FirstOrCreate() (*model.AdminPrivilege, error) FindByPage(offset int, limit int) (result []*model.AdminPrivilege, count int64, err error) ScanByPage(result any, offset int, limit int) (count int64, err error) Scan(result any) (err error) Returning(value any, columns ...string) IAdminPrivilegeDo UnderlyingDB() *gorm.DB schema.Tabler } func (a adminPrivilegeDo) Debug() IAdminPrivilegeDo { return a.withDO(a.DO.Debug()) } func (a adminPrivilegeDo) WithContext(ctx context.Context) IAdminPrivilegeDo { return a.withDO(a.DO.WithContext(ctx)) } func (a adminPrivilegeDo) ReadDB() IAdminPrivilegeDo { return a.Clauses(dbresolver.Read) } func (a adminPrivilegeDo) WriteDB() IAdminPrivilegeDo { return a.Clauses(dbresolver.Write) } func (a adminPrivilegeDo) Session(config *gorm.Session) IAdminPrivilegeDo { return a.withDO(a.DO.Session(config)) } func (a adminPrivilegeDo) Clauses(conds ...clause.Expression) IAdminPrivilegeDo { return a.withDO(a.DO.Clauses(conds...)) } func (a adminPrivilegeDo) Returning(value any, columns ...string) IAdminPrivilegeDo { return a.withDO(a.DO.Returning(value, columns...)) } func (a adminPrivilegeDo) Not(conds ...gen.Condition) IAdminPrivilegeDo { return a.withDO(a.DO.Not(conds...)) } func (a adminPrivilegeDo) Or(conds ...gen.Condition) IAdminPrivilegeDo { return a.withDO(a.DO.Or(conds...)) } func (a adminPrivilegeDo) Select(conds ...field.Expr) IAdminPrivilegeDo { return a.withDO(a.DO.Select(conds...)) } func (a adminPrivilegeDo) Where(conds ...gen.Condition) IAdminPrivilegeDo { return a.withDO(a.DO.Where(conds...)) } func (a adminPrivilegeDo) Order(conds ...field.Expr) IAdminPrivilegeDo { return a.withDO(a.DO.Order(conds...)) } func (a adminPrivilegeDo) Distinct(cols ...field.Expr) IAdminPrivilegeDo { return a.withDO(a.DO.Distinct(cols...)) } func (a adminPrivilegeDo) Omit(cols ...field.Expr) IAdminPrivilegeDo { return a.withDO(a.DO.Omit(cols...)) } func (a adminPrivilegeDo) Join(table schema.Tabler, on ...field.Expr) IAdminPrivilegeDo { return a.withDO(a.DO.Join(table, on...)) } func (a adminPrivilegeDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAdminPrivilegeDo { return a.withDO(a.DO.LeftJoin(table, on...)) } func (a adminPrivilegeDo) RightJoin(table schema.Tabler, on ...field.Expr) IAdminPrivilegeDo { return a.withDO(a.DO.RightJoin(table, on...)) } func (a adminPrivilegeDo) Group(cols ...field.Expr) IAdminPrivilegeDo { return a.withDO(a.DO.Group(cols...)) } func (a adminPrivilegeDo) Having(conds ...gen.Condition) IAdminPrivilegeDo { return a.withDO(a.DO.Having(conds...)) } func (a adminPrivilegeDo) Limit(limit int) IAdminPrivilegeDo { return a.withDO(a.DO.Limit(limit)) } func (a adminPrivilegeDo) Offset(offset int) IAdminPrivilegeDo { return a.withDO(a.DO.Offset(offset)) } func (a adminPrivilegeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAdminPrivilegeDo { return a.withDO(a.DO.Scopes(funcs...)) } func (a adminPrivilegeDo) Unscoped() IAdminPrivilegeDo { return a.withDO(a.DO.Unscoped()) } func (a adminPrivilegeDo) Create(values ...*model.AdminPrivilege) error { if len(values) == 0 { return nil } return a.DO.Create(values) } func (a adminPrivilegeDo) CreateInBatches(values []*model.AdminPrivilege, batchSize int) error { return a.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 (a adminPrivilegeDo) Save(values ...*model.AdminPrivilege) error { if len(values) == 0 { return nil } return a.DO.Save(values) } func (a adminPrivilegeDo) First() (*model.AdminPrivilege, error) { if result, err := a.DO.First(); err != nil { return nil, err } else { return result.(*model.AdminPrivilege), nil } } func (a adminPrivilegeDo) Take() (*model.AdminPrivilege, error) { if result, err := a.DO.Take(); err != nil { return nil, err } else { return result.(*model.AdminPrivilege), nil } } func (a adminPrivilegeDo) Last() (*model.AdminPrivilege, error) { if result, err := a.DO.Last(); err != nil { return nil, err } else { return result.(*model.AdminPrivilege), nil } } func (a adminPrivilegeDo) Find() ([]*model.AdminPrivilege, error) { result, err := a.DO.Find() return result.([]*model.AdminPrivilege), err } func (a adminPrivilegeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AdminPrivilege, err error) { buf := make([]*model.AdminPrivilege, 0, batchSize) err = a.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 (a adminPrivilegeDo) FindInBatches(result *[]*model.AdminPrivilege, batchSize int, fc func(tx gen.Dao, batch int) error) error { return a.DO.FindInBatches(result, batchSize, fc) } func (a adminPrivilegeDo) Attrs(attrs ...field.AssignExpr) IAdminPrivilegeDo { return a.withDO(a.DO.Attrs(attrs...)) } func (a adminPrivilegeDo) Assign(attrs ...field.AssignExpr) IAdminPrivilegeDo { return a.withDO(a.DO.Assign(attrs...)) } func (a adminPrivilegeDo) Joins(fields ...field.RelationField) IAdminPrivilegeDo { for _, _f := range fields { a = *a.withDO(a.DO.Joins(_f)) } return &a } func (a adminPrivilegeDo) Preload(fields ...field.RelationField) IAdminPrivilegeDo { for _, _f := range fields { a = *a.withDO(a.DO.Preload(_f)) } return &a } func (a adminPrivilegeDo) FirstOrInit() (*model.AdminPrivilege, error) { if result, err := a.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.AdminPrivilege), nil } } func (a adminPrivilegeDo) FirstOrCreate() (*model.AdminPrivilege, error) { if result, err := a.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.AdminPrivilege), nil } } func (a adminPrivilegeDo) FindByPage(offset int, limit int) (result []*model.AdminPrivilege, count int64, err error) { result, err = a.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 = a.Offset(-1).Limit(-1).Count() return } func (a adminPrivilegeDo) ScanByPage(result any, offset int, limit int) (count int64, err error) { count, err = a.Count() if err != nil { return } err = a.Offset(offset).Limit(limit).Scan(result) return } func (a adminPrivilegeDo) Scan(result any) (err error) { return a.DO.Scan(result) } func (a adminPrivilegeDo) Delete(models ...*model.AdminPrivilege) (result gen.ResultInfo, err error) { return a.DO.Delete(models) } func (a *adminPrivilegeDo) withDO(do gen.Dao) *adminPrivilegeDo { a.DO = *do.(*gen.DO) return a }