draft grpc
This commit is contained in:
437
internal/database/query/ad_templates.gen.go
Normal file
437
internal/database/query/ad_templates.gen.go
Normal file
@@ -0,0 +1,437 @@
|
||||
// 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"
|
||||
"database/sql"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"stream.api/internal/database/model"
|
||||
)
|
||||
|
||||
func newAdTemplate(db *gorm.DB, opts ...gen.DOOption) adTemplate {
|
||||
_adTemplate := adTemplate{}
|
||||
|
||||
_adTemplate.adTemplateDo.UseDB(db, opts...)
|
||||
_adTemplate.adTemplateDo.UseModel(&model.AdTemplate{})
|
||||
|
||||
tableName := _adTemplate.adTemplateDo.TableName()
|
||||
_adTemplate.ALL = field.NewAsterisk(tableName)
|
||||
_adTemplate.ID = field.NewString(tableName, "id")
|
||||
_adTemplate.UserID = field.NewString(tableName, "user_id")
|
||||
_adTemplate.Name = field.NewString(tableName, "name")
|
||||
_adTemplate.Description = field.NewString(tableName, "description")
|
||||
_adTemplate.VastTagURL = field.NewString(tableName, "vast_tag_url")
|
||||
_adTemplate.AdFormat = field.NewString(tableName, "ad_format")
|
||||
_adTemplate.Duration = field.NewInt64(tableName, "duration")
|
||||
_adTemplate.IsActive = field.NewBool(tableName, "is_active")
|
||||
_adTemplate.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_adTemplate.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_adTemplate.IsDefault = field.NewBool(tableName, "is_default")
|
||||
_adTemplate.Version = field.NewInt64(tableName, "version")
|
||||
|
||||
_adTemplate.fillFieldMap()
|
||||
|
||||
return _adTemplate
|
||||
}
|
||||
|
||||
type adTemplate struct {
|
||||
adTemplateDo adTemplateDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.String
|
||||
UserID field.String
|
||||
Name field.String
|
||||
Description field.String
|
||||
VastTagURL field.String
|
||||
AdFormat field.String
|
||||
Duration field.Int64
|
||||
IsActive field.Bool
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
IsDefault field.Bool
|
||||
Version field.Int64
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (a adTemplate) Table(newTableName string) *adTemplate {
|
||||
a.adTemplateDo.UseTable(newTableName)
|
||||
return a.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (a adTemplate) As(alias string) *adTemplate {
|
||||
a.adTemplateDo.DO = *(a.adTemplateDo.As(alias).(*gen.DO))
|
||||
return a.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (a *adTemplate) updateTableName(table string) *adTemplate {
|
||||
a.ALL = field.NewAsterisk(table)
|
||||
a.ID = field.NewString(table, "id")
|
||||
a.UserID = field.NewString(table, "user_id")
|
||||
a.Name = field.NewString(table, "name")
|
||||
a.Description = field.NewString(table, "description")
|
||||
a.VastTagURL = field.NewString(table, "vast_tag_url")
|
||||
a.AdFormat = field.NewString(table, "ad_format")
|
||||
a.Duration = field.NewInt64(table, "duration")
|
||||
a.IsActive = field.NewBool(table, "is_active")
|
||||
a.CreatedAt = field.NewTime(table, "created_at")
|
||||
a.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
a.IsDefault = field.NewBool(table, "is_default")
|
||||
a.Version = field.NewInt64(table, "version")
|
||||
|
||||
a.fillFieldMap()
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *adTemplate) WithContext(ctx context.Context) IAdTemplateDo {
|
||||
return a.adTemplateDo.WithContext(ctx)
|
||||
}
|
||||
|
||||
func (a adTemplate) TableName() string { return a.adTemplateDo.TableName() }
|
||||
|
||||
func (a adTemplate) Alias() string { return a.adTemplateDo.Alias() }
|
||||
|
||||
func (a adTemplate) Columns(cols ...field.Expr) gen.Columns { return a.adTemplateDo.Columns(cols...) }
|
||||
|
||||
func (a *adTemplate) 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 *adTemplate) fillFieldMap() {
|
||||
a.fieldMap = make(map[string]field.Expr, 12)
|
||||
a.fieldMap["id"] = a.ID
|
||||
a.fieldMap["user_id"] = a.UserID
|
||||
a.fieldMap["name"] = a.Name
|
||||
a.fieldMap["description"] = a.Description
|
||||
a.fieldMap["vast_tag_url"] = a.VastTagURL
|
||||
a.fieldMap["ad_format"] = a.AdFormat
|
||||
a.fieldMap["duration"] = a.Duration
|
||||
a.fieldMap["is_active"] = a.IsActive
|
||||
a.fieldMap["created_at"] = a.CreatedAt
|
||||
a.fieldMap["updated_at"] = a.UpdatedAt
|
||||
a.fieldMap["is_default"] = a.IsDefault
|
||||
a.fieldMap["version"] = a.Version
|
||||
}
|
||||
|
||||
func (a adTemplate) clone(db *gorm.DB) adTemplate {
|
||||
a.adTemplateDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return a
|
||||
}
|
||||
|
||||
func (a adTemplate) replaceDB(db *gorm.DB) adTemplate {
|
||||
a.adTemplateDo.ReplaceDB(db)
|
||||
return a
|
||||
}
|
||||
|
||||
type adTemplateDo struct{ gen.DO }
|
||||
|
||||
type IAdTemplateDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IAdTemplateDo
|
||||
WithContext(ctx context.Context) IAdTemplateDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IAdTemplateDo
|
||||
WriteDB() IAdTemplateDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IAdTemplateDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IAdTemplateDo
|
||||
Not(conds ...gen.Condition) IAdTemplateDo
|
||||
Or(conds ...gen.Condition) IAdTemplateDo
|
||||
Select(conds ...field.Expr) IAdTemplateDo
|
||||
Where(conds ...gen.Condition) IAdTemplateDo
|
||||
Order(conds ...field.Expr) IAdTemplateDo
|
||||
Distinct(cols ...field.Expr) IAdTemplateDo
|
||||
Omit(cols ...field.Expr) IAdTemplateDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IAdTemplateDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IAdTemplateDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IAdTemplateDo
|
||||
Group(cols ...field.Expr) IAdTemplateDo
|
||||
Having(conds ...gen.Condition) IAdTemplateDo
|
||||
Limit(limit int) IAdTemplateDo
|
||||
Offset(offset int) IAdTemplateDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IAdTemplateDo
|
||||
Unscoped() IAdTemplateDo
|
||||
Create(values ...*model.AdTemplate) error
|
||||
CreateInBatches(values []*model.AdTemplate, batchSize int) error
|
||||
Save(values ...*model.AdTemplate) error
|
||||
First() (*model.AdTemplate, error)
|
||||
Take() (*model.AdTemplate, error)
|
||||
Last() (*model.AdTemplate, error)
|
||||
Find() ([]*model.AdTemplate, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AdTemplate, err error)
|
||||
FindInBatches(result *[]*model.AdTemplate, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.AdTemplate) (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) IAdTemplateDo
|
||||
Assign(attrs ...field.AssignExpr) IAdTemplateDo
|
||||
Joins(fields ...field.RelationField) IAdTemplateDo
|
||||
Preload(fields ...field.RelationField) IAdTemplateDo
|
||||
FirstOrInit() (*model.AdTemplate, error)
|
||||
FirstOrCreate() (*model.AdTemplate, error)
|
||||
FindByPage(offset int, limit int) (result []*model.AdTemplate, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Rows() (*sql.Rows, error)
|
||||
Row() *sql.Row
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IAdTemplateDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Debug() IAdTemplateDo {
|
||||
return a.withDO(a.DO.Debug())
|
||||
}
|
||||
|
||||
func (a adTemplateDo) WithContext(ctx context.Context) IAdTemplateDo {
|
||||
return a.withDO(a.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) ReadDB() IAdTemplateDo {
|
||||
return a.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (a adTemplateDo) WriteDB() IAdTemplateDo {
|
||||
return a.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Session(config *gorm.Session) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Session(config))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Clauses(conds ...clause.Expression) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Returning(value interface{}, columns ...string) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Not(conds ...gen.Condition) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Or(conds ...gen.Condition) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Select(conds ...field.Expr) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Where(conds ...gen.Condition) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Order(conds ...field.Expr) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Distinct(cols ...field.Expr) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Omit(cols ...field.Expr) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Join(table schema.Tabler, on ...field.Expr) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAdTemplateDo {
|
||||
return a.withDO(a.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) RightJoin(table schema.Tabler, on ...field.Expr) IAdTemplateDo {
|
||||
return a.withDO(a.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Group(cols ...field.Expr) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Having(conds ...gen.Condition) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Limit(limit int) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Offset(offset int) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Unscoped() IAdTemplateDo {
|
||||
return a.withDO(a.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Create(values ...*model.AdTemplate) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Create(values)
|
||||
}
|
||||
|
||||
func (a adTemplateDo) CreateInBatches(values []*model.AdTemplate, 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 adTemplateDo) Save(values ...*model.AdTemplate) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Save(values)
|
||||
}
|
||||
|
||||
func (a adTemplateDo) First() (*model.AdTemplate, error) {
|
||||
if result, err := a.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AdTemplate), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Take() (*model.AdTemplate, error) {
|
||||
if result, err := a.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AdTemplate), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Last() (*model.AdTemplate, error) {
|
||||
if result, err := a.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AdTemplate), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Find() ([]*model.AdTemplate, error) {
|
||||
result, err := a.DO.Find()
|
||||
return result.([]*model.AdTemplate), err
|
||||
}
|
||||
|
||||
func (a adTemplateDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AdTemplate, err error) {
|
||||
buf := make([]*model.AdTemplate, 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 adTemplateDo) FindInBatches(result *[]*model.AdTemplate, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return a.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Attrs(attrs ...field.AssignExpr) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Assign(attrs ...field.AssignExpr) IAdTemplateDo {
|
||||
return a.withDO(a.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Joins(fields ...field.RelationField) IAdTemplateDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Joins(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Preload(fields ...field.RelationField) IAdTemplateDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Preload(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a adTemplateDo) FirstOrInit() (*model.AdTemplate, error) {
|
||||
if result, err := a.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AdTemplate), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adTemplateDo) FirstOrCreate() (*model.AdTemplate, error) {
|
||||
if result, err := a.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AdTemplate), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adTemplateDo) FindByPage(offset int, limit int) (result []*model.AdTemplate, 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 adTemplateDo) 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 adTemplateDo) Scan(result interface{}) (err error) {
|
||||
return a.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (a adTemplateDo) Delete(models ...*model.AdTemplate) (result gen.ResultInfo, err error) {
|
||||
return a.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (a *adTemplateDo) withDO(do gen.Dao) *adTemplateDo {
|
||||
a.DO = *do.(*gen.DO)
|
||||
return a
|
||||
}
|
||||
411
internal/database/query/domains.gen.go
Normal file
411
internal/database/query/domains.gen.go
Normal file
@@ -0,0 +1,411 @@
|
||||
// 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"
|
||||
"database/sql"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"stream.api/internal/database/model"
|
||||
)
|
||||
|
||||
func newDomain(db *gorm.DB, opts ...gen.DOOption) domain {
|
||||
_domain := domain{}
|
||||
|
||||
_domain.domainDo.UseDB(db, opts...)
|
||||
_domain.domainDo.UseModel(&model.Domain{})
|
||||
|
||||
tableName := _domain.domainDo.TableName()
|
||||
_domain.ALL = field.NewAsterisk(tableName)
|
||||
_domain.ID = field.NewString(tableName, "id")
|
||||
_domain.UserID = field.NewString(tableName, "user_id")
|
||||
_domain.Name = field.NewString(tableName, "name")
|
||||
_domain.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_domain.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_domain.Version = field.NewInt64(tableName, "version")
|
||||
|
||||
_domain.fillFieldMap()
|
||||
|
||||
return _domain
|
||||
}
|
||||
|
||||
type domain struct {
|
||||
domainDo domainDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.String
|
||||
UserID field.String
|
||||
Name field.String
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
Version field.Int64
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (d domain) Table(newTableName string) *domain {
|
||||
d.domainDo.UseTable(newTableName)
|
||||
return d.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (d domain) As(alias string) *domain {
|
||||
d.domainDo.DO = *(d.domainDo.As(alias).(*gen.DO))
|
||||
return d.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (d *domain) updateTableName(table string) *domain {
|
||||
d.ALL = field.NewAsterisk(table)
|
||||
d.ID = field.NewString(table, "id")
|
||||
d.UserID = field.NewString(table, "user_id")
|
||||
d.Name = field.NewString(table, "name")
|
||||
d.CreatedAt = field.NewTime(table, "created_at")
|
||||
d.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
d.Version = field.NewInt64(table, "version")
|
||||
|
||||
d.fillFieldMap()
|
||||
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *domain) WithContext(ctx context.Context) IDomainDo { return d.domainDo.WithContext(ctx) }
|
||||
|
||||
func (d domain) TableName() string { return d.domainDo.TableName() }
|
||||
|
||||
func (d domain) Alias() string { return d.domainDo.Alias() }
|
||||
|
||||
func (d domain) Columns(cols ...field.Expr) gen.Columns { return d.domainDo.Columns(cols...) }
|
||||
|
||||
func (d *domain) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := d.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (d *domain) fillFieldMap() {
|
||||
d.fieldMap = make(map[string]field.Expr, 6)
|
||||
d.fieldMap["id"] = d.ID
|
||||
d.fieldMap["user_id"] = d.UserID
|
||||
d.fieldMap["name"] = d.Name
|
||||
d.fieldMap["created_at"] = d.CreatedAt
|
||||
d.fieldMap["updated_at"] = d.UpdatedAt
|
||||
d.fieldMap["version"] = d.Version
|
||||
}
|
||||
|
||||
func (d domain) clone(db *gorm.DB) domain {
|
||||
d.domainDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return d
|
||||
}
|
||||
|
||||
func (d domain) replaceDB(db *gorm.DB) domain {
|
||||
d.domainDo.ReplaceDB(db)
|
||||
return d
|
||||
}
|
||||
|
||||
type domainDo struct{ gen.DO }
|
||||
|
||||
type IDomainDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IDomainDo
|
||||
WithContext(ctx context.Context) IDomainDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IDomainDo
|
||||
WriteDB() IDomainDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IDomainDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IDomainDo
|
||||
Not(conds ...gen.Condition) IDomainDo
|
||||
Or(conds ...gen.Condition) IDomainDo
|
||||
Select(conds ...field.Expr) IDomainDo
|
||||
Where(conds ...gen.Condition) IDomainDo
|
||||
Order(conds ...field.Expr) IDomainDo
|
||||
Distinct(cols ...field.Expr) IDomainDo
|
||||
Omit(cols ...field.Expr) IDomainDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IDomainDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IDomainDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IDomainDo
|
||||
Group(cols ...field.Expr) IDomainDo
|
||||
Having(conds ...gen.Condition) IDomainDo
|
||||
Limit(limit int) IDomainDo
|
||||
Offset(offset int) IDomainDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IDomainDo
|
||||
Unscoped() IDomainDo
|
||||
Create(values ...*model.Domain) error
|
||||
CreateInBatches(values []*model.Domain, batchSize int) error
|
||||
Save(values ...*model.Domain) error
|
||||
First() (*model.Domain, error)
|
||||
Take() (*model.Domain, error)
|
||||
Last() (*model.Domain, error)
|
||||
Find() ([]*model.Domain, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Domain, err error)
|
||||
FindInBatches(result *[]*model.Domain, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.Domain) (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) IDomainDo
|
||||
Assign(attrs ...field.AssignExpr) IDomainDo
|
||||
Joins(fields ...field.RelationField) IDomainDo
|
||||
Preload(fields ...field.RelationField) IDomainDo
|
||||
FirstOrInit() (*model.Domain, error)
|
||||
FirstOrCreate() (*model.Domain, error)
|
||||
FindByPage(offset int, limit int) (result []*model.Domain, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Rows() (*sql.Rows, error)
|
||||
Row() *sql.Row
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IDomainDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (d domainDo) Debug() IDomainDo {
|
||||
return d.withDO(d.DO.Debug())
|
||||
}
|
||||
|
||||
func (d domainDo) WithContext(ctx context.Context) IDomainDo {
|
||||
return d.withDO(d.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (d domainDo) ReadDB() IDomainDo {
|
||||
return d.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (d domainDo) WriteDB() IDomainDo {
|
||||
return d.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (d domainDo) Session(config *gorm.Session) IDomainDo {
|
||||
return d.withDO(d.DO.Session(config))
|
||||
}
|
||||
|
||||
func (d domainDo) Clauses(conds ...clause.Expression) IDomainDo {
|
||||
return d.withDO(d.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (d domainDo) Returning(value interface{}, columns ...string) IDomainDo {
|
||||
return d.withDO(d.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (d domainDo) Not(conds ...gen.Condition) IDomainDo {
|
||||
return d.withDO(d.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (d domainDo) Or(conds ...gen.Condition) IDomainDo {
|
||||
return d.withDO(d.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (d domainDo) Select(conds ...field.Expr) IDomainDo {
|
||||
return d.withDO(d.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (d domainDo) Where(conds ...gen.Condition) IDomainDo {
|
||||
return d.withDO(d.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (d domainDo) Order(conds ...field.Expr) IDomainDo {
|
||||
return d.withDO(d.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (d domainDo) Distinct(cols ...field.Expr) IDomainDo {
|
||||
return d.withDO(d.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (d domainDo) Omit(cols ...field.Expr) IDomainDo {
|
||||
return d.withDO(d.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (d domainDo) Join(table schema.Tabler, on ...field.Expr) IDomainDo {
|
||||
return d.withDO(d.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (d domainDo) LeftJoin(table schema.Tabler, on ...field.Expr) IDomainDo {
|
||||
return d.withDO(d.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (d domainDo) RightJoin(table schema.Tabler, on ...field.Expr) IDomainDo {
|
||||
return d.withDO(d.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (d domainDo) Group(cols ...field.Expr) IDomainDo {
|
||||
return d.withDO(d.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (d domainDo) Having(conds ...gen.Condition) IDomainDo {
|
||||
return d.withDO(d.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (d domainDo) Limit(limit int) IDomainDo {
|
||||
return d.withDO(d.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (d domainDo) Offset(offset int) IDomainDo {
|
||||
return d.withDO(d.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (d domainDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IDomainDo {
|
||||
return d.withDO(d.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (d domainDo) Unscoped() IDomainDo {
|
||||
return d.withDO(d.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (d domainDo) Create(values ...*model.Domain) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return d.DO.Create(values)
|
||||
}
|
||||
|
||||
func (d domainDo) CreateInBatches(values []*model.Domain, batchSize int) error {
|
||||
return d.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 (d domainDo) Save(values ...*model.Domain) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return d.DO.Save(values)
|
||||
}
|
||||
|
||||
func (d domainDo) First() (*model.Domain, error) {
|
||||
if result, err := d.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Domain), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (d domainDo) Take() (*model.Domain, error) {
|
||||
if result, err := d.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Domain), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (d domainDo) Last() (*model.Domain, error) {
|
||||
if result, err := d.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Domain), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (d domainDo) Find() ([]*model.Domain, error) {
|
||||
result, err := d.DO.Find()
|
||||
return result.([]*model.Domain), err
|
||||
}
|
||||
|
||||
func (d domainDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Domain, err error) {
|
||||
buf := make([]*model.Domain, 0, batchSize)
|
||||
err = d.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 (d domainDo) FindInBatches(result *[]*model.Domain, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return d.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (d domainDo) Attrs(attrs ...field.AssignExpr) IDomainDo {
|
||||
return d.withDO(d.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (d domainDo) Assign(attrs ...field.AssignExpr) IDomainDo {
|
||||
return d.withDO(d.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (d domainDo) Joins(fields ...field.RelationField) IDomainDo {
|
||||
for _, _f := range fields {
|
||||
d = *d.withDO(d.DO.Joins(_f))
|
||||
}
|
||||
return &d
|
||||
}
|
||||
|
||||
func (d domainDo) Preload(fields ...field.RelationField) IDomainDo {
|
||||
for _, _f := range fields {
|
||||
d = *d.withDO(d.DO.Preload(_f))
|
||||
}
|
||||
return &d
|
||||
}
|
||||
|
||||
func (d domainDo) FirstOrInit() (*model.Domain, error) {
|
||||
if result, err := d.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Domain), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (d domainDo) FirstOrCreate() (*model.Domain, error) {
|
||||
if result, err := d.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Domain), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (d domainDo) FindByPage(offset int, limit int) (result []*model.Domain, count int64, err error) {
|
||||
result, err = d.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 = d.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (d domainDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = d.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = d.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (d domainDo) Scan(result interface{}) (err error) {
|
||||
return d.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (d domainDo) Delete(models ...*model.Domain) (result gen.ResultInfo, err error) {
|
||||
return d.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (d *domainDo) withDO(do gen.Dao) *domainDo {
|
||||
d.DO = *do.(*gen.DO)
|
||||
return d
|
||||
}
|
||||
@@ -16,49 +16,89 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
Q = new(Query)
|
||||
Payment *payment
|
||||
Plan *plan
|
||||
User *user
|
||||
Video *video
|
||||
Q = new(Query)
|
||||
AdTemplate *adTemplate
|
||||
Domain *domain
|
||||
Job *job
|
||||
Notification *notification
|
||||
Payment *payment
|
||||
Plan *plan
|
||||
PlanSubscription *planSubscription
|
||||
User *user
|
||||
UserPreference *userPreference
|
||||
Video *video
|
||||
VideoAdConfig *videoAdConfig
|
||||
WalletTransaction *walletTransaction
|
||||
)
|
||||
|
||||
func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
|
||||
*Q = *Use(db, opts...)
|
||||
AdTemplate = &Q.AdTemplate
|
||||
Domain = &Q.Domain
|
||||
Job = &Q.Job
|
||||
Notification = &Q.Notification
|
||||
Payment = &Q.Payment
|
||||
Plan = &Q.Plan
|
||||
PlanSubscription = &Q.PlanSubscription
|
||||
User = &Q.User
|
||||
UserPreference = &Q.UserPreference
|
||||
Video = &Q.Video
|
||||
VideoAdConfig = &Q.VideoAdConfig
|
||||
WalletTransaction = &Q.WalletTransaction
|
||||
}
|
||||
|
||||
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
|
||||
return &Query{
|
||||
db: db,
|
||||
Payment: newPayment(db, opts...),
|
||||
Plan: newPlan(db, opts...),
|
||||
User: newUser(db, opts...),
|
||||
Video: newVideo(db, opts...),
|
||||
db: db,
|
||||
AdTemplate: newAdTemplate(db, opts...),
|
||||
Domain: newDomain(db, opts...),
|
||||
Job: newJob(db, opts...),
|
||||
Notification: newNotification(db, opts...),
|
||||
Payment: newPayment(db, opts...),
|
||||
Plan: newPlan(db, opts...),
|
||||
PlanSubscription: newPlanSubscription(db, opts...),
|
||||
User: newUser(db, opts...),
|
||||
UserPreference: newUserPreference(db, opts...),
|
||||
Video: newVideo(db, opts...),
|
||||
VideoAdConfig: newVideoAdConfig(db, opts...),
|
||||
WalletTransaction: newWalletTransaction(db, opts...),
|
||||
}
|
||||
}
|
||||
|
||||
type Query struct {
|
||||
db *gorm.DB
|
||||
|
||||
Payment payment
|
||||
Plan plan
|
||||
User user
|
||||
Video video
|
||||
AdTemplate adTemplate
|
||||
Domain domain
|
||||
Job job
|
||||
Notification notification
|
||||
Payment payment
|
||||
Plan plan
|
||||
PlanSubscription planSubscription
|
||||
User user
|
||||
UserPreference userPreference
|
||||
Video video
|
||||
VideoAdConfig videoAdConfig
|
||||
WalletTransaction walletTransaction
|
||||
}
|
||||
|
||||
func (q *Query) Available() bool { return q.db != nil }
|
||||
|
||||
func (q *Query) clone(db *gorm.DB) *Query {
|
||||
return &Query{
|
||||
db: db,
|
||||
Payment: q.Payment.clone(db),
|
||||
Plan: q.Plan.clone(db),
|
||||
User: q.User.clone(db),
|
||||
Video: q.Video.clone(db),
|
||||
db: db,
|
||||
AdTemplate: q.AdTemplate.clone(db),
|
||||
Domain: q.Domain.clone(db),
|
||||
Job: q.Job.clone(db),
|
||||
Notification: q.Notification.clone(db),
|
||||
Payment: q.Payment.clone(db),
|
||||
Plan: q.Plan.clone(db),
|
||||
PlanSubscription: q.PlanSubscription.clone(db),
|
||||
User: q.User.clone(db),
|
||||
UserPreference: q.UserPreference.clone(db),
|
||||
Video: q.Video.clone(db),
|
||||
VideoAdConfig: q.VideoAdConfig.clone(db),
|
||||
WalletTransaction: q.WalletTransaction.clone(db),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,27 +112,51 @@ func (q *Query) WriteDB() *Query {
|
||||
|
||||
func (q *Query) ReplaceDB(db *gorm.DB) *Query {
|
||||
return &Query{
|
||||
db: db,
|
||||
Payment: q.Payment.replaceDB(db),
|
||||
Plan: q.Plan.replaceDB(db),
|
||||
User: q.User.replaceDB(db),
|
||||
Video: q.Video.replaceDB(db),
|
||||
db: db,
|
||||
AdTemplate: q.AdTemplate.replaceDB(db),
|
||||
Domain: q.Domain.replaceDB(db),
|
||||
Job: q.Job.replaceDB(db),
|
||||
Notification: q.Notification.replaceDB(db),
|
||||
Payment: q.Payment.replaceDB(db),
|
||||
Plan: q.Plan.replaceDB(db),
|
||||
PlanSubscription: q.PlanSubscription.replaceDB(db),
|
||||
User: q.User.replaceDB(db),
|
||||
UserPreference: q.UserPreference.replaceDB(db),
|
||||
Video: q.Video.replaceDB(db),
|
||||
VideoAdConfig: q.VideoAdConfig.replaceDB(db),
|
||||
WalletTransaction: q.WalletTransaction.replaceDB(db),
|
||||
}
|
||||
}
|
||||
|
||||
type queryCtx struct {
|
||||
Payment IPaymentDo
|
||||
Plan IPlanDo
|
||||
User IUserDo
|
||||
Video IVideoDo
|
||||
AdTemplate IAdTemplateDo
|
||||
Domain IDomainDo
|
||||
Job IJobDo
|
||||
Notification INotificationDo
|
||||
Payment IPaymentDo
|
||||
Plan IPlanDo
|
||||
PlanSubscription IPlanSubscriptionDo
|
||||
User IUserDo
|
||||
UserPreference IUserPreferenceDo
|
||||
Video IVideoDo
|
||||
VideoAdConfig IVideoAdConfigDo
|
||||
WalletTransaction IWalletTransactionDo
|
||||
}
|
||||
|
||||
func (q *Query) WithContext(ctx context.Context) *queryCtx {
|
||||
return &queryCtx{
|
||||
Payment: q.Payment.WithContext(ctx),
|
||||
Plan: q.Plan.WithContext(ctx),
|
||||
User: q.User.WithContext(ctx),
|
||||
Video: q.Video.WithContext(ctx),
|
||||
AdTemplate: q.AdTemplate.WithContext(ctx),
|
||||
Domain: q.Domain.WithContext(ctx),
|
||||
Job: q.Job.WithContext(ctx),
|
||||
Notification: q.Notification.WithContext(ctx),
|
||||
Payment: q.Payment.WithContext(ctx),
|
||||
Plan: q.Plan.WithContext(ctx),
|
||||
PlanSubscription: q.PlanSubscription.WithContext(ctx),
|
||||
User: q.User.WithContext(ctx),
|
||||
UserPreference: q.UserPreference.WithContext(ctx),
|
||||
Video: q.Video.WithContext(ctx),
|
||||
VideoAdConfig: q.VideoAdConfig.WithContext(ctx),
|
||||
WalletTransaction: q.WalletTransaction.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
455
internal/database/query/jobs.gen.go
Normal file
455
internal/database/query/jobs.gen.go
Normal file
@@ -0,0 +1,455 @@
|
||||
// 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"
|
||||
"database/sql"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"stream.api/internal/database/model"
|
||||
)
|
||||
|
||||
func newJob(db *gorm.DB, opts ...gen.DOOption) job {
|
||||
_job := job{}
|
||||
|
||||
_job.jobDo.UseDB(db, opts...)
|
||||
_job.jobDo.UseModel(&model.Job{})
|
||||
|
||||
tableName := _job.jobDo.TableName()
|
||||
_job.ALL = field.NewAsterisk(tableName)
|
||||
_job.ID = field.NewString(tableName, "id")
|
||||
_job.Status = field.NewString(tableName, "status")
|
||||
_job.Priority = field.NewInt64(tableName, "priority")
|
||||
_job.InputURL = field.NewString(tableName, "input_url")
|
||||
_job.OutputURL = field.NewString(tableName, "output_url")
|
||||
_job.TotalDuration = field.NewInt64(tableName, "total_duration")
|
||||
_job.CurrentTime = field.NewInt64(tableName, "current_time")
|
||||
_job.Progress = field.NewFloat64(tableName, "progress")
|
||||
_job.AgentID = field.NewInt64(tableName, "agent_id")
|
||||
_job.Logs = field.NewString(tableName, "logs")
|
||||
_job.Config = field.NewString(tableName, "config")
|
||||
_job.Cancelled = field.NewBool(tableName, "cancelled")
|
||||
_job.RetryCount = field.NewInt64(tableName, "retry_count")
|
||||
_job.MaxRetries = field.NewInt64(tableName, "max_retries")
|
||||
_job.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_job.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_job.Version = field.NewInt64(tableName, "version")
|
||||
|
||||
_job.fillFieldMap()
|
||||
|
||||
return _job
|
||||
}
|
||||
|
||||
type job struct {
|
||||
jobDo jobDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.String
|
||||
Status field.String
|
||||
Priority field.Int64
|
||||
InputURL field.String
|
||||
OutputURL field.String
|
||||
TotalDuration field.Int64
|
||||
CurrentTime field.Int64
|
||||
Progress field.Float64
|
||||
AgentID field.Int64
|
||||
Logs field.String
|
||||
Config field.String
|
||||
Cancelled field.Bool
|
||||
RetryCount field.Int64
|
||||
MaxRetries field.Int64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
Version field.Int64
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (j job) Table(newTableName string) *job {
|
||||
j.jobDo.UseTable(newTableName)
|
||||
return j.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (j job) As(alias string) *job {
|
||||
j.jobDo.DO = *(j.jobDo.As(alias).(*gen.DO))
|
||||
return j.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (j *job) updateTableName(table string) *job {
|
||||
j.ALL = field.NewAsterisk(table)
|
||||
j.ID = field.NewString(table, "id")
|
||||
j.Status = field.NewString(table, "status")
|
||||
j.Priority = field.NewInt64(table, "priority")
|
||||
j.InputURL = field.NewString(table, "input_url")
|
||||
j.OutputURL = field.NewString(table, "output_url")
|
||||
j.TotalDuration = field.NewInt64(table, "total_duration")
|
||||
j.CurrentTime = field.NewInt64(table, "current_time")
|
||||
j.Progress = field.NewFloat64(table, "progress")
|
||||
j.AgentID = field.NewInt64(table, "agent_id")
|
||||
j.Logs = field.NewString(table, "logs")
|
||||
j.Config = field.NewString(table, "config")
|
||||
j.Cancelled = field.NewBool(table, "cancelled")
|
||||
j.RetryCount = field.NewInt64(table, "retry_count")
|
||||
j.MaxRetries = field.NewInt64(table, "max_retries")
|
||||
j.CreatedAt = field.NewTime(table, "created_at")
|
||||
j.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
j.Version = field.NewInt64(table, "version")
|
||||
|
||||
j.fillFieldMap()
|
||||
|
||||
return j
|
||||
}
|
||||
|
||||
func (j *job) WithContext(ctx context.Context) IJobDo { return j.jobDo.WithContext(ctx) }
|
||||
|
||||
func (j job) TableName() string { return j.jobDo.TableName() }
|
||||
|
||||
func (j job) Alias() string { return j.jobDo.Alias() }
|
||||
|
||||
func (j job) Columns(cols ...field.Expr) gen.Columns { return j.jobDo.Columns(cols...) }
|
||||
|
||||
func (j *job) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := j.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (j *job) fillFieldMap() {
|
||||
j.fieldMap = make(map[string]field.Expr, 17)
|
||||
j.fieldMap["id"] = j.ID
|
||||
j.fieldMap["status"] = j.Status
|
||||
j.fieldMap["priority"] = j.Priority
|
||||
j.fieldMap["input_url"] = j.InputURL
|
||||
j.fieldMap["output_url"] = j.OutputURL
|
||||
j.fieldMap["total_duration"] = j.TotalDuration
|
||||
j.fieldMap["current_time"] = j.CurrentTime
|
||||
j.fieldMap["progress"] = j.Progress
|
||||
j.fieldMap["agent_id"] = j.AgentID
|
||||
j.fieldMap["logs"] = j.Logs
|
||||
j.fieldMap["config"] = j.Config
|
||||
j.fieldMap["cancelled"] = j.Cancelled
|
||||
j.fieldMap["retry_count"] = j.RetryCount
|
||||
j.fieldMap["max_retries"] = j.MaxRetries
|
||||
j.fieldMap["created_at"] = j.CreatedAt
|
||||
j.fieldMap["updated_at"] = j.UpdatedAt
|
||||
j.fieldMap["version"] = j.Version
|
||||
}
|
||||
|
||||
func (j job) clone(db *gorm.DB) job {
|
||||
j.jobDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return j
|
||||
}
|
||||
|
||||
func (j job) replaceDB(db *gorm.DB) job {
|
||||
j.jobDo.ReplaceDB(db)
|
||||
return j
|
||||
}
|
||||
|
||||
type jobDo struct{ gen.DO }
|
||||
|
||||
type IJobDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IJobDo
|
||||
WithContext(ctx context.Context) IJobDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IJobDo
|
||||
WriteDB() IJobDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IJobDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IJobDo
|
||||
Not(conds ...gen.Condition) IJobDo
|
||||
Or(conds ...gen.Condition) IJobDo
|
||||
Select(conds ...field.Expr) IJobDo
|
||||
Where(conds ...gen.Condition) IJobDo
|
||||
Order(conds ...field.Expr) IJobDo
|
||||
Distinct(cols ...field.Expr) IJobDo
|
||||
Omit(cols ...field.Expr) IJobDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IJobDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IJobDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IJobDo
|
||||
Group(cols ...field.Expr) IJobDo
|
||||
Having(conds ...gen.Condition) IJobDo
|
||||
Limit(limit int) IJobDo
|
||||
Offset(offset int) IJobDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IJobDo
|
||||
Unscoped() IJobDo
|
||||
Create(values ...*model.Job) error
|
||||
CreateInBatches(values []*model.Job, batchSize int) error
|
||||
Save(values ...*model.Job) error
|
||||
First() (*model.Job, error)
|
||||
Take() (*model.Job, error)
|
||||
Last() (*model.Job, error)
|
||||
Find() ([]*model.Job, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Job, err error)
|
||||
FindInBatches(result *[]*model.Job, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.Job) (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) IJobDo
|
||||
Assign(attrs ...field.AssignExpr) IJobDo
|
||||
Joins(fields ...field.RelationField) IJobDo
|
||||
Preload(fields ...field.RelationField) IJobDo
|
||||
FirstOrInit() (*model.Job, error)
|
||||
FirstOrCreate() (*model.Job, error)
|
||||
FindByPage(offset int, limit int) (result []*model.Job, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Rows() (*sql.Rows, error)
|
||||
Row() *sql.Row
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IJobDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (j jobDo) Debug() IJobDo {
|
||||
return j.withDO(j.DO.Debug())
|
||||
}
|
||||
|
||||
func (j jobDo) WithContext(ctx context.Context) IJobDo {
|
||||
return j.withDO(j.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (j jobDo) ReadDB() IJobDo {
|
||||
return j.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (j jobDo) WriteDB() IJobDo {
|
||||
return j.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (j jobDo) Session(config *gorm.Session) IJobDo {
|
||||
return j.withDO(j.DO.Session(config))
|
||||
}
|
||||
|
||||
func (j jobDo) Clauses(conds ...clause.Expression) IJobDo {
|
||||
return j.withDO(j.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (j jobDo) Returning(value interface{}, columns ...string) IJobDo {
|
||||
return j.withDO(j.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (j jobDo) Not(conds ...gen.Condition) IJobDo {
|
||||
return j.withDO(j.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (j jobDo) Or(conds ...gen.Condition) IJobDo {
|
||||
return j.withDO(j.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (j jobDo) Select(conds ...field.Expr) IJobDo {
|
||||
return j.withDO(j.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (j jobDo) Where(conds ...gen.Condition) IJobDo {
|
||||
return j.withDO(j.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (j jobDo) Order(conds ...field.Expr) IJobDo {
|
||||
return j.withDO(j.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (j jobDo) Distinct(cols ...field.Expr) IJobDo {
|
||||
return j.withDO(j.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (j jobDo) Omit(cols ...field.Expr) IJobDo {
|
||||
return j.withDO(j.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (j jobDo) Join(table schema.Tabler, on ...field.Expr) IJobDo {
|
||||
return j.withDO(j.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (j jobDo) LeftJoin(table schema.Tabler, on ...field.Expr) IJobDo {
|
||||
return j.withDO(j.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (j jobDo) RightJoin(table schema.Tabler, on ...field.Expr) IJobDo {
|
||||
return j.withDO(j.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (j jobDo) Group(cols ...field.Expr) IJobDo {
|
||||
return j.withDO(j.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (j jobDo) Having(conds ...gen.Condition) IJobDo {
|
||||
return j.withDO(j.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (j jobDo) Limit(limit int) IJobDo {
|
||||
return j.withDO(j.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (j jobDo) Offset(offset int) IJobDo {
|
||||
return j.withDO(j.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (j jobDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IJobDo {
|
||||
return j.withDO(j.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (j jobDo) Unscoped() IJobDo {
|
||||
return j.withDO(j.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (j jobDo) Create(values ...*model.Job) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return j.DO.Create(values)
|
||||
}
|
||||
|
||||
func (j jobDo) CreateInBatches(values []*model.Job, batchSize int) error {
|
||||
return j.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 (j jobDo) Save(values ...*model.Job) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return j.DO.Save(values)
|
||||
}
|
||||
|
||||
func (j jobDo) First() (*model.Job, error) {
|
||||
if result, err := j.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Job), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (j jobDo) Take() (*model.Job, error) {
|
||||
if result, err := j.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Job), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (j jobDo) Last() (*model.Job, error) {
|
||||
if result, err := j.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Job), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (j jobDo) Find() ([]*model.Job, error) {
|
||||
result, err := j.DO.Find()
|
||||
return result.([]*model.Job), err
|
||||
}
|
||||
|
||||
func (j jobDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Job, err error) {
|
||||
buf := make([]*model.Job, 0, batchSize)
|
||||
err = j.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 (j jobDo) FindInBatches(result *[]*model.Job, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return j.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (j jobDo) Attrs(attrs ...field.AssignExpr) IJobDo {
|
||||
return j.withDO(j.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (j jobDo) Assign(attrs ...field.AssignExpr) IJobDo {
|
||||
return j.withDO(j.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (j jobDo) Joins(fields ...field.RelationField) IJobDo {
|
||||
for _, _f := range fields {
|
||||
j = *j.withDO(j.DO.Joins(_f))
|
||||
}
|
||||
return &j
|
||||
}
|
||||
|
||||
func (j jobDo) Preload(fields ...field.RelationField) IJobDo {
|
||||
for _, _f := range fields {
|
||||
j = *j.withDO(j.DO.Preload(_f))
|
||||
}
|
||||
return &j
|
||||
}
|
||||
|
||||
func (j jobDo) FirstOrInit() (*model.Job, error) {
|
||||
if result, err := j.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Job), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (j jobDo) FirstOrCreate() (*model.Job, error) {
|
||||
if result, err := j.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Job), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (j jobDo) FindByPage(offset int, limit int) (result []*model.Job, count int64, err error) {
|
||||
result, err = j.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 = j.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (j jobDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = j.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = j.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (j jobDo) Scan(result interface{}) (err error) {
|
||||
return j.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (j jobDo) Delete(models ...*model.Job) (result gen.ResultInfo, err error) {
|
||||
return j.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (j *jobDo) withDO(do gen.Dao) *jobDo {
|
||||
j.DO = *do.(*gen.DO)
|
||||
return j
|
||||
}
|
||||
439
internal/database/query/notifications.gen.go
Normal file
439
internal/database/query/notifications.gen.go
Normal file
@@ -0,0 +1,439 @@
|
||||
// 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"
|
||||
"database/sql"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"stream.api/internal/database/model"
|
||||
)
|
||||
|
||||
func newNotification(db *gorm.DB, opts ...gen.DOOption) notification {
|
||||
_notification := notification{}
|
||||
|
||||
_notification.notificationDo.UseDB(db, opts...)
|
||||
_notification.notificationDo.UseModel(&model.Notification{})
|
||||
|
||||
tableName := _notification.notificationDo.TableName()
|
||||
_notification.ALL = field.NewAsterisk(tableName)
|
||||
_notification.ID = field.NewString(tableName, "id")
|
||||
_notification.UserID = field.NewString(tableName, "user_id")
|
||||
_notification.Type = field.NewString(tableName, "type")
|
||||
_notification.Title = field.NewString(tableName, "title")
|
||||
_notification.Message = field.NewString(tableName, "message")
|
||||
_notification.Metadata = field.NewString(tableName, "metadata")
|
||||
_notification.ActionURL = field.NewString(tableName, "action_url")
|
||||
_notification.ActionLabel = field.NewString(tableName, "action_label")
|
||||
_notification.IsRead = field.NewBool(tableName, "is_read")
|
||||
_notification.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_notification.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_notification.Version = field.NewInt64(tableName, "version")
|
||||
|
||||
_notification.fillFieldMap()
|
||||
|
||||
return _notification
|
||||
}
|
||||
|
||||
type notification struct {
|
||||
notificationDo notificationDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.String
|
||||
UserID field.String
|
||||
Type field.String
|
||||
Title field.String
|
||||
Message field.String
|
||||
Metadata field.String
|
||||
ActionURL field.String
|
||||
ActionLabel field.String
|
||||
IsRead field.Bool
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
Version field.Int64
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (n notification) Table(newTableName string) *notification {
|
||||
n.notificationDo.UseTable(newTableName)
|
||||
return n.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (n notification) As(alias string) *notification {
|
||||
n.notificationDo.DO = *(n.notificationDo.As(alias).(*gen.DO))
|
||||
return n.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (n *notification) updateTableName(table string) *notification {
|
||||
n.ALL = field.NewAsterisk(table)
|
||||
n.ID = field.NewString(table, "id")
|
||||
n.UserID = field.NewString(table, "user_id")
|
||||
n.Type = field.NewString(table, "type")
|
||||
n.Title = field.NewString(table, "title")
|
||||
n.Message = field.NewString(table, "message")
|
||||
n.Metadata = field.NewString(table, "metadata")
|
||||
n.ActionURL = field.NewString(table, "action_url")
|
||||
n.ActionLabel = field.NewString(table, "action_label")
|
||||
n.IsRead = field.NewBool(table, "is_read")
|
||||
n.CreatedAt = field.NewTime(table, "created_at")
|
||||
n.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
n.Version = field.NewInt64(table, "version")
|
||||
|
||||
n.fillFieldMap()
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *notification) WithContext(ctx context.Context) INotificationDo {
|
||||
return n.notificationDo.WithContext(ctx)
|
||||
}
|
||||
|
||||
func (n notification) TableName() string { return n.notificationDo.TableName() }
|
||||
|
||||
func (n notification) Alias() string { return n.notificationDo.Alias() }
|
||||
|
||||
func (n notification) Columns(cols ...field.Expr) gen.Columns {
|
||||
return n.notificationDo.Columns(cols...)
|
||||
}
|
||||
|
||||
func (n *notification) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := n.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (n *notification) fillFieldMap() {
|
||||
n.fieldMap = make(map[string]field.Expr, 12)
|
||||
n.fieldMap["id"] = n.ID
|
||||
n.fieldMap["user_id"] = n.UserID
|
||||
n.fieldMap["type"] = n.Type
|
||||
n.fieldMap["title"] = n.Title
|
||||
n.fieldMap["message"] = n.Message
|
||||
n.fieldMap["metadata"] = n.Metadata
|
||||
n.fieldMap["action_url"] = n.ActionURL
|
||||
n.fieldMap["action_label"] = n.ActionLabel
|
||||
n.fieldMap["is_read"] = n.IsRead
|
||||
n.fieldMap["created_at"] = n.CreatedAt
|
||||
n.fieldMap["updated_at"] = n.UpdatedAt
|
||||
n.fieldMap["version"] = n.Version
|
||||
}
|
||||
|
||||
func (n notification) clone(db *gorm.DB) notification {
|
||||
n.notificationDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return n
|
||||
}
|
||||
|
||||
func (n notification) replaceDB(db *gorm.DB) notification {
|
||||
n.notificationDo.ReplaceDB(db)
|
||||
return n
|
||||
}
|
||||
|
||||
type notificationDo struct{ gen.DO }
|
||||
|
||||
type INotificationDo interface {
|
||||
gen.SubQuery
|
||||
Debug() INotificationDo
|
||||
WithContext(ctx context.Context) INotificationDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() INotificationDo
|
||||
WriteDB() INotificationDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) INotificationDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) INotificationDo
|
||||
Not(conds ...gen.Condition) INotificationDo
|
||||
Or(conds ...gen.Condition) INotificationDo
|
||||
Select(conds ...field.Expr) INotificationDo
|
||||
Where(conds ...gen.Condition) INotificationDo
|
||||
Order(conds ...field.Expr) INotificationDo
|
||||
Distinct(cols ...field.Expr) INotificationDo
|
||||
Omit(cols ...field.Expr) INotificationDo
|
||||
Join(table schema.Tabler, on ...field.Expr) INotificationDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) INotificationDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) INotificationDo
|
||||
Group(cols ...field.Expr) INotificationDo
|
||||
Having(conds ...gen.Condition) INotificationDo
|
||||
Limit(limit int) INotificationDo
|
||||
Offset(offset int) INotificationDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) INotificationDo
|
||||
Unscoped() INotificationDo
|
||||
Create(values ...*model.Notification) error
|
||||
CreateInBatches(values []*model.Notification, batchSize int) error
|
||||
Save(values ...*model.Notification) error
|
||||
First() (*model.Notification, error)
|
||||
Take() (*model.Notification, error)
|
||||
Last() (*model.Notification, error)
|
||||
Find() ([]*model.Notification, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Notification, err error)
|
||||
FindInBatches(result *[]*model.Notification, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.Notification) (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) INotificationDo
|
||||
Assign(attrs ...field.AssignExpr) INotificationDo
|
||||
Joins(fields ...field.RelationField) INotificationDo
|
||||
Preload(fields ...field.RelationField) INotificationDo
|
||||
FirstOrInit() (*model.Notification, error)
|
||||
FirstOrCreate() (*model.Notification, error)
|
||||
FindByPage(offset int, limit int) (result []*model.Notification, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Rows() (*sql.Rows, error)
|
||||
Row() *sql.Row
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) INotificationDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (n notificationDo) Debug() INotificationDo {
|
||||
return n.withDO(n.DO.Debug())
|
||||
}
|
||||
|
||||
func (n notificationDo) WithContext(ctx context.Context) INotificationDo {
|
||||
return n.withDO(n.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (n notificationDo) ReadDB() INotificationDo {
|
||||
return n.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (n notificationDo) WriteDB() INotificationDo {
|
||||
return n.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (n notificationDo) Session(config *gorm.Session) INotificationDo {
|
||||
return n.withDO(n.DO.Session(config))
|
||||
}
|
||||
|
||||
func (n notificationDo) Clauses(conds ...clause.Expression) INotificationDo {
|
||||
return n.withDO(n.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (n notificationDo) Returning(value interface{}, columns ...string) INotificationDo {
|
||||
return n.withDO(n.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (n notificationDo) Not(conds ...gen.Condition) INotificationDo {
|
||||
return n.withDO(n.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (n notificationDo) Or(conds ...gen.Condition) INotificationDo {
|
||||
return n.withDO(n.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (n notificationDo) Select(conds ...field.Expr) INotificationDo {
|
||||
return n.withDO(n.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (n notificationDo) Where(conds ...gen.Condition) INotificationDo {
|
||||
return n.withDO(n.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (n notificationDo) Order(conds ...field.Expr) INotificationDo {
|
||||
return n.withDO(n.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (n notificationDo) Distinct(cols ...field.Expr) INotificationDo {
|
||||
return n.withDO(n.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (n notificationDo) Omit(cols ...field.Expr) INotificationDo {
|
||||
return n.withDO(n.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (n notificationDo) Join(table schema.Tabler, on ...field.Expr) INotificationDo {
|
||||
return n.withDO(n.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (n notificationDo) LeftJoin(table schema.Tabler, on ...field.Expr) INotificationDo {
|
||||
return n.withDO(n.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n notificationDo) RightJoin(table schema.Tabler, on ...field.Expr) INotificationDo {
|
||||
return n.withDO(n.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n notificationDo) Group(cols ...field.Expr) INotificationDo {
|
||||
return n.withDO(n.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (n notificationDo) Having(conds ...gen.Condition) INotificationDo {
|
||||
return n.withDO(n.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (n notificationDo) Limit(limit int) INotificationDo {
|
||||
return n.withDO(n.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (n notificationDo) Offset(offset int) INotificationDo {
|
||||
return n.withDO(n.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (n notificationDo) Scopes(funcs ...func(gen.Dao) gen.Dao) INotificationDo {
|
||||
return n.withDO(n.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (n notificationDo) Unscoped() INotificationDo {
|
||||
return n.withDO(n.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (n notificationDo) Create(values ...*model.Notification) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Create(values)
|
||||
}
|
||||
|
||||
func (n notificationDo) CreateInBatches(values []*model.Notification, batchSize int) error {
|
||||
return n.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 (n notificationDo) Save(values ...*model.Notification) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Save(values)
|
||||
}
|
||||
|
||||
func (n notificationDo) First() (*model.Notification, error) {
|
||||
if result, err := n.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Notification), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n notificationDo) Take() (*model.Notification, error) {
|
||||
if result, err := n.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Notification), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n notificationDo) Last() (*model.Notification, error) {
|
||||
if result, err := n.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Notification), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n notificationDo) Find() ([]*model.Notification, error) {
|
||||
result, err := n.DO.Find()
|
||||
return result.([]*model.Notification), err
|
||||
}
|
||||
|
||||
func (n notificationDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Notification, err error) {
|
||||
buf := make([]*model.Notification, 0, batchSize)
|
||||
err = n.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 (n notificationDo) FindInBatches(result *[]*model.Notification, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return n.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (n notificationDo) Attrs(attrs ...field.AssignExpr) INotificationDo {
|
||||
return n.withDO(n.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (n notificationDo) Assign(attrs ...field.AssignExpr) INotificationDo {
|
||||
return n.withDO(n.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (n notificationDo) Joins(fields ...field.RelationField) INotificationDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Joins(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n notificationDo) Preload(fields ...field.RelationField) INotificationDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Preload(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n notificationDo) FirstOrInit() (*model.Notification, error) {
|
||||
if result, err := n.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Notification), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n notificationDo) FirstOrCreate() (*model.Notification, error) {
|
||||
if result, err := n.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.Notification), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n notificationDo) FindByPage(offset int, limit int) (result []*model.Notification, count int64, err error) {
|
||||
result, err = n.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 = n.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (n notificationDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = n.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = n.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (n notificationDo) Scan(result interface{}) (err error) {
|
||||
return n.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (n notificationDo) Delete(models ...*model.Notification) (result gen.ResultInfo, err error) {
|
||||
return n.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (n *notificationDo) withDO(do gen.Dao) *notificationDo {
|
||||
n.DO = *do.(*gen.DO)
|
||||
return n
|
||||
}
|
||||
@@ -37,7 +37,7 @@ func newPlan(db *gorm.DB, opts ...gen.DOOption) plan {
|
||||
_plan.UploadLimit = field.NewInt32(tableName, "upload_limit")
|
||||
_plan.DurationLimit = field.NewInt32(tableName, "duration_limit")
|
||||
_plan.QualityLimit = field.NewString(tableName, "quality_limit")
|
||||
_plan.Features = field.NewString(tableName, "features")
|
||||
_plan.Features = field.NewField(tableName, "features")
|
||||
_plan.IsActive = field.NewBool(tableName, "is_active")
|
||||
_plan.Version = field.NewInt64(tableName, "version")
|
||||
|
||||
@@ -59,7 +59,7 @@ type plan struct {
|
||||
UploadLimit field.Int32
|
||||
DurationLimit field.Int32
|
||||
QualityLimit field.String
|
||||
Features field.String
|
||||
Features field.Field
|
||||
IsActive field.Bool
|
||||
Version field.Int64
|
||||
|
||||
@@ -87,7 +87,7 @@ func (p *plan) updateTableName(table string) *plan {
|
||||
p.UploadLimit = field.NewInt32(table, "upload_limit")
|
||||
p.DurationLimit = field.NewInt32(table, "duration_limit")
|
||||
p.QualityLimit = field.NewString(table, "quality_limit")
|
||||
p.Features = field.NewString(table, "features")
|
||||
p.Features = field.NewField(table, "features")
|
||||
p.IsActive = field.NewBool(table, "is_active")
|
||||
p.Version = field.NewInt64(table, "version")
|
||||
|
||||
|
||||
455
internal/database/query/plan_subscriptions.gen.go
Normal file
455
internal/database/query/plan_subscriptions.gen.go
Normal file
@@ -0,0 +1,455 @@
|
||||
// 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"
|
||||
"database/sql"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"stream.api/internal/database/model"
|
||||
)
|
||||
|
||||
func newPlanSubscription(db *gorm.DB, opts ...gen.DOOption) planSubscription {
|
||||
_planSubscription := planSubscription{}
|
||||
|
||||
_planSubscription.planSubscriptionDo.UseDB(db, opts...)
|
||||
_planSubscription.planSubscriptionDo.UseModel(&model.PlanSubscription{})
|
||||
|
||||
tableName := _planSubscription.planSubscriptionDo.TableName()
|
||||
_planSubscription.ALL = field.NewAsterisk(tableName)
|
||||
_planSubscription.ID = field.NewString(tableName, "id")
|
||||
_planSubscription.UserID = field.NewString(tableName, "user_id")
|
||||
_planSubscription.PaymentID = field.NewString(tableName, "payment_id")
|
||||
_planSubscription.PlanID = field.NewString(tableName, "plan_id")
|
||||
_planSubscription.TermMonths = field.NewInt32(tableName, "term_months")
|
||||
_planSubscription.PaymentMethod = field.NewString(tableName, "payment_method")
|
||||
_planSubscription.WalletAmount = field.NewFloat64(tableName, "wallet_amount")
|
||||
_planSubscription.TopupAmount = field.NewFloat64(tableName, "topup_amount")
|
||||
_planSubscription.StartedAt = field.NewTime(tableName, "started_at")
|
||||
_planSubscription.ExpiresAt = field.NewTime(tableName, "expires_at")
|
||||
_planSubscription.Reminder7DSentAt = field.NewTime(tableName, "reminder_7d_sent_at")
|
||||
_planSubscription.Reminder3DSentAt = field.NewTime(tableName, "reminder_3d_sent_at")
|
||||
_planSubscription.Reminder1DSentAt = field.NewTime(tableName, "reminder_1d_sent_at")
|
||||
_planSubscription.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_planSubscription.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_planSubscription.Version = field.NewInt64(tableName, "version")
|
||||
|
||||
_planSubscription.fillFieldMap()
|
||||
|
||||
return _planSubscription
|
||||
}
|
||||
|
||||
type planSubscription struct {
|
||||
planSubscriptionDo planSubscriptionDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.String
|
||||
UserID field.String
|
||||
PaymentID field.String
|
||||
PlanID field.String
|
||||
TermMonths field.Int32
|
||||
PaymentMethod field.String
|
||||
WalletAmount field.Float64
|
||||
TopupAmount field.Float64
|
||||
StartedAt field.Time
|
||||
ExpiresAt field.Time
|
||||
Reminder7DSentAt field.Time
|
||||
Reminder3DSentAt field.Time
|
||||
Reminder1DSentAt field.Time
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
Version field.Int64
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (p planSubscription) Table(newTableName string) *planSubscription {
|
||||
p.planSubscriptionDo.UseTable(newTableName)
|
||||
return p.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (p planSubscription) As(alias string) *planSubscription {
|
||||
p.planSubscriptionDo.DO = *(p.planSubscriptionDo.As(alias).(*gen.DO))
|
||||
return p.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (p *planSubscription) updateTableName(table string) *planSubscription {
|
||||
p.ALL = field.NewAsterisk(table)
|
||||
p.ID = field.NewString(table, "id")
|
||||
p.UserID = field.NewString(table, "user_id")
|
||||
p.PaymentID = field.NewString(table, "payment_id")
|
||||
p.PlanID = field.NewString(table, "plan_id")
|
||||
p.TermMonths = field.NewInt32(table, "term_months")
|
||||
p.PaymentMethod = field.NewString(table, "payment_method")
|
||||
p.WalletAmount = field.NewFloat64(table, "wallet_amount")
|
||||
p.TopupAmount = field.NewFloat64(table, "topup_amount")
|
||||
p.StartedAt = field.NewTime(table, "started_at")
|
||||
p.ExpiresAt = field.NewTime(table, "expires_at")
|
||||
p.Reminder7DSentAt = field.NewTime(table, "reminder_7d_sent_at")
|
||||
p.Reminder3DSentAt = field.NewTime(table, "reminder_3d_sent_at")
|
||||
p.Reminder1DSentAt = field.NewTime(table, "reminder_1d_sent_at")
|
||||
p.CreatedAt = field.NewTime(table, "created_at")
|
||||
p.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
p.Version = field.NewInt64(table, "version")
|
||||
|
||||
p.fillFieldMap()
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *planSubscription) WithContext(ctx context.Context) IPlanSubscriptionDo {
|
||||
return p.planSubscriptionDo.WithContext(ctx)
|
||||
}
|
||||
|
||||
func (p planSubscription) TableName() string { return p.planSubscriptionDo.TableName() }
|
||||
|
||||
func (p planSubscription) Alias() string { return p.planSubscriptionDo.Alias() }
|
||||
|
||||
func (p planSubscription) Columns(cols ...field.Expr) gen.Columns {
|
||||
return p.planSubscriptionDo.Columns(cols...)
|
||||
}
|
||||
|
||||
func (p *planSubscription) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := p.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (p *planSubscription) fillFieldMap() {
|
||||
p.fieldMap = make(map[string]field.Expr, 16)
|
||||
p.fieldMap["id"] = p.ID
|
||||
p.fieldMap["user_id"] = p.UserID
|
||||
p.fieldMap["payment_id"] = p.PaymentID
|
||||
p.fieldMap["plan_id"] = p.PlanID
|
||||
p.fieldMap["term_months"] = p.TermMonths
|
||||
p.fieldMap["payment_method"] = p.PaymentMethod
|
||||
p.fieldMap["wallet_amount"] = p.WalletAmount
|
||||
p.fieldMap["topup_amount"] = p.TopupAmount
|
||||
p.fieldMap["started_at"] = p.StartedAt
|
||||
p.fieldMap["expires_at"] = p.ExpiresAt
|
||||
p.fieldMap["reminder_7d_sent_at"] = p.Reminder7DSentAt
|
||||
p.fieldMap["reminder_3d_sent_at"] = p.Reminder3DSentAt
|
||||
p.fieldMap["reminder_1d_sent_at"] = p.Reminder1DSentAt
|
||||
p.fieldMap["created_at"] = p.CreatedAt
|
||||
p.fieldMap["updated_at"] = p.UpdatedAt
|
||||
p.fieldMap["version"] = p.Version
|
||||
}
|
||||
|
||||
func (p planSubscription) clone(db *gorm.DB) planSubscription {
|
||||
p.planSubscriptionDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return p
|
||||
}
|
||||
|
||||
func (p planSubscription) replaceDB(db *gorm.DB) planSubscription {
|
||||
p.planSubscriptionDo.ReplaceDB(db)
|
||||
return p
|
||||
}
|
||||
|
||||
type planSubscriptionDo struct{ gen.DO }
|
||||
|
||||
type IPlanSubscriptionDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IPlanSubscriptionDo
|
||||
WithContext(ctx context.Context) IPlanSubscriptionDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IPlanSubscriptionDo
|
||||
WriteDB() IPlanSubscriptionDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IPlanSubscriptionDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IPlanSubscriptionDo
|
||||
Not(conds ...gen.Condition) IPlanSubscriptionDo
|
||||
Or(conds ...gen.Condition) IPlanSubscriptionDo
|
||||
Select(conds ...field.Expr) IPlanSubscriptionDo
|
||||
Where(conds ...gen.Condition) IPlanSubscriptionDo
|
||||
Order(conds ...field.Expr) IPlanSubscriptionDo
|
||||
Distinct(cols ...field.Expr) IPlanSubscriptionDo
|
||||
Omit(cols ...field.Expr) IPlanSubscriptionDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IPlanSubscriptionDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IPlanSubscriptionDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IPlanSubscriptionDo
|
||||
Group(cols ...field.Expr) IPlanSubscriptionDo
|
||||
Having(conds ...gen.Condition) IPlanSubscriptionDo
|
||||
Limit(limit int) IPlanSubscriptionDo
|
||||
Offset(offset int) IPlanSubscriptionDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IPlanSubscriptionDo
|
||||
Unscoped() IPlanSubscriptionDo
|
||||
Create(values ...*model.PlanSubscription) error
|
||||
CreateInBatches(values []*model.PlanSubscription, batchSize int) error
|
||||
Save(values ...*model.PlanSubscription) error
|
||||
First() (*model.PlanSubscription, error)
|
||||
Take() (*model.PlanSubscription, error)
|
||||
Last() (*model.PlanSubscription, error)
|
||||
Find() ([]*model.PlanSubscription, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.PlanSubscription, err error)
|
||||
FindInBatches(result *[]*model.PlanSubscription, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.PlanSubscription) (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) IPlanSubscriptionDo
|
||||
Assign(attrs ...field.AssignExpr) IPlanSubscriptionDo
|
||||
Joins(fields ...field.RelationField) IPlanSubscriptionDo
|
||||
Preload(fields ...field.RelationField) IPlanSubscriptionDo
|
||||
FirstOrInit() (*model.PlanSubscription, error)
|
||||
FirstOrCreate() (*model.PlanSubscription, error)
|
||||
FindByPage(offset int, limit int) (result []*model.PlanSubscription, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Rows() (*sql.Rows, error)
|
||||
Row() *sql.Row
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IPlanSubscriptionDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Debug() IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Debug())
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) WithContext(ctx context.Context) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) ReadDB() IPlanSubscriptionDo {
|
||||
return p.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) WriteDB() IPlanSubscriptionDo {
|
||||
return p.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Session(config *gorm.Session) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Session(config))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Clauses(conds ...clause.Expression) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Returning(value interface{}, columns ...string) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Not(conds ...gen.Condition) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Or(conds ...gen.Condition) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Select(conds ...field.Expr) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Where(conds ...gen.Condition) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Order(conds ...field.Expr) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Distinct(cols ...field.Expr) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Omit(cols ...field.Expr) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Join(table schema.Tabler, on ...field.Expr) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) LeftJoin(table schema.Tabler, on ...field.Expr) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) RightJoin(table schema.Tabler, on ...field.Expr) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Group(cols ...field.Expr) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Having(conds ...gen.Condition) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Limit(limit int) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Offset(offset int) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Unscoped() IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Create(values ...*model.PlanSubscription) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return p.DO.Create(values)
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) CreateInBatches(values []*model.PlanSubscription, batchSize int) error {
|
||||
return p.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 (p planSubscriptionDo) Save(values ...*model.PlanSubscription) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return p.DO.Save(values)
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) First() (*model.PlanSubscription, error) {
|
||||
if result, err := p.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.PlanSubscription), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Take() (*model.PlanSubscription, error) {
|
||||
if result, err := p.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.PlanSubscription), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Last() (*model.PlanSubscription, error) {
|
||||
if result, err := p.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.PlanSubscription), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Find() ([]*model.PlanSubscription, error) {
|
||||
result, err := p.DO.Find()
|
||||
return result.([]*model.PlanSubscription), err
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.PlanSubscription, err error) {
|
||||
buf := make([]*model.PlanSubscription, 0, batchSize)
|
||||
err = p.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 (p planSubscriptionDo) FindInBatches(result *[]*model.PlanSubscription, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return p.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Attrs(attrs ...field.AssignExpr) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Assign(attrs ...field.AssignExpr) IPlanSubscriptionDo {
|
||||
return p.withDO(p.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Joins(fields ...field.RelationField) IPlanSubscriptionDo {
|
||||
for _, _f := range fields {
|
||||
p = *p.withDO(p.DO.Joins(_f))
|
||||
}
|
||||
return &p
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Preload(fields ...field.RelationField) IPlanSubscriptionDo {
|
||||
for _, _f := range fields {
|
||||
p = *p.withDO(p.DO.Preload(_f))
|
||||
}
|
||||
return &p
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) FirstOrInit() (*model.PlanSubscription, error) {
|
||||
if result, err := p.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.PlanSubscription), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) FirstOrCreate() (*model.PlanSubscription, error) {
|
||||
if result, err := p.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.PlanSubscription), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) FindByPage(offset int, limit int) (result []*model.PlanSubscription, count int64, err error) {
|
||||
result, err = p.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 = p.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = p.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = p.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Scan(result interface{}) (err error) {
|
||||
return p.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (p planSubscriptionDo) Delete(models ...*model.PlanSubscription) (result gen.ResultInfo, err error) {
|
||||
return p.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (p *planSubscriptionDo) withDO(do gen.Dao) *planSubscriptionDo {
|
||||
p.DO = *do.(*gen.DO)
|
||||
return p
|
||||
}
|
||||
463
internal/database/query/user_preferences.gen.go
Normal file
463
internal/database/query/user_preferences.gen.go
Normal file
@@ -0,0 +1,463 @@
|
||||
// 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"
|
||||
"database/sql"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"stream.api/internal/database/model"
|
||||
)
|
||||
|
||||
func newUserPreference(db *gorm.DB, opts ...gen.DOOption) userPreference {
|
||||
_userPreference := userPreference{}
|
||||
|
||||
_userPreference.userPreferenceDo.UseDB(db, opts...)
|
||||
_userPreference.userPreferenceDo.UseModel(&model.UserPreference{})
|
||||
|
||||
tableName := _userPreference.userPreferenceDo.TableName()
|
||||
_userPreference.ALL = field.NewAsterisk(tableName)
|
||||
_userPreference.UserID = field.NewString(tableName, "user_id")
|
||||
_userPreference.Language = field.NewString(tableName, "language")
|
||||
_userPreference.Locale = field.NewString(tableName, "locale")
|
||||
_userPreference.EmailNotifications = field.NewBool(tableName, "email_notifications")
|
||||
_userPreference.PushNotifications = field.NewBool(tableName, "push_notifications")
|
||||
_userPreference.MarketingNotifications = field.NewBool(tableName, "marketing_notifications")
|
||||
_userPreference.TelegramNotifications = field.NewBool(tableName, "telegram_notifications")
|
||||
_userPreference.Autoplay = field.NewBool(tableName, "autoplay")
|
||||
_userPreference.Loop = field.NewBool(tableName, "loop")
|
||||
_userPreference.Muted = field.NewBool(tableName, "muted")
|
||||
_userPreference.ShowControls = field.NewBool(tableName, "show_controls")
|
||||
_userPreference.Pip = field.NewBool(tableName, "pip")
|
||||
_userPreference.Airplay = field.NewBool(tableName, "airplay")
|
||||
_userPreference.Chromecast = field.NewBool(tableName, "chromecast")
|
||||
_userPreference.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_userPreference.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_userPreference.EncrytionM3u8 = field.NewBool(tableName, "encrytion_m3u8")
|
||||
_userPreference.Version = field.NewInt64(tableName, "version")
|
||||
|
||||
_userPreference.fillFieldMap()
|
||||
|
||||
return _userPreference
|
||||
}
|
||||
|
||||
type userPreference struct {
|
||||
userPreferenceDo userPreferenceDo
|
||||
|
||||
ALL field.Asterisk
|
||||
UserID field.String
|
||||
Language field.String
|
||||
Locale field.String
|
||||
EmailNotifications field.Bool
|
||||
PushNotifications field.Bool
|
||||
MarketingNotifications field.Bool
|
||||
TelegramNotifications field.Bool
|
||||
Autoplay field.Bool
|
||||
Loop field.Bool
|
||||
Muted field.Bool
|
||||
ShowControls field.Bool
|
||||
Pip field.Bool
|
||||
Airplay field.Bool
|
||||
Chromecast field.Bool
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
EncrytionM3u8 field.Bool
|
||||
Version field.Int64
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (u userPreference) Table(newTableName string) *userPreference {
|
||||
u.userPreferenceDo.UseTable(newTableName)
|
||||
return u.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (u userPreference) As(alias string) *userPreference {
|
||||
u.userPreferenceDo.DO = *(u.userPreferenceDo.As(alias).(*gen.DO))
|
||||
return u.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (u *userPreference) updateTableName(table string) *userPreference {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.UserID = field.NewString(table, "user_id")
|
||||
u.Language = field.NewString(table, "language")
|
||||
u.Locale = field.NewString(table, "locale")
|
||||
u.EmailNotifications = field.NewBool(table, "email_notifications")
|
||||
u.PushNotifications = field.NewBool(table, "push_notifications")
|
||||
u.MarketingNotifications = field.NewBool(table, "marketing_notifications")
|
||||
u.TelegramNotifications = field.NewBool(table, "telegram_notifications")
|
||||
u.Autoplay = field.NewBool(table, "autoplay")
|
||||
u.Loop = field.NewBool(table, "loop")
|
||||
u.Muted = field.NewBool(table, "muted")
|
||||
u.ShowControls = field.NewBool(table, "show_controls")
|
||||
u.Pip = field.NewBool(table, "pip")
|
||||
u.Airplay = field.NewBool(table, "airplay")
|
||||
u.Chromecast = field.NewBool(table, "chromecast")
|
||||
u.CreatedAt = field.NewTime(table, "created_at")
|
||||
u.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
u.EncrytionM3u8 = field.NewBool(table, "encrytion_m3u8")
|
||||
u.Version = field.NewInt64(table, "version")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *userPreference) WithContext(ctx context.Context) IUserPreferenceDo {
|
||||
return u.userPreferenceDo.WithContext(ctx)
|
||||
}
|
||||
|
||||
func (u userPreference) TableName() string { return u.userPreferenceDo.TableName() }
|
||||
|
||||
func (u userPreference) Alias() string { return u.userPreferenceDo.Alias() }
|
||||
|
||||
func (u userPreference) Columns(cols ...field.Expr) gen.Columns {
|
||||
return u.userPreferenceDo.Columns(cols...)
|
||||
}
|
||||
|
||||
func (u *userPreference) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := u.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (u *userPreference) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 18)
|
||||
u.fieldMap["user_id"] = u.UserID
|
||||
u.fieldMap["language"] = u.Language
|
||||
u.fieldMap["locale"] = u.Locale
|
||||
u.fieldMap["email_notifications"] = u.EmailNotifications
|
||||
u.fieldMap["push_notifications"] = u.PushNotifications
|
||||
u.fieldMap["marketing_notifications"] = u.MarketingNotifications
|
||||
u.fieldMap["telegram_notifications"] = u.TelegramNotifications
|
||||
u.fieldMap["autoplay"] = u.Autoplay
|
||||
u.fieldMap["loop"] = u.Loop
|
||||
u.fieldMap["muted"] = u.Muted
|
||||
u.fieldMap["show_controls"] = u.ShowControls
|
||||
u.fieldMap["pip"] = u.Pip
|
||||
u.fieldMap["airplay"] = u.Airplay
|
||||
u.fieldMap["chromecast"] = u.Chromecast
|
||||
u.fieldMap["created_at"] = u.CreatedAt
|
||||
u.fieldMap["updated_at"] = u.UpdatedAt
|
||||
u.fieldMap["encrytion_m3u8"] = u.EncrytionM3u8
|
||||
u.fieldMap["version"] = u.Version
|
||||
}
|
||||
|
||||
func (u userPreference) clone(db *gorm.DB) userPreference {
|
||||
u.userPreferenceDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return u
|
||||
}
|
||||
|
||||
func (u userPreference) replaceDB(db *gorm.DB) userPreference {
|
||||
u.userPreferenceDo.ReplaceDB(db)
|
||||
return u
|
||||
}
|
||||
|
||||
type userPreferenceDo struct{ gen.DO }
|
||||
|
||||
type IUserPreferenceDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IUserPreferenceDo
|
||||
WithContext(ctx context.Context) IUserPreferenceDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IUserPreferenceDo
|
||||
WriteDB() IUserPreferenceDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IUserPreferenceDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IUserPreferenceDo
|
||||
Not(conds ...gen.Condition) IUserPreferenceDo
|
||||
Or(conds ...gen.Condition) IUserPreferenceDo
|
||||
Select(conds ...field.Expr) IUserPreferenceDo
|
||||
Where(conds ...gen.Condition) IUserPreferenceDo
|
||||
Order(conds ...field.Expr) IUserPreferenceDo
|
||||
Distinct(cols ...field.Expr) IUserPreferenceDo
|
||||
Omit(cols ...field.Expr) IUserPreferenceDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IUserPreferenceDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IUserPreferenceDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IUserPreferenceDo
|
||||
Group(cols ...field.Expr) IUserPreferenceDo
|
||||
Having(conds ...gen.Condition) IUserPreferenceDo
|
||||
Limit(limit int) IUserPreferenceDo
|
||||
Offset(offset int) IUserPreferenceDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IUserPreferenceDo
|
||||
Unscoped() IUserPreferenceDo
|
||||
Create(values ...*model.UserPreference) error
|
||||
CreateInBatches(values []*model.UserPreference, batchSize int) error
|
||||
Save(values ...*model.UserPreference) error
|
||||
First() (*model.UserPreference, error)
|
||||
Take() (*model.UserPreference, error)
|
||||
Last() (*model.UserPreference, error)
|
||||
Find() ([]*model.UserPreference, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.UserPreference, err error)
|
||||
FindInBatches(result *[]*model.UserPreference, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.UserPreference) (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) IUserPreferenceDo
|
||||
Assign(attrs ...field.AssignExpr) IUserPreferenceDo
|
||||
Joins(fields ...field.RelationField) IUserPreferenceDo
|
||||
Preload(fields ...field.RelationField) IUserPreferenceDo
|
||||
FirstOrInit() (*model.UserPreference, error)
|
||||
FirstOrCreate() (*model.UserPreference, error)
|
||||
FindByPage(offset int, limit int) (result []*model.UserPreference, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Rows() (*sql.Rows, error)
|
||||
Row() *sql.Row
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IUserPreferenceDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Debug() IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) WithContext(ctx context.Context) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) ReadDB() IUserPreferenceDo {
|
||||
return u.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) WriteDB() IUserPreferenceDo {
|
||||
return u.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Session(config *gorm.Session) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Session(config))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Clauses(conds ...clause.Expression) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Returning(value interface{}, columns ...string) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Not(conds ...gen.Condition) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Or(conds ...gen.Condition) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Select(conds ...field.Expr) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Where(conds ...gen.Condition) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Order(conds ...field.Expr) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Distinct(cols ...field.Expr) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Omit(cols ...field.Expr) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Join(table schema.Tabler, on ...field.Expr) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Group(cols ...field.Expr) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Having(conds ...gen.Condition) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Limit(limit int) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Offset(offset int) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Unscoped() IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Create(values ...*model.UserPreference) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Create(values)
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) CreateInBatches(values []*model.UserPreference, batchSize int) error {
|
||||
return u.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 (u userPreferenceDo) Save(values ...*model.UserPreference) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Save(values)
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) First() (*model.UserPreference, error) {
|
||||
if result, err := u.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.UserPreference), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Take() (*model.UserPreference, error) {
|
||||
if result, err := u.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.UserPreference), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Last() (*model.UserPreference, error) {
|
||||
if result, err := u.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.UserPreference), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Find() ([]*model.UserPreference, error) {
|
||||
result, err := u.DO.Find()
|
||||
return result.([]*model.UserPreference), err
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.UserPreference, err error) {
|
||||
buf := make([]*model.UserPreference, 0, batchSize)
|
||||
err = u.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 (u userPreferenceDo) FindInBatches(result *[]*model.UserPreference, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return u.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Attrs(attrs ...field.AssignExpr) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Assign(attrs ...field.AssignExpr) IUserPreferenceDo {
|
||||
return u.withDO(u.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Joins(fields ...field.RelationField) IUserPreferenceDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Joins(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Preload(fields ...field.RelationField) IUserPreferenceDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Preload(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) FirstOrInit() (*model.UserPreference, error) {
|
||||
if result, err := u.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.UserPreference), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) FirstOrCreate() (*model.UserPreference, error) {
|
||||
if result, err := u.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.UserPreference), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) FindByPage(offset int, limit int) (result []*model.UserPreference, count int64, err error) {
|
||||
result, err = u.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 = u.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = u.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = u.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Scan(result interface{}) (err error) {
|
||||
return u.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (u userPreferenceDo) Delete(models ...*model.UserPreference) (result gen.ResultInfo, err error) {
|
||||
return u.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (u *userPreferenceDo) withDO(do gen.Dao) *userPreferenceDo {
|
||||
u.DO = *do.(*gen.DO)
|
||||
return u
|
||||
}
|
||||
427
internal/database/query/video_ad_configs.gen.go
Normal file
427
internal/database/query/video_ad_configs.gen.go
Normal file
@@ -0,0 +1,427 @@
|
||||
// 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"
|
||||
"database/sql"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"stream.api/internal/database/model"
|
||||
)
|
||||
|
||||
func newVideoAdConfig(db *gorm.DB, opts ...gen.DOOption) videoAdConfig {
|
||||
_videoAdConfig := videoAdConfig{}
|
||||
|
||||
_videoAdConfig.videoAdConfigDo.UseDB(db, opts...)
|
||||
_videoAdConfig.videoAdConfigDo.UseModel(&model.VideoAdConfig{})
|
||||
|
||||
tableName := _videoAdConfig.videoAdConfigDo.TableName()
|
||||
_videoAdConfig.ALL = field.NewAsterisk(tableName)
|
||||
_videoAdConfig.VideoID = field.NewString(tableName, "video_id")
|
||||
_videoAdConfig.UserID = field.NewString(tableName, "user_id")
|
||||
_videoAdConfig.AdTemplateID = field.NewString(tableName, "ad_template_id")
|
||||
_videoAdConfig.VastTagURL = field.NewString(tableName, "vast_tag_url")
|
||||
_videoAdConfig.AdFormat = field.NewString(tableName, "ad_format")
|
||||
_videoAdConfig.Duration = field.NewInt64(tableName, "duration")
|
||||
_videoAdConfig.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_videoAdConfig.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_videoAdConfig.Version = field.NewInt64(tableName, "version")
|
||||
|
||||
_videoAdConfig.fillFieldMap()
|
||||
|
||||
return _videoAdConfig
|
||||
}
|
||||
|
||||
type videoAdConfig struct {
|
||||
videoAdConfigDo videoAdConfigDo
|
||||
|
||||
ALL field.Asterisk
|
||||
VideoID field.String
|
||||
UserID field.String
|
||||
AdTemplateID field.String
|
||||
VastTagURL field.String
|
||||
AdFormat field.String
|
||||
Duration field.Int64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
Version field.Int64
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (v videoAdConfig) Table(newTableName string) *videoAdConfig {
|
||||
v.videoAdConfigDo.UseTable(newTableName)
|
||||
return v.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (v videoAdConfig) As(alias string) *videoAdConfig {
|
||||
v.videoAdConfigDo.DO = *(v.videoAdConfigDo.As(alias).(*gen.DO))
|
||||
return v.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (v *videoAdConfig) updateTableName(table string) *videoAdConfig {
|
||||
v.ALL = field.NewAsterisk(table)
|
||||
v.VideoID = field.NewString(table, "video_id")
|
||||
v.UserID = field.NewString(table, "user_id")
|
||||
v.AdTemplateID = field.NewString(table, "ad_template_id")
|
||||
v.VastTagURL = field.NewString(table, "vast_tag_url")
|
||||
v.AdFormat = field.NewString(table, "ad_format")
|
||||
v.Duration = field.NewInt64(table, "duration")
|
||||
v.CreatedAt = field.NewTime(table, "created_at")
|
||||
v.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
v.Version = field.NewInt64(table, "version")
|
||||
|
||||
v.fillFieldMap()
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (v *videoAdConfig) WithContext(ctx context.Context) IVideoAdConfigDo {
|
||||
return v.videoAdConfigDo.WithContext(ctx)
|
||||
}
|
||||
|
||||
func (v videoAdConfig) TableName() string { return v.videoAdConfigDo.TableName() }
|
||||
|
||||
func (v videoAdConfig) Alias() string { return v.videoAdConfigDo.Alias() }
|
||||
|
||||
func (v videoAdConfig) Columns(cols ...field.Expr) gen.Columns {
|
||||
return v.videoAdConfigDo.Columns(cols...)
|
||||
}
|
||||
|
||||
func (v *videoAdConfig) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := v.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (v *videoAdConfig) fillFieldMap() {
|
||||
v.fieldMap = make(map[string]field.Expr, 9)
|
||||
v.fieldMap["video_id"] = v.VideoID
|
||||
v.fieldMap["user_id"] = v.UserID
|
||||
v.fieldMap["ad_template_id"] = v.AdTemplateID
|
||||
v.fieldMap["vast_tag_url"] = v.VastTagURL
|
||||
v.fieldMap["ad_format"] = v.AdFormat
|
||||
v.fieldMap["duration"] = v.Duration
|
||||
v.fieldMap["created_at"] = v.CreatedAt
|
||||
v.fieldMap["updated_at"] = v.UpdatedAt
|
||||
v.fieldMap["version"] = v.Version
|
||||
}
|
||||
|
||||
func (v videoAdConfig) clone(db *gorm.DB) videoAdConfig {
|
||||
v.videoAdConfigDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return v
|
||||
}
|
||||
|
||||
func (v videoAdConfig) replaceDB(db *gorm.DB) videoAdConfig {
|
||||
v.videoAdConfigDo.ReplaceDB(db)
|
||||
return v
|
||||
}
|
||||
|
||||
type videoAdConfigDo struct{ gen.DO }
|
||||
|
||||
type IVideoAdConfigDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IVideoAdConfigDo
|
||||
WithContext(ctx context.Context) IVideoAdConfigDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IVideoAdConfigDo
|
||||
WriteDB() IVideoAdConfigDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IVideoAdConfigDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IVideoAdConfigDo
|
||||
Not(conds ...gen.Condition) IVideoAdConfigDo
|
||||
Or(conds ...gen.Condition) IVideoAdConfigDo
|
||||
Select(conds ...field.Expr) IVideoAdConfigDo
|
||||
Where(conds ...gen.Condition) IVideoAdConfigDo
|
||||
Order(conds ...field.Expr) IVideoAdConfigDo
|
||||
Distinct(cols ...field.Expr) IVideoAdConfigDo
|
||||
Omit(cols ...field.Expr) IVideoAdConfigDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IVideoAdConfigDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IVideoAdConfigDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IVideoAdConfigDo
|
||||
Group(cols ...field.Expr) IVideoAdConfigDo
|
||||
Having(conds ...gen.Condition) IVideoAdConfigDo
|
||||
Limit(limit int) IVideoAdConfigDo
|
||||
Offset(offset int) IVideoAdConfigDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IVideoAdConfigDo
|
||||
Unscoped() IVideoAdConfigDo
|
||||
Create(values ...*model.VideoAdConfig) error
|
||||
CreateInBatches(values []*model.VideoAdConfig, batchSize int) error
|
||||
Save(values ...*model.VideoAdConfig) error
|
||||
First() (*model.VideoAdConfig, error)
|
||||
Take() (*model.VideoAdConfig, error)
|
||||
Last() (*model.VideoAdConfig, error)
|
||||
Find() ([]*model.VideoAdConfig, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.VideoAdConfig, err error)
|
||||
FindInBatches(result *[]*model.VideoAdConfig, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.VideoAdConfig) (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) IVideoAdConfigDo
|
||||
Assign(attrs ...field.AssignExpr) IVideoAdConfigDo
|
||||
Joins(fields ...field.RelationField) IVideoAdConfigDo
|
||||
Preload(fields ...field.RelationField) IVideoAdConfigDo
|
||||
FirstOrInit() (*model.VideoAdConfig, error)
|
||||
FirstOrCreate() (*model.VideoAdConfig, error)
|
||||
FindByPage(offset int, limit int) (result []*model.VideoAdConfig, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Rows() (*sql.Rows, error)
|
||||
Row() *sql.Row
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IVideoAdConfigDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Debug() IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Debug())
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) WithContext(ctx context.Context) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) ReadDB() IVideoAdConfigDo {
|
||||
return v.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) WriteDB() IVideoAdConfigDo {
|
||||
return v.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Session(config *gorm.Session) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Session(config))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Clauses(conds ...clause.Expression) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Returning(value interface{}, columns ...string) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Not(conds ...gen.Condition) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Or(conds ...gen.Condition) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Select(conds ...field.Expr) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Where(conds ...gen.Condition) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Order(conds ...field.Expr) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Distinct(cols ...field.Expr) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Omit(cols ...field.Expr) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Join(table schema.Tabler, on ...field.Expr) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) LeftJoin(table schema.Tabler, on ...field.Expr) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) RightJoin(table schema.Tabler, on ...field.Expr) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Group(cols ...field.Expr) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Having(conds ...gen.Condition) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Limit(limit int) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Offset(offset int) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Unscoped() IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Create(values ...*model.VideoAdConfig) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return v.DO.Create(values)
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) CreateInBatches(values []*model.VideoAdConfig, batchSize int) error {
|
||||
return v.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 (v videoAdConfigDo) Save(values ...*model.VideoAdConfig) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return v.DO.Save(values)
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) First() (*model.VideoAdConfig, error) {
|
||||
if result, err := v.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.VideoAdConfig), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Take() (*model.VideoAdConfig, error) {
|
||||
if result, err := v.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.VideoAdConfig), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Last() (*model.VideoAdConfig, error) {
|
||||
if result, err := v.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.VideoAdConfig), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Find() ([]*model.VideoAdConfig, error) {
|
||||
result, err := v.DO.Find()
|
||||
return result.([]*model.VideoAdConfig), err
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.VideoAdConfig, err error) {
|
||||
buf := make([]*model.VideoAdConfig, 0, batchSize)
|
||||
err = v.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 (v videoAdConfigDo) FindInBatches(result *[]*model.VideoAdConfig, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return v.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Attrs(attrs ...field.AssignExpr) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Assign(attrs ...field.AssignExpr) IVideoAdConfigDo {
|
||||
return v.withDO(v.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Joins(fields ...field.RelationField) IVideoAdConfigDo {
|
||||
for _, _f := range fields {
|
||||
v = *v.withDO(v.DO.Joins(_f))
|
||||
}
|
||||
return &v
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Preload(fields ...field.RelationField) IVideoAdConfigDo {
|
||||
for _, _f := range fields {
|
||||
v = *v.withDO(v.DO.Preload(_f))
|
||||
}
|
||||
return &v
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) FirstOrInit() (*model.VideoAdConfig, error) {
|
||||
if result, err := v.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.VideoAdConfig), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) FirstOrCreate() (*model.VideoAdConfig, error) {
|
||||
if result, err := v.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.VideoAdConfig), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) FindByPage(offset int, limit int) (result []*model.VideoAdConfig, count int64, err error) {
|
||||
result, err = v.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 = v.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = v.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = v.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Scan(result interface{}) (err error) {
|
||||
return v.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (v videoAdConfigDo) Delete(models ...*model.VideoAdConfig) (result gen.ResultInfo, err error) {
|
||||
return v.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (v *videoAdConfigDo) withDO(do gen.Dao) *videoAdConfigDo {
|
||||
v.DO = *do.(*gen.DO)
|
||||
return v
|
||||
}
|
||||
439
internal/database/query/wallet_transactions.gen.go
Normal file
439
internal/database/query/wallet_transactions.gen.go
Normal file
@@ -0,0 +1,439 @@
|
||||
// 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"
|
||||
"database/sql"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"stream.api/internal/database/model"
|
||||
)
|
||||
|
||||
func newWalletTransaction(db *gorm.DB, opts ...gen.DOOption) walletTransaction {
|
||||
_walletTransaction := walletTransaction{}
|
||||
|
||||
_walletTransaction.walletTransactionDo.UseDB(db, opts...)
|
||||
_walletTransaction.walletTransactionDo.UseModel(&model.WalletTransaction{})
|
||||
|
||||
tableName := _walletTransaction.walletTransactionDo.TableName()
|
||||
_walletTransaction.ALL = field.NewAsterisk(tableName)
|
||||
_walletTransaction.ID = field.NewString(tableName, "id")
|
||||
_walletTransaction.UserID = field.NewString(tableName, "user_id")
|
||||
_walletTransaction.Type = field.NewString(tableName, "type")
|
||||
_walletTransaction.Amount = field.NewFloat64(tableName, "amount")
|
||||
_walletTransaction.Currency = field.NewString(tableName, "currency")
|
||||
_walletTransaction.Note = field.NewString(tableName, "note")
|
||||
_walletTransaction.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_walletTransaction.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_walletTransaction.PaymentID = field.NewString(tableName, "payment_id")
|
||||
_walletTransaction.PlanID = field.NewString(tableName, "plan_id")
|
||||
_walletTransaction.TermMonths = field.NewInt32(tableName, "term_months")
|
||||
_walletTransaction.Version = field.NewInt64(tableName, "version")
|
||||
|
||||
_walletTransaction.fillFieldMap()
|
||||
|
||||
return _walletTransaction
|
||||
}
|
||||
|
||||
type walletTransaction struct {
|
||||
walletTransactionDo walletTransactionDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.String
|
||||
UserID field.String
|
||||
Type field.String
|
||||
Amount field.Float64
|
||||
Currency field.String
|
||||
Note field.String
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
PaymentID field.String
|
||||
PlanID field.String
|
||||
TermMonths field.Int32
|
||||
Version field.Int64
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (w walletTransaction) Table(newTableName string) *walletTransaction {
|
||||
w.walletTransactionDo.UseTable(newTableName)
|
||||
return w.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (w walletTransaction) As(alias string) *walletTransaction {
|
||||
w.walletTransactionDo.DO = *(w.walletTransactionDo.As(alias).(*gen.DO))
|
||||
return w.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (w *walletTransaction) updateTableName(table string) *walletTransaction {
|
||||
w.ALL = field.NewAsterisk(table)
|
||||
w.ID = field.NewString(table, "id")
|
||||
w.UserID = field.NewString(table, "user_id")
|
||||
w.Type = field.NewString(table, "type")
|
||||
w.Amount = field.NewFloat64(table, "amount")
|
||||
w.Currency = field.NewString(table, "currency")
|
||||
w.Note = field.NewString(table, "note")
|
||||
w.CreatedAt = field.NewTime(table, "created_at")
|
||||
w.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
w.PaymentID = field.NewString(table, "payment_id")
|
||||
w.PlanID = field.NewString(table, "plan_id")
|
||||
w.TermMonths = field.NewInt32(table, "term_months")
|
||||
w.Version = field.NewInt64(table, "version")
|
||||
|
||||
w.fillFieldMap()
|
||||
|
||||
return w
|
||||
}
|
||||
|
||||
func (w *walletTransaction) WithContext(ctx context.Context) IWalletTransactionDo {
|
||||
return w.walletTransactionDo.WithContext(ctx)
|
||||
}
|
||||
|
||||
func (w walletTransaction) TableName() string { return w.walletTransactionDo.TableName() }
|
||||
|
||||
func (w walletTransaction) Alias() string { return w.walletTransactionDo.Alias() }
|
||||
|
||||
func (w walletTransaction) Columns(cols ...field.Expr) gen.Columns {
|
||||
return w.walletTransactionDo.Columns(cols...)
|
||||
}
|
||||
|
||||
func (w *walletTransaction) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := w.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (w *walletTransaction) fillFieldMap() {
|
||||
w.fieldMap = make(map[string]field.Expr, 12)
|
||||
w.fieldMap["id"] = w.ID
|
||||
w.fieldMap["user_id"] = w.UserID
|
||||
w.fieldMap["type"] = w.Type
|
||||
w.fieldMap["amount"] = w.Amount
|
||||
w.fieldMap["currency"] = w.Currency
|
||||
w.fieldMap["note"] = w.Note
|
||||
w.fieldMap["created_at"] = w.CreatedAt
|
||||
w.fieldMap["updated_at"] = w.UpdatedAt
|
||||
w.fieldMap["payment_id"] = w.PaymentID
|
||||
w.fieldMap["plan_id"] = w.PlanID
|
||||
w.fieldMap["term_months"] = w.TermMonths
|
||||
w.fieldMap["version"] = w.Version
|
||||
}
|
||||
|
||||
func (w walletTransaction) clone(db *gorm.DB) walletTransaction {
|
||||
w.walletTransactionDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return w
|
||||
}
|
||||
|
||||
func (w walletTransaction) replaceDB(db *gorm.DB) walletTransaction {
|
||||
w.walletTransactionDo.ReplaceDB(db)
|
||||
return w
|
||||
}
|
||||
|
||||
type walletTransactionDo struct{ gen.DO }
|
||||
|
||||
type IWalletTransactionDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IWalletTransactionDo
|
||||
WithContext(ctx context.Context) IWalletTransactionDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IWalletTransactionDo
|
||||
WriteDB() IWalletTransactionDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IWalletTransactionDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IWalletTransactionDo
|
||||
Not(conds ...gen.Condition) IWalletTransactionDo
|
||||
Or(conds ...gen.Condition) IWalletTransactionDo
|
||||
Select(conds ...field.Expr) IWalletTransactionDo
|
||||
Where(conds ...gen.Condition) IWalletTransactionDo
|
||||
Order(conds ...field.Expr) IWalletTransactionDo
|
||||
Distinct(cols ...field.Expr) IWalletTransactionDo
|
||||
Omit(cols ...field.Expr) IWalletTransactionDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IWalletTransactionDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IWalletTransactionDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IWalletTransactionDo
|
||||
Group(cols ...field.Expr) IWalletTransactionDo
|
||||
Having(conds ...gen.Condition) IWalletTransactionDo
|
||||
Limit(limit int) IWalletTransactionDo
|
||||
Offset(offset int) IWalletTransactionDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IWalletTransactionDo
|
||||
Unscoped() IWalletTransactionDo
|
||||
Create(values ...*model.WalletTransaction) error
|
||||
CreateInBatches(values []*model.WalletTransaction, batchSize int) error
|
||||
Save(values ...*model.WalletTransaction) error
|
||||
First() (*model.WalletTransaction, error)
|
||||
Take() (*model.WalletTransaction, error)
|
||||
Last() (*model.WalletTransaction, error)
|
||||
Find() ([]*model.WalletTransaction, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.WalletTransaction, err error)
|
||||
FindInBatches(result *[]*model.WalletTransaction, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.WalletTransaction) (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) IWalletTransactionDo
|
||||
Assign(attrs ...field.AssignExpr) IWalletTransactionDo
|
||||
Joins(fields ...field.RelationField) IWalletTransactionDo
|
||||
Preload(fields ...field.RelationField) IWalletTransactionDo
|
||||
FirstOrInit() (*model.WalletTransaction, error)
|
||||
FirstOrCreate() (*model.WalletTransaction, error)
|
||||
FindByPage(offset int, limit int) (result []*model.WalletTransaction, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Rows() (*sql.Rows, error)
|
||||
Row() *sql.Row
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IWalletTransactionDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Debug() IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Debug())
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) WithContext(ctx context.Context) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) ReadDB() IWalletTransactionDo {
|
||||
return w.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) WriteDB() IWalletTransactionDo {
|
||||
return w.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Session(config *gorm.Session) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Session(config))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Clauses(conds ...clause.Expression) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Returning(value interface{}, columns ...string) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Not(conds ...gen.Condition) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Or(conds ...gen.Condition) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Select(conds ...field.Expr) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Where(conds ...gen.Condition) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Order(conds ...field.Expr) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Distinct(cols ...field.Expr) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Omit(cols ...field.Expr) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Join(table schema.Tabler, on ...field.Expr) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) LeftJoin(table schema.Tabler, on ...field.Expr) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) RightJoin(table schema.Tabler, on ...field.Expr) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Group(cols ...field.Expr) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Having(conds ...gen.Condition) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Limit(limit int) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Offset(offset int) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Unscoped() IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Create(values ...*model.WalletTransaction) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return w.DO.Create(values)
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) CreateInBatches(values []*model.WalletTransaction, batchSize int) error {
|
||||
return w.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 (w walletTransactionDo) Save(values ...*model.WalletTransaction) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return w.DO.Save(values)
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) First() (*model.WalletTransaction, error) {
|
||||
if result, err := w.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.WalletTransaction), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Take() (*model.WalletTransaction, error) {
|
||||
if result, err := w.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.WalletTransaction), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Last() (*model.WalletTransaction, error) {
|
||||
if result, err := w.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.WalletTransaction), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Find() ([]*model.WalletTransaction, error) {
|
||||
result, err := w.DO.Find()
|
||||
return result.([]*model.WalletTransaction), err
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.WalletTransaction, err error) {
|
||||
buf := make([]*model.WalletTransaction, 0, batchSize)
|
||||
err = w.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 (w walletTransactionDo) FindInBatches(result *[]*model.WalletTransaction, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return w.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Attrs(attrs ...field.AssignExpr) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Assign(attrs ...field.AssignExpr) IWalletTransactionDo {
|
||||
return w.withDO(w.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Joins(fields ...field.RelationField) IWalletTransactionDo {
|
||||
for _, _f := range fields {
|
||||
w = *w.withDO(w.DO.Joins(_f))
|
||||
}
|
||||
return &w
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Preload(fields ...field.RelationField) IWalletTransactionDo {
|
||||
for _, _f := range fields {
|
||||
w = *w.withDO(w.DO.Preload(_f))
|
||||
}
|
||||
return &w
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) FirstOrInit() (*model.WalletTransaction, error) {
|
||||
if result, err := w.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.WalletTransaction), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) FirstOrCreate() (*model.WalletTransaction, error) {
|
||||
if result, err := w.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.WalletTransaction), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) FindByPage(offset int, limit int) (result []*model.WalletTransaction, count int64, err error) {
|
||||
result, err = w.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 = w.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = w.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = w.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Scan(result interface{}) (err error) {
|
||||
return w.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (w walletTransactionDo) Delete(models ...*model.WalletTransaction) (result gen.ResultInfo, err error) {
|
||||
return w.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (w *walletTransactionDo) withDO(do gen.Dao) *walletTransactionDo {
|
||||
w.DO = *do.(*gen.DO)
|
||||
return w
|
||||
}
|
||||
Reference in New Issue
Block a user