421 lines
12 KiB
Go
421 lines
12 KiB
Go
// 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"
|
|
|
|
"atom/database/models"
|
|
)
|
|
|
|
func newCasbinRule(db *gorm.DB, opts ...gen.DOOption) casbinRule {
|
|
_casbinRule := casbinRule{}
|
|
|
|
_casbinRule.casbinRuleDo.UseDB(db, opts...)
|
|
_casbinRule.casbinRuleDo.UseModel(&models.CasbinRule{})
|
|
|
|
tableName := _casbinRule.casbinRuleDo.TableName()
|
|
_casbinRule.ALL = field.NewAsterisk(tableName)
|
|
_casbinRule.ID = field.NewUint64(tableName, "id")
|
|
_casbinRule.Ptype = field.NewString(tableName, "ptype")
|
|
_casbinRule.V0 = field.NewString(tableName, "v0")
|
|
_casbinRule.V1 = field.NewString(tableName, "v1")
|
|
_casbinRule.V2 = field.NewString(tableName, "v2")
|
|
_casbinRule.V3 = field.NewString(tableName, "v3")
|
|
_casbinRule.V4 = field.NewString(tableName, "v4")
|
|
_casbinRule.V5 = field.NewString(tableName, "v5")
|
|
|
|
_casbinRule.fillFieldMap()
|
|
|
|
return _casbinRule
|
|
}
|
|
|
|
type casbinRule struct {
|
|
casbinRuleDo casbinRuleDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Uint64
|
|
Ptype field.String
|
|
V0 field.String
|
|
V1 field.String
|
|
V2 field.String
|
|
V3 field.String
|
|
V4 field.String
|
|
V5 field.String
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (c casbinRule) Table(newTableName string) *casbinRule {
|
|
c.casbinRuleDo.UseTable(newTableName)
|
|
return c.updateTableName(newTableName)
|
|
}
|
|
|
|
func (c casbinRule) As(alias string) *casbinRule {
|
|
c.casbinRuleDo.DO = *(c.casbinRuleDo.As(alias).(*gen.DO))
|
|
return c.updateTableName(alias)
|
|
}
|
|
|
|
func (c *casbinRule) updateTableName(table string) *casbinRule {
|
|
c.ALL = field.NewAsterisk(table)
|
|
c.ID = field.NewUint64(table, "id")
|
|
c.Ptype = field.NewString(table, "ptype")
|
|
c.V0 = field.NewString(table, "v0")
|
|
c.V1 = field.NewString(table, "v1")
|
|
c.V2 = field.NewString(table, "v2")
|
|
c.V3 = field.NewString(table, "v3")
|
|
c.V4 = field.NewString(table, "v4")
|
|
c.V5 = field.NewString(table, "v5")
|
|
|
|
c.fillFieldMap()
|
|
|
|
return c
|
|
}
|
|
|
|
func (c *casbinRule) WithContext(ctx context.Context) ICasbinRuleDo {
|
|
return c.casbinRuleDo.WithContext(ctx)
|
|
}
|
|
|
|
func (c casbinRule) TableName() string { return c.casbinRuleDo.TableName() }
|
|
|
|
func (c casbinRule) Alias() string { return c.casbinRuleDo.Alias() }
|
|
|
|
func (c *casbinRule) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
_f, ok := c.fieldMap[fieldName]
|
|
if !ok || _f == nil {
|
|
return nil, false
|
|
}
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
return _oe, ok
|
|
}
|
|
|
|
func (c *casbinRule) fillFieldMap() {
|
|
c.fieldMap = make(map[string]field.Expr, 8)
|
|
c.fieldMap["id"] = c.ID
|
|
c.fieldMap["ptype"] = c.Ptype
|
|
c.fieldMap["v0"] = c.V0
|
|
c.fieldMap["v1"] = c.V1
|
|
c.fieldMap["v2"] = c.V2
|
|
c.fieldMap["v3"] = c.V3
|
|
c.fieldMap["v4"] = c.V4
|
|
c.fieldMap["v5"] = c.V5
|
|
}
|
|
|
|
func (c casbinRule) clone(db *gorm.DB) casbinRule {
|
|
c.casbinRuleDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return c
|
|
}
|
|
|
|
func (c casbinRule) replaceDB(db *gorm.DB) casbinRule {
|
|
c.casbinRuleDo.ReplaceDB(db)
|
|
return c
|
|
}
|
|
|
|
type casbinRuleDo struct{ gen.DO }
|
|
|
|
type ICasbinRuleDo interface {
|
|
gen.SubQuery
|
|
Debug() ICasbinRuleDo
|
|
WithContext(ctx context.Context) ICasbinRuleDo
|
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
|
ReplaceDB(db *gorm.DB)
|
|
ReadDB() ICasbinRuleDo
|
|
WriteDB() ICasbinRuleDo
|
|
As(alias string) gen.Dao
|
|
Session(config *gorm.Session) ICasbinRuleDo
|
|
Columns(cols ...field.Expr) gen.Columns
|
|
Clauses(conds ...clause.Expression) ICasbinRuleDo
|
|
Not(conds ...gen.Condition) ICasbinRuleDo
|
|
Or(conds ...gen.Condition) ICasbinRuleDo
|
|
Select(conds ...field.Expr) ICasbinRuleDo
|
|
Where(conds ...gen.Condition) ICasbinRuleDo
|
|
Order(conds ...field.Expr) ICasbinRuleDo
|
|
Distinct(cols ...field.Expr) ICasbinRuleDo
|
|
Omit(cols ...field.Expr) ICasbinRuleDo
|
|
Join(table schema.Tabler, on ...field.Expr) ICasbinRuleDo
|
|
LeftJoin(table schema.Tabler, on ...field.Expr) ICasbinRuleDo
|
|
RightJoin(table schema.Tabler, on ...field.Expr) ICasbinRuleDo
|
|
Group(cols ...field.Expr) ICasbinRuleDo
|
|
Having(conds ...gen.Condition) ICasbinRuleDo
|
|
Limit(limit int) ICasbinRuleDo
|
|
Offset(offset int) ICasbinRuleDo
|
|
Count() (count int64, err error)
|
|
Scopes(funcs ...func(gen.Dao) gen.Dao) ICasbinRuleDo
|
|
Unscoped() ICasbinRuleDo
|
|
Create(values ...*models.CasbinRule) error
|
|
CreateInBatches(values []*models.CasbinRule, batchSize int) error
|
|
Save(values ...*models.CasbinRule) error
|
|
First() (*models.CasbinRule, error)
|
|
Take() (*models.CasbinRule, error)
|
|
Last() (*models.CasbinRule, error)
|
|
Find() ([]*models.CasbinRule, error)
|
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.CasbinRule, err error)
|
|
FindInBatches(result *[]*models.CasbinRule, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
|
Pluck(column field.Expr, dest interface{}) error
|
|
Delete(...*models.CasbinRule) (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) ICasbinRuleDo
|
|
Assign(attrs ...field.AssignExpr) ICasbinRuleDo
|
|
Joins(fields ...field.RelationField) ICasbinRuleDo
|
|
Preload(fields ...field.RelationField) ICasbinRuleDo
|
|
FirstOrInit() (*models.CasbinRule, error)
|
|
FirstOrCreate() (*models.CasbinRule, error)
|
|
FindByPage(offset int, limit int) (result []*models.CasbinRule, 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) ICasbinRuleDo
|
|
UnderlyingDB() *gorm.DB
|
|
schema.Tabler
|
|
}
|
|
|
|
func (c casbinRuleDo) Debug() ICasbinRuleDo {
|
|
return c.withDO(c.DO.Debug())
|
|
}
|
|
|
|
func (c casbinRuleDo) WithContext(ctx context.Context) ICasbinRuleDo {
|
|
return c.withDO(c.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (c casbinRuleDo) ReadDB() ICasbinRuleDo {
|
|
return c.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (c casbinRuleDo) WriteDB() ICasbinRuleDo {
|
|
return c.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (c casbinRuleDo) Session(config *gorm.Session) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Session(config))
|
|
}
|
|
|
|
func (c casbinRuleDo) Clauses(conds ...clause.Expression) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (c casbinRuleDo) Returning(value interface{}, columns ...string) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (c casbinRuleDo) Not(conds ...gen.Condition) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Not(conds...))
|
|
}
|
|
|
|
func (c casbinRuleDo) Or(conds ...gen.Condition) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Or(conds...))
|
|
}
|
|
|
|
func (c casbinRuleDo) Select(conds ...field.Expr) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Select(conds...))
|
|
}
|
|
|
|
func (c casbinRuleDo) Where(conds ...gen.Condition) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Where(conds...))
|
|
}
|
|
|
|
func (c casbinRuleDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) ICasbinRuleDo {
|
|
return c.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
}
|
|
|
|
func (c casbinRuleDo) Order(conds ...field.Expr) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Order(conds...))
|
|
}
|
|
|
|
func (c casbinRuleDo) Distinct(cols ...field.Expr) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (c casbinRuleDo) Omit(cols ...field.Expr) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Omit(cols...))
|
|
}
|
|
|
|
func (c casbinRuleDo) Join(table schema.Tabler, on ...field.Expr) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Join(table, on...))
|
|
}
|
|
|
|
func (c casbinRuleDo) LeftJoin(table schema.Tabler, on ...field.Expr) ICasbinRuleDo {
|
|
return c.withDO(c.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (c casbinRuleDo) RightJoin(table schema.Tabler, on ...field.Expr) ICasbinRuleDo {
|
|
return c.withDO(c.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (c casbinRuleDo) Group(cols ...field.Expr) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Group(cols...))
|
|
}
|
|
|
|
func (c casbinRuleDo) Having(conds ...gen.Condition) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Having(conds...))
|
|
}
|
|
|
|
func (c casbinRuleDo) Limit(limit int) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Limit(limit))
|
|
}
|
|
|
|
func (c casbinRuleDo) Offset(offset int) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Offset(offset))
|
|
}
|
|
|
|
func (c casbinRuleDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (c casbinRuleDo) Unscoped() ICasbinRuleDo {
|
|
return c.withDO(c.DO.Unscoped())
|
|
}
|
|
|
|
func (c casbinRuleDo) Create(values ...*models.CasbinRule) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return c.DO.Create(values)
|
|
}
|
|
|
|
func (c casbinRuleDo) CreateInBatches(values []*models.CasbinRule, batchSize int) error {
|
|
return c.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 (c casbinRuleDo) Save(values ...*models.CasbinRule) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return c.DO.Save(values)
|
|
}
|
|
|
|
func (c casbinRuleDo) First() (*models.CasbinRule, error) {
|
|
if result, err := c.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.CasbinRule), nil
|
|
}
|
|
}
|
|
|
|
func (c casbinRuleDo) Take() (*models.CasbinRule, error) {
|
|
if result, err := c.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.CasbinRule), nil
|
|
}
|
|
}
|
|
|
|
func (c casbinRuleDo) Last() (*models.CasbinRule, error) {
|
|
if result, err := c.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.CasbinRule), nil
|
|
}
|
|
}
|
|
|
|
func (c casbinRuleDo) Find() ([]*models.CasbinRule, error) {
|
|
result, err := c.DO.Find()
|
|
return result.([]*models.CasbinRule), err
|
|
}
|
|
|
|
func (c casbinRuleDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.CasbinRule, err error) {
|
|
buf := make([]*models.CasbinRule, 0, batchSize)
|
|
err = c.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 (c casbinRuleDo) FindInBatches(result *[]*models.CasbinRule, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return c.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (c casbinRuleDo) Attrs(attrs ...field.AssignExpr) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (c casbinRuleDo) Assign(attrs ...field.AssignExpr) ICasbinRuleDo {
|
|
return c.withDO(c.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (c casbinRuleDo) Joins(fields ...field.RelationField) ICasbinRuleDo {
|
|
for _, _f := range fields {
|
|
c = *c.withDO(c.DO.Joins(_f))
|
|
}
|
|
return &c
|
|
}
|
|
|
|
func (c casbinRuleDo) Preload(fields ...field.RelationField) ICasbinRuleDo {
|
|
for _, _f := range fields {
|
|
c = *c.withDO(c.DO.Preload(_f))
|
|
}
|
|
return &c
|
|
}
|
|
|
|
func (c casbinRuleDo) FirstOrInit() (*models.CasbinRule, error) {
|
|
if result, err := c.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.CasbinRule), nil
|
|
}
|
|
}
|
|
|
|
func (c casbinRuleDo) FirstOrCreate() (*models.CasbinRule, error) {
|
|
if result, err := c.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.CasbinRule), nil
|
|
}
|
|
}
|
|
|
|
func (c casbinRuleDo) FindByPage(offset int, limit int) (result []*models.CasbinRule, count int64, err error) {
|
|
result, err = c.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 = c.Offset(-1).Limit(-1).Count()
|
|
return
|
|
}
|
|
|
|
func (c casbinRuleDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
count, err = c.Count()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = c.Offset(offset).Limit(limit).Scan(result)
|
|
return
|
|
}
|
|
|
|
func (c casbinRuleDo) Scan(result interface{}) (err error) {
|
|
return c.DO.Scan(result)
|
|
}
|
|
|
|
func (c casbinRuleDo) Delete(models ...*models.CasbinRule) (result gen.ResultInfo, err error) {
|
|
return c.DO.Delete(models)
|
|
}
|
|
|
|
func (c *casbinRuleDo) withDO(do gen.Dao) *casbinRuleDo {
|
|
c.DO = *do.(*gen.DO)
|
|
return c
|
|
}
|