393 lines
11 KiB
Go
393 lines
11 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 dbquery
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"gorm.io/gorm"
|
||
|
"gorm.io/gorm/clause"
|
||
|
"gorm.io/gorm/schema"
|
||
|
|
||
|
"gorm.io/gen"
|
||
|
"gorm.io/gen/field"
|
||
|
|
||
|
"gorm.io/plugin/dbresolver"
|
||
|
|
||
|
"joylink.club/bj-rtsts-server/db/model"
|
||
|
)
|
||
|
|
||
|
func newAuthAPIPath(db *gorm.DB, opts ...gen.DOOption) authAPIPath {
|
||
|
_authAPIPath := authAPIPath{}
|
||
|
|
||
|
_authAPIPath.authAPIPathDo.UseDB(db, opts...)
|
||
|
_authAPIPath.authAPIPathDo.UseModel(&model.AuthAPIPath{})
|
||
|
|
||
|
tableName := _authAPIPath.authAPIPathDo.TableName()
|
||
|
_authAPIPath.ALL = field.NewAsterisk(tableName)
|
||
|
_authAPIPath.ID = field.NewInt32(tableName, "id")
|
||
|
_authAPIPath.Name = field.NewString(tableName, "name")
|
||
|
_authAPIPath.Path = field.NewString(tableName, "path")
|
||
|
_authAPIPath.Method = field.NewString(tableName, "method")
|
||
|
|
||
|
_authAPIPath.fillFieldMap()
|
||
|
|
||
|
return _authAPIPath
|
||
|
}
|
||
|
|
||
|
type authAPIPath struct {
|
||
|
authAPIPathDo
|
||
|
|
||
|
ALL field.Asterisk
|
||
|
ID field.Int32 // 主键
|
||
|
Name field.String // 功能名称
|
||
|
Path field.String // 请求路径
|
||
|
Method field.String // 请求方式
|
||
|
|
||
|
fieldMap map[string]field.Expr
|
||
|
}
|
||
|
|
||
|
func (a authAPIPath) Table(newTableName string) *authAPIPath {
|
||
|
a.authAPIPathDo.UseTable(newTableName)
|
||
|
return a.updateTableName(newTableName)
|
||
|
}
|
||
|
|
||
|
func (a authAPIPath) As(alias string) *authAPIPath {
|
||
|
a.authAPIPathDo.DO = *(a.authAPIPathDo.As(alias).(*gen.DO))
|
||
|
return a.updateTableName(alias)
|
||
|
}
|
||
|
|
||
|
func (a *authAPIPath) updateTableName(table string) *authAPIPath {
|
||
|
a.ALL = field.NewAsterisk(table)
|
||
|
a.ID = field.NewInt32(table, "id")
|
||
|
a.Name = field.NewString(table, "name")
|
||
|
a.Path = field.NewString(table, "path")
|
||
|
a.Method = field.NewString(table, "method")
|
||
|
|
||
|
a.fillFieldMap()
|
||
|
|
||
|
return a
|
||
|
}
|
||
|
|
||
|
func (a *authAPIPath) 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 *authAPIPath) fillFieldMap() {
|
||
|
a.fieldMap = make(map[string]field.Expr, 4)
|
||
|
a.fieldMap["id"] = a.ID
|
||
|
a.fieldMap["name"] = a.Name
|
||
|
a.fieldMap["path"] = a.Path
|
||
|
a.fieldMap["method"] = a.Method
|
||
|
}
|
||
|
|
||
|
func (a authAPIPath) clone(db *gorm.DB) authAPIPath {
|
||
|
a.authAPIPathDo.ReplaceConnPool(db.Statement.ConnPool)
|
||
|
return a
|
||
|
}
|
||
|
|
||
|
func (a authAPIPath) replaceDB(db *gorm.DB) authAPIPath {
|
||
|
a.authAPIPathDo.ReplaceDB(db)
|
||
|
return a
|
||
|
}
|
||
|
|
||
|
type authAPIPathDo struct{ gen.DO }
|
||
|
|
||
|
type IAuthAPIPathDo interface {
|
||
|
gen.SubQuery
|
||
|
Debug() IAuthAPIPathDo
|
||
|
WithContext(ctx context.Context) IAuthAPIPathDo
|
||
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||
|
ReplaceDB(db *gorm.DB)
|
||
|
ReadDB() IAuthAPIPathDo
|
||
|
WriteDB() IAuthAPIPathDo
|
||
|
As(alias string) gen.Dao
|
||
|
Session(config *gorm.Session) IAuthAPIPathDo
|
||
|
Columns(cols ...field.Expr) gen.Columns
|
||
|
Clauses(conds ...clause.Expression) IAuthAPIPathDo
|
||
|
Not(conds ...gen.Condition) IAuthAPIPathDo
|
||
|
Or(conds ...gen.Condition) IAuthAPIPathDo
|
||
|
Select(conds ...field.Expr) IAuthAPIPathDo
|
||
|
Where(conds ...gen.Condition) IAuthAPIPathDo
|
||
|
Order(conds ...field.Expr) IAuthAPIPathDo
|
||
|
Distinct(cols ...field.Expr) IAuthAPIPathDo
|
||
|
Omit(cols ...field.Expr) IAuthAPIPathDo
|
||
|
Join(table schema.Tabler, on ...field.Expr) IAuthAPIPathDo
|
||
|
LeftJoin(table schema.Tabler, on ...field.Expr) IAuthAPIPathDo
|
||
|
RightJoin(table schema.Tabler, on ...field.Expr) IAuthAPIPathDo
|
||
|
Group(cols ...field.Expr) IAuthAPIPathDo
|
||
|
Having(conds ...gen.Condition) IAuthAPIPathDo
|
||
|
Limit(limit int) IAuthAPIPathDo
|
||
|
Offset(offset int) IAuthAPIPathDo
|
||
|
Count() (count int64, err error)
|
||
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IAuthAPIPathDo
|
||
|
Unscoped() IAuthAPIPathDo
|
||
|
Create(values ...*model.AuthAPIPath) error
|
||
|
CreateInBatches(values []*model.AuthAPIPath, batchSize int) error
|
||
|
Save(values ...*model.AuthAPIPath) error
|
||
|
First() (*model.AuthAPIPath, error)
|
||
|
Take() (*model.AuthAPIPath, error)
|
||
|
Last() (*model.AuthAPIPath, error)
|
||
|
Find() ([]*model.AuthAPIPath, error)
|
||
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AuthAPIPath, err error)
|
||
|
FindInBatches(result *[]*model.AuthAPIPath, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||
|
Pluck(column field.Expr, dest interface{}) error
|
||
|
Delete(...*model.AuthAPIPath) (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) IAuthAPIPathDo
|
||
|
Assign(attrs ...field.AssignExpr) IAuthAPIPathDo
|
||
|
Joins(fields ...field.RelationField) IAuthAPIPathDo
|
||
|
Preload(fields ...field.RelationField) IAuthAPIPathDo
|
||
|
FirstOrInit() (*model.AuthAPIPath, error)
|
||
|
FirstOrCreate() (*model.AuthAPIPath, error)
|
||
|
FindByPage(offset int, limit int) (result []*model.AuthAPIPath, 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) IAuthAPIPathDo
|
||
|
UnderlyingDB() *gorm.DB
|
||
|
schema.Tabler
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Debug() IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Debug())
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) WithContext(ctx context.Context) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.WithContext(ctx))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) ReadDB() IAuthAPIPathDo {
|
||
|
return a.Clauses(dbresolver.Read)
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) WriteDB() IAuthAPIPathDo {
|
||
|
return a.Clauses(dbresolver.Write)
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Session(config *gorm.Session) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Session(config))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Clauses(conds ...clause.Expression) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Clauses(conds...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Returning(value interface{}, columns ...string) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Returning(value, columns...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Not(conds ...gen.Condition) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Not(conds...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Or(conds ...gen.Condition) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Or(conds...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Select(conds ...field.Expr) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Select(conds...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Where(conds ...gen.Condition) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Where(conds...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Order(conds ...field.Expr) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Order(conds...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Distinct(cols ...field.Expr) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Distinct(cols...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Omit(cols ...field.Expr) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Omit(cols...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Join(table schema.Tabler, on ...field.Expr) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Join(table, on...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.LeftJoin(table, on...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) RightJoin(table schema.Tabler, on ...field.Expr) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.RightJoin(table, on...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Group(cols ...field.Expr) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Group(cols...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Having(conds ...gen.Condition) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Having(conds...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Limit(limit int) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Limit(limit))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Offset(offset int) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Offset(offset))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Scopes(funcs...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Unscoped() IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Unscoped())
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Create(values ...*model.AuthAPIPath) error {
|
||
|
if len(values) == 0 {
|
||
|
return nil
|
||
|
}
|
||
|
return a.DO.Create(values)
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) CreateInBatches(values []*model.AuthAPIPath, 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 authAPIPathDo) Save(values ...*model.AuthAPIPath) error {
|
||
|
if len(values) == 0 {
|
||
|
return nil
|
||
|
}
|
||
|
return a.DO.Save(values)
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) First() (*model.AuthAPIPath, error) {
|
||
|
if result, err := a.DO.First(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*model.AuthAPIPath), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Take() (*model.AuthAPIPath, error) {
|
||
|
if result, err := a.DO.Take(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*model.AuthAPIPath), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Last() (*model.AuthAPIPath, error) {
|
||
|
if result, err := a.DO.Last(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*model.AuthAPIPath), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Find() ([]*model.AuthAPIPath, error) {
|
||
|
result, err := a.DO.Find()
|
||
|
return result.([]*model.AuthAPIPath), err
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AuthAPIPath, err error) {
|
||
|
buf := make([]*model.AuthAPIPath, 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 authAPIPathDo) FindInBatches(result *[]*model.AuthAPIPath, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||
|
return a.DO.FindInBatches(result, batchSize, fc)
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Attrs(attrs ...field.AssignExpr) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Attrs(attrs...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Assign(attrs ...field.AssignExpr) IAuthAPIPathDo {
|
||
|
return a.withDO(a.DO.Assign(attrs...))
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Joins(fields ...field.RelationField) IAuthAPIPathDo {
|
||
|
for _, _f := range fields {
|
||
|
a = *a.withDO(a.DO.Joins(_f))
|
||
|
}
|
||
|
return &a
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Preload(fields ...field.RelationField) IAuthAPIPathDo {
|
||
|
for _, _f := range fields {
|
||
|
a = *a.withDO(a.DO.Preload(_f))
|
||
|
}
|
||
|
return &a
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) FirstOrInit() (*model.AuthAPIPath, error) {
|
||
|
if result, err := a.DO.FirstOrInit(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*model.AuthAPIPath), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) FirstOrCreate() (*model.AuthAPIPath, error) {
|
||
|
if result, err := a.DO.FirstOrCreate(); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return result.(*model.AuthAPIPath), nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) FindByPage(offset int, limit int) (result []*model.AuthAPIPath, 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 authAPIPathDo) ScanByPage(result interface{}, 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 authAPIPathDo) Scan(result interface{}) (err error) {
|
||
|
return a.DO.Scan(result)
|
||
|
}
|
||
|
|
||
|
func (a authAPIPathDo) Delete(models ...*model.AuthAPIPath) (result gen.ResultInfo, err error) {
|
||
|
return a.DO.Delete(models)
|
||
|
}
|
||
|
|
||
|
func (a *authAPIPathDo) withDO(do gen.Dao) *authAPIPathDo {
|
||
|
a.DO = *do.(*gen.DO)
|
||
|
return a
|
||
|
}
|