336 lines
8.7 KiB
Go
336 lines
8.7 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 queries
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
"gorm.io/gorm/schema"
|
|
|
|
"gorm.io/gen"
|
|
"gorm.io/gen/field"
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
"platform/web/models"
|
|
)
|
|
|
|
func newResourcePps(db *gorm.DB, opts ...gen.DOOption) resourcePps {
|
|
_resourcePps := resourcePps{}
|
|
|
|
_resourcePps.resourcePpsDo.UseDB(db, opts...)
|
|
_resourcePps.resourcePpsDo.UseModel(&models.ResourcePps{})
|
|
|
|
tableName := _resourcePps.resourcePpsDo.TableName()
|
|
_resourcePps.ALL = field.NewAsterisk(tableName)
|
|
_resourcePps.ID = field.NewInt32(tableName, "id")
|
|
_resourcePps.ResourceID = field.NewInt32(tableName, "resource_id")
|
|
_resourcePps.CreatedAt = field.NewField(tableName, "created_at")
|
|
_resourcePps.UpdatedAt = field.NewField(tableName, "updated_at")
|
|
_resourcePps.DeletedAt = field.NewField(tableName, "deleted_at")
|
|
|
|
_resourcePps.fillFieldMap()
|
|
|
|
return _resourcePps
|
|
}
|
|
|
|
type resourcePps struct {
|
|
resourcePpsDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int32 // ID
|
|
ResourceID field.Int32 // 套餐ID
|
|
CreatedAt field.Field // 创建时间
|
|
UpdatedAt field.Field // 更新时间
|
|
DeletedAt field.Field // 删除时间
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (r resourcePps) Table(newTableName string) *resourcePps {
|
|
r.resourcePpsDo.UseTable(newTableName)
|
|
return r.updateTableName(newTableName)
|
|
}
|
|
|
|
func (r resourcePps) As(alias string) *resourcePps {
|
|
r.resourcePpsDo.DO = *(r.resourcePpsDo.As(alias).(*gen.DO))
|
|
return r.updateTableName(alias)
|
|
}
|
|
|
|
func (r *resourcePps) updateTableName(table string) *resourcePps {
|
|
r.ALL = field.NewAsterisk(table)
|
|
r.ID = field.NewInt32(table, "id")
|
|
r.ResourceID = field.NewInt32(table, "resource_id")
|
|
r.CreatedAt = field.NewField(table, "created_at")
|
|
r.UpdatedAt = field.NewField(table, "updated_at")
|
|
r.DeletedAt = field.NewField(table, "deleted_at")
|
|
|
|
r.fillFieldMap()
|
|
|
|
return r
|
|
}
|
|
|
|
func (r *resourcePps) 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 *resourcePps) fillFieldMap() {
|
|
r.fieldMap = make(map[string]field.Expr, 5)
|
|
r.fieldMap["id"] = r.ID
|
|
r.fieldMap["resource_id"] = r.ResourceID
|
|
r.fieldMap["created_at"] = r.CreatedAt
|
|
r.fieldMap["updated_at"] = r.UpdatedAt
|
|
r.fieldMap["deleted_at"] = r.DeletedAt
|
|
}
|
|
|
|
func (r resourcePps) clone(db *gorm.DB) resourcePps {
|
|
r.resourcePpsDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return r
|
|
}
|
|
|
|
func (r resourcePps) replaceDB(db *gorm.DB) resourcePps {
|
|
r.resourcePpsDo.ReplaceDB(db)
|
|
return r
|
|
}
|
|
|
|
type resourcePpsDo struct{ gen.DO }
|
|
|
|
func (r resourcePpsDo) Debug() *resourcePpsDo {
|
|
return r.withDO(r.DO.Debug())
|
|
}
|
|
|
|
func (r resourcePpsDo) WithContext(ctx context.Context) *resourcePpsDo {
|
|
return r.withDO(r.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (r resourcePpsDo) ReadDB() *resourcePpsDo {
|
|
return r.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (r resourcePpsDo) WriteDB() *resourcePpsDo {
|
|
return r.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (r resourcePpsDo) Session(config *gorm.Session) *resourcePpsDo {
|
|
return r.withDO(r.DO.Session(config))
|
|
}
|
|
|
|
func (r resourcePpsDo) Clauses(conds ...clause.Expression) *resourcePpsDo {
|
|
return r.withDO(r.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (r resourcePpsDo) Returning(value interface{}, columns ...string) *resourcePpsDo {
|
|
return r.withDO(r.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (r resourcePpsDo) Not(conds ...gen.Condition) *resourcePpsDo {
|
|
return r.withDO(r.DO.Not(conds...))
|
|
}
|
|
|
|
func (r resourcePpsDo) Or(conds ...gen.Condition) *resourcePpsDo {
|
|
return r.withDO(r.DO.Or(conds...))
|
|
}
|
|
|
|
func (r resourcePpsDo) Select(conds ...field.Expr) *resourcePpsDo {
|
|
return r.withDO(r.DO.Select(conds...))
|
|
}
|
|
|
|
func (r resourcePpsDo) Where(conds ...gen.Condition) *resourcePpsDo {
|
|
return r.withDO(r.DO.Where(conds...))
|
|
}
|
|
|
|
func (r resourcePpsDo) Order(conds ...field.Expr) *resourcePpsDo {
|
|
return r.withDO(r.DO.Order(conds...))
|
|
}
|
|
|
|
func (r resourcePpsDo) Distinct(cols ...field.Expr) *resourcePpsDo {
|
|
return r.withDO(r.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (r resourcePpsDo) Omit(cols ...field.Expr) *resourcePpsDo {
|
|
return r.withDO(r.DO.Omit(cols...))
|
|
}
|
|
|
|
func (r resourcePpsDo) Join(table schema.Tabler, on ...field.Expr) *resourcePpsDo {
|
|
return r.withDO(r.DO.Join(table, on...))
|
|
}
|
|
|
|
func (r resourcePpsDo) LeftJoin(table schema.Tabler, on ...field.Expr) *resourcePpsDo {
|
|
return r.withDO(r.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (r resourcePpsDo) RightJoin(table schema.Tabler, on ...field.Expr) *resourcePpsDo {
|
|
return r.withDO(r.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (r resourcePpsDo) Group(cols ...field.Expr) *resourcePpsDo {
|
|
return r.withDO(r.DO.Group(cols...))
|
|
}
|
|
|
|
func (r resourcePpsDo) Having(conds ...gen.Condition) *resourcePpsDo {
|
|
return r.withDO(r.DO.Having(conds...))
|
|
}
|
|
|
|
func (r resourcePpsDo) Limit(limit int) *resourcePpsDo {
|
|
return r.withDO(r.DO.Limit(limit))
|
|
}
|
|
|
|
func (r resourcePpsDo) Offset(offset int) *resourcePpsDo {
|
|
return r.withDO(r.DO.Offset(offset))
|
|
}
|
|
|
|
func (r resourcePpsDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *resourcePpsDo {
|
|
return r.withDO(r.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (r resourcePpsDo) Unscoped() *resourcePpsDo {
|
|
return r.withDO(r.DO.Unscoped())
|
|
}
|
|
|
|
func (r resourcePpsDo) Create(values ...*models.ResourcePps) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return r.DO.Create(values)
|
|
}
|
|
|
|
func (r resourcePpsDo) CreateInBatches(values []*models.ResourcePps, 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 resourcePpsDo) Save(values ...*models.ResourcePps) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return r.DO.Save(values)
|
|
}
|
|
|
|
func (r resourcePpsDo) First() (*models.ResourcePps, error) {
|
|
if result, err := r.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.ResourcePps), nil
|
|
}
|
|
}
|
|
|
|
func (r resourcePpsDo) Take() (*models.ResourcePps, error) {
|
|
if result, err := r.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.ResourcePps), nil
|
|
}
|
|
}
|
|
|
|
func (r resourcePpsDo) Last() (*models.ResourcePps, error) {
|
|
if result, err := r.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.ResourcePps), nil
|
|
}
|
|
}
|
|
|
|
func (r resourcePpsDo) Find() ([]*models.ResourcePps, error) {
|
|
result, err := r.DO.Find()
|
|
return result.([]*models.ResourcePps), err
|
|
}
|
|
|
|
func (r resourcePpsDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.ResourcePps, err error) {
|
|
buf := make([]*models.ResourcePps, 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 resourcePpsDo) FindInBatches(result *[]*models.ResourcePps, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return r.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (r resourcePpsDo) Attrs(attrs ...field.AssignExpr) *resourcePpsDo {
|
|
return r.withDO(r.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (r resourcePpsDo) Assign(attrs ...field.AssignExpr) *resourcePpsDo {
|
|
return r.withDO(r.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (r resourcePpsDo) Joins(fields ...field.RelationField) *resourcePpsDo {
|
|
for _, _f := range fields {
|
|
r = *r.withDO(r.DO.Joins(_f))
|
|
}
|
|
return &r
|
|
}
|
|
|
|
func (r resourcePpsDo) Preload(fields ...field.RelationField) *resourcePpsDo {
|
|
for _, _f := range fields {
|
|
r = *r.withDO(r.DO.Preload(_f))
|
|
}
|
|
return &r
|
|
}
|
|
|
|
func (r resourcePpsDo) FirstOrInit() (*models.ResourcePps, error) {
|
|
if result, err := r.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.ResourcePps), nil
|
|
}
|
|
}
|
|
|
|
func (r resourcePpsDo) FirstOrCreate() (*models.ResourcePps, error) {
|
|
if result, err := r.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.ResourcePps), nil
|
|
}
|
|
}
|
|
|
|
func (r resourcePpsDo) FindByPage(offset int, limit int) (result []*models.ResourcePps, 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 resourcePpsDo) 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 resourcePpsDo) Scan(result interface{}) (err error) {
|
|
return r.DO.Scan(result)
|
|
}
|
|
|
|
func (r resourcePpsDo) Delete(models ...*models.ResourcePps) (result gen.ResultInfo, err error) {
|
|
return r.DO.Delete(models)
|
|
}
|
|
|
|
func (r *resourcePpsDo) withDO(do gen.Dao) *resourcePpsDo {
|
|
r.DO = *do.(*gen.DO)
|
|
return r
|
|
}
|