feat: Add player_configs feature and migrate user preferences
- Implemented player_configs table to store multiple player configurations per user. - Migrated existing player settings from user_preferences to player_configs. - Removed player-related columns from user_preferences. - Added referral state fields to user for tracking referral rewards. - Created migration scripts for database changes and data migration. - Added test cases for app services and usage helpers. - Introduced video job service interfaces and implementations.
This commit is contained in:
@@ -24,10 +24,10 @@ var (
|
||||
Payment *payment
|
||||
Plan *plan
|
||||
PlanSubscription *planSubscription
|
||||
PlayerConfig *playerConfig
|
||||
User *user
|
||||
UserPreference *userPreference
|
||||
Video *video
|
||||
VideoAdConfig *videoAdConfig
|
||||
WalletTransaction *walletTransaction
|
||||
)
|
||||
|
||||
@@ -40,10 +40,10 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
|
||||
Payment = &Q.Payment
|
||||
Plan = &Q.Plan
|
||||
PlanSubscription = &Q.PlanSubscription
|
||||
PlayerConfig = &Q.PlayerConfig
|
||||
User = &Q.User
|
||||
UserPreference = &Q.UserPreference
|
||||
Video = &Q.Video
|
||||
VideoAdConfig = &Q.VideoAdConfig
|
||||
WalletTransaction = &Q.WalletTransaction
|
||||
}
|
||||
|
||||
@@ -57,10 +57,10 @@ func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
|
||||
Payment: newPayment(db, opts...),
|
||||
Plan: newPlan(db, opts...),
|
||||
PlanSubscription: newPlanSubscription(db, opts...),
|
||||
PlayerConfig: newPlayerConfig(db, opts...),
|
||||
User: newUser(db, opts...),
|
||||
UserPreference: newUserPreference(db, opts...),
|
||||
Video: newVideo(db, opts...),
|
||||
VideoAdConfig: newVideoAdConfig(db, opts...),
|
||||
WalletTransaction: newWalletTransaction(db, opts...),
|
||||
}
|
||||
}
|
||||
@@ -75,10 +75,10 @@ type Query struct {
|
||||
Payment payment
|
||||
Plan plan
|
||||
PlanSubscription planSubscription
|
||||
PlayerConfig playerConfig
|
||||
User user
|
||||
UserPreference userPreference
|
||||
Video video
|
||||
VideoAdConfig videoAdConfig
|
||||
WalletTransaction walletTransaction
|
||||
}
|
||||
|
||||
@@ -94,10 +94,10 @@ func (q *Query) clone(db *gorm.DB) *Query {
|
||||
Payment: q.Payment.clone(db),
|
||||
Plan: q.Plan.clone(db),
|
||||
PlanSubscription: q.PlanSubscription.clone(db),
|
||||
PlayerConfig: q.PlayerConfig.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),
|
||||
}
|
||||
}
|
||||
@@ -120,10 +120,10 @@ func (q *Query) ReplaceDB(db *gorm.DB) *Query {
|
||||
Payment: q.Payment.replaceDB(db),
|
||||
Plan: q.Plan.replaceDB(db),
|
||||
PlanSubscription: q.PlanSubscription.replaceDB(db),
|
||||
PlayerConfig: q.PlayerConfig.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),
|
||||
}
|
||||
}
|
||||
@@ -136,10 +136,10 @@ type queryCtx struct {
|
||||
Payment IPaymentDo
|
||||
Plan IPlanDo
|
||||
PlanSubscription IPlanSubscriptionDo
|
||||
PlayerConfig IPlayerConfigDo
|
||||
User IUserDo
|
||||
UserPreference IUserPreferenceDo
|
||||
Video IVideoDo
|
||||
VideoAdConfig IVideoAdConfigDo
|
||||
WalletTransaction IWalletTransactionDo
|
||||
}
|
||||
|
||||
@@ -152,10 +152,10 @@ func (q *Query) WithContext(ctx context.Context) *queryCtx {
|
||||
Payment: q.Payment.WithContext(ctx),
|
||||
Plan: q.Plan.WithContext(ctx),
|
||||
PlanSubscription: q.PlanSubscription.WithContext(ctx),
|
||||
PlayerConfig: q.PlayerConfig.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),
|
||||
}
|
||||
}
|
||||
|
||||
463
internal/database/query/player_configs.gen.go
Normal file
463
internal/database/query/player_configs.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 newPlayerConfig(db *gorm.DB, opts ...gen.DOOption) playerConfig {
|
||||
_playerConfig := playerConfig{}
|
||||
|
||||
_playerConfig.playerConfigDo.UseDB(db, opts...)
|
||||
_playerConfig.playerConfigDo.UseModel(&model.PlayerConfig{})
|
||||
|
||||
tableName := _playerConfig.playerConfigDo.TableName()
|
||||
_playerConfig.ALL = field.NewAsterisk(tableName)
|
||||
_playerConfig.ID = field.NewString(tableName, "id")
|
||||
_playerConfig.UserID = field.NewString(tableName, "user_id")
|
||||
_playerConfig.Name = field.NewString(tableName, "name")
|
||||
_playerConfig.Description = field.NewString(tableName, "description")
|
||||
_playerConfig.Autoplay = field.NewBool(tableName, "autoplay")
|
||||
_playerConfig.Loop = field.NewBool(tableName, "loop")
|
||||
_playerConfig.Muted = field.NewBool(tableName, "muted")
|
||||
_playerConfig.ShowControls = field.NewBool(tableName, "show_controls")
|
||||
_playerConfig.Pip = field.NewBool(tableName, "pip")
|
||||
_playerConfig.Airplay = field.NewBool(tableName, "airplay")
|
||||
_playerConfig.Chromecast = field.NewBool(tableName, "chromecast")
|
||||
_playerConfig.IsActive = field.NewBool(tableName, "is_active")
|
||||
_playerConfig.IsDefault = field.NewBool(tableName, "is_default")
|
||||
_playerConfig.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_playerConfig.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_playerConfig.Version = field.NewInt64(tableName, "version")
|
||||
_playerConfig.EncrytionM3u8 = field.NewBool(tableName, "encrytion_m3u8")
|
||||
_playerConfig.LogoURL = field.NewString(tableName, "logo_url")
|
||||
|
||||
_playerConfig.fillFieldMap()
|
||||
|
||||
return _playerConfig
|
||||
}
|
||||
|
||||
type playerConfig struct {
|
||||
playerConfigDo playerConfigDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.String
|
||||
UserID field.String
|
||||
Name field.String
|
||||
Description field.String
|
||||
Autoplay field.Bool
|
||||
Loop field.Bool
|
||||
Muted field.Bool
|
||||
ShowControls field.Bool
|
||||
Pip field.Bool
|
||||
Airplay field.Bool
|
||||
Chromecast field.Bool
|
||||
IsActive field.Bool
|
||||
IsDefault field.Bool
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
Version field.Int64
|
||||
EncrytionM3u8 field.Bool
|
||||
LogoURL field.String
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (p playerConfig) Table(newTableName string) *playerConfig {
|
||||
p.playerConfigDo.UseTable(newTableName)
|
||||
return p.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (p playerConfig) As(alias string) *playerConfig {
|
||||
p.playerConfigDo.DO = *(p.playerConfigDo.As(alias).(*gen.DO))
|
||||
return p.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (p *playerConfig) updateTableName(table string) *playerConfig {
|
||||
p.ALL = field.NewAsterisk(table)
|
||||
p.ID = field.NewString(table, "id")
|
||||
p.UserID = field.NewString(table, "user_id")
|
||||
p.Name = field.NewString(table, "name")
|
||||
p.Description = field.NewString(table, "description")
|
||||
p.Autoplay = field.NewBool(table, "autoplay")
|
||||
p.Loop = field.NewBool(table, "loop")
|
||||
p.Muted = field.NewBool(table, "muted")
|
||||
p.ShowControls = field.NewBool(table, "show_controls")
|
||||
p.Pip = field.NewBool(table, "pip")
|
||||
p.Airplay = field.NewBool(table, "airplay")
|
||||
p.Chromecast = field.NewBool(table, "chromecast")
|
||||
p.IsActive = field.NewBool(table, "is_active")
|
||||
p.IsDefault = field.NewBool(table, "is_default")
|
||||
p.CreatedAt = field.NewTime(table, "created_at")
|
||||
p.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
p.Version = field.NewInt64(table, "version")
|
||||
p.EncrytionM3u8 = field.NewBool(table, "encrytion_m3u8")
|
||||
p.LogoURL = field.NewString(table, "logo_url")
|
||||
|
||||
p.fillFieldMap()
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *playerConfig) WithContext(ctx context.Context) IPlayerConfigDo {
|
||||
return p.playerConfigDo.WithContext(ctx)
|
||||
}
|
||||
|
||||
func (p playerConfig) TableName() string { return p.playerConfigDo.TableName() }
|
||||
|
||||
func (p playerConfig) Alias() string { return p.playerConfigDo.Alias() }
|
||||
|
||||
func (p playerConfig) Columns(cols ...field.Expr) gen.Columns {
|
||||
return p.playerConfigDo.Columns(cols...)
|
||||
}
|
||||
|
||||
func (p *playerConfig) 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 *playerConfig) fillFieldMap() {
|
||||
p.fieldMap = make(map[string]field.Expr, 18)
|
||||
p.fieldMap["id"] = p.ID
|
||||
p.fieldMap["user_id"] = p.UserID
|
||||
p.fieldMap["name"] = p.Name
|
||||
p.fieldMap["description"] = p.Description
|
||||
p.fieldMap["autoplay"] = p.Autoplay
|
||||
p.fieldMap["loop"] = p.Loop
|
||||
p.fieldMap["muted"] = p.Muted
|
||||
p.fieldMap["show_controls"] = p.ShowControls
|
||||
p.fieldMap["pip"] = p.Pip
|
||||
p.fieldMap["airplay"] = p.Airplay
|
||||
p.fieldMap["chromecast"] = p.Chromecast
|
||||
p.fieldMap["is_active"] = p.IsActive
|
||||
p.fieldMap["is_default"] = p.IsDefault
|
||||
p.fieldMap["created_at"] = p.CreatedAt
|
||||
p.fieldMap["updated_at"] = p.UpdatedAt
|
||||
p.fieldMap["version"] = p.Version
|
||||
p.fieldMap["encrytion_m3u8"] = p.EncrytionM3u8
|
||||
p.fieldMap["logo_url"] = p.LogoURL
|
||||
}
|
||||
|
||||
func (p playerConfig) clone(db *gorm.DB) playerConfig {
|
||||
p.playerConfigDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return p
|
||||
}
|
||||
|
||||
func (p playerConfig) replaceDB(db *gorm.DB) playerConfig {
|
||||
p.playerConfigDo.ReplaceDB(db)
|
||||
return p
|
||||
}
|
||||
|
||||
type playerConfigDo struct{ gen.DO }
|
||||
|
||||
type IPlayerConfigDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IPlayerConfigDo
|
||||
WithContext(ctx context.Context) IPlayerConfigDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IPlayerConfigDo
|
||||
WriteDB() IPlayerConfigDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IPlayerConfigDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IPlayerConfigDo
|
||||
Not(conds ...gen.Condition) IPlayerConfigDo
|
||||
Or(conds ...gen.Condition) IPlayerConfigDo
|
||||
Select(conds ...field.Expr) IPlayerConfigDo
|
||||
Where(conds ...gen.Condition) IPlayerConfigDo
|
||||
Order(conds ...field.Expr) IPlayerConfigDo
|
||||
Distinct(cols ...field.Expr) IPlayerConfigDo
|
||||
Omit(cols ...field.Expr) IPlayerConfigDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IPlayerConfigDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IPlayerConfigDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IPlayerConfigDo
|
||||
Group(cols ...field.Expr) IPlayerConfigDo
|
||||
Having(conds ...gen.Condition) IPlayerConfigDo
|
||||
Limit(limit int) IPlayerConfigDo
|
||||
Offset(offset int) IPlayerConfigDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IPlayerConfigDo
|
||||
Unscoped() IPlayerConfigDo
|
||||
Create(values ...*model.PlayerConfig) error
|
||||
CreateInBatches(values []*model.PlayerConfig, batchSize int) error
|
||||
Save(values ...*model.PlayerConfig) error
|
||||
First() (*model.PlayerConfig, error)
|
||||
Take() (*model.PlayerConfig, error)
|
||||
Last() (*model.PlayerConfig, error)
|
||||
Find() ([]*model.PlayerConfig, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.PlayerConfig, err error)
|
||||
FindInBatches(result *[]*model.PlayerConfig, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.PlayerConfig) (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) IPlayerConfigDo
|
||||
Assign(attrs ...field.AssignExpr) IPlayerConfigDo
|
||||
Joins(fields ...field.RelationField) IPlayerConfigDo
|
||||
Preload(fields ...field.RelationField) IPlayerConfigDo
|
||||
FirstOrInit() (*model.PlayerConfig, error)
|
||||
FirstOrCreate() (*model.PlayerConfig, error)
|
||||
FindByPage(offset int, limit int) (result []*model.PlayerConfig, 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) IPlayerConfigDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Debug() IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Debug())
|
||||
}
|
||||
|
||||
func (p playerConfigDo) WithContext(ctx context.Context) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) ReadDB() IPlayerConfigDo {
|
||||
return p.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (p playerConfigDo) WriteDB() IPlayerConfigDo {
|
||||
return p.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Session(config *gorm.Session) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Session(config))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Clauses(conds ...clause.Expression) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Returning(value interface{}, columns ...string) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Not(conds ...gen.Condition) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Or(conds ...gen.Condition) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Select(conds ...field.Expr) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Where(conds ...gen.Condition) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Order(conds ...field.Expr) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Distinct(cols ...field.Expr) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Omit(cols ...field.Expr) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Join(table schema.Tabler, on ...field.Expr) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) LeftJoin(table schema.Tabler, on ...field.Expr) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) RightJoin(table schema.Tabler, on ...field.Expr) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Group(cols ...field.Expr) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Having(conds ...gen.Condition) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Limit(limit int) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Offset(offset int) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Unscoped() IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Create(values ...*model.PlayerConfig) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return p.DO.Create(values)
|
||||
}
|
||||
|
||||
func (p playerConfigDo) CreateInBatches(values []*model.PlayerConfig, 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 playerConfigDo) Save(values ...*model.PlayerConfig) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return p.DO.Save(values)
|
||||
}
|
||||
|
||||
func (p playerConfigDo) First() (*model.PlayerConfig, error) {
|
||||
if result, err := p.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.PlayerConfig), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Take() (*model.PlayerConfig, error) {
|
||||
if result, err := p.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.PlayerConfig), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Last() (*model.PlayerConfig, error) {
|
||||
if result, err := p.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.PlayerConfig), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Find() ([]*model.PlayerConfig, error) {
|
||||
result, err := p.DO.Find()
|
||||
return result.([]*model.PlayerConfig), err
|
||||
}
|
||||
|
||||
func (p playerConfigDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.PlayerConfig, err error) {
|
||||
buf := make([]*model.PlayerConfig, 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 playerConfigDo) FindInBatches(result *[]*model.PlayerConfig, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return p.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Attrs(attrs ...field.AssignExpr) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Assign(attrs ...field.AssignExpr) IPlayerConfigDo {
|
||||
return p.withDO(p.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Joins(fields ...field.RelationField) IPlayerConfigDo {
|
||||
for _, _f := range fields {
|
||||
p = *p.withDO(p.DO.Joins(_f))
|
||||
}
|
||||
return &p
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Preload(fields ...field.RelationField) IPlayerConfigDo {
|
||||
for _, _f := range fields {
|
||||
p = *p.withDO(p.DO.Preload(_f))
|
||||
}
|
||||
return &p
|
||||
}
|
||||
|
||||
func (p playerConfigDo) FirstOrInit() (*model.PlayerConfig, error) {
|
||||
if result, err := p.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.PlayerConfig), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p playerConfigDo) FirstOrCreate() (*model.PlayerConfig, error) {
|
||||
if result, err := p.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.PlayerConfig), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p playerConfigDo) FindByPage(offset int, limit int) (result []*model.PlayerConfig, 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 playerConfigDo) 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 playerConfigDo) Scan(result interface{}) (err error) {
|
||||
return p.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (p playerConfigDo) Delete(models ...*model.PlayerConfig) (result gen.ResultInfo, err error) {
|
||||
return p.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (p *playerConfigDo) withDO(do gen.Dao) *playerConfigDo {
|
||||
p.DO = *do.(*gen.DO)
|
||||
return p
|
||||
}
|
||||
@@ -37,9 +37,16 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) user {
|
||||
_user.GoogleID = field.NewString(tableName, "google_id")
|
||||
_user.StorageUsed = field.NewInt64(tableName, "storage_used")
|
||||
_user.PlanID = field.NewString(tableName, "plan_id")
|
||||
_user.ReferredByUserID = field.NewString(tableName, "referred_by_user_id")
|
||||
_user.ReferralEligible = field.NewBool(tableName, "referral_eligible")
|
||||
_user.ReferralRewardBps = field.NewInt32(tableName, "referral_reward_bps")
|
||||
_user.ReferralRewardGrantedAt = field.NewTime(tableName, "referral_reward_granted_at")
|
||||
_user.ReferralRewardPaymentID = field.NewString(tableName, "referral_reward_payment_id")
|
||||
_user.ReferralRewardAmount = field.NewFloat64(tableName, "referral_reward_amount")
|
||||
_user.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_user.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_user.Version = field.NewInt64(tableName, "version")
|
||||
_user.TelegramID = field.NewString(tableName, "telegram_id")
|
||||
|
||||
_user.fillFieldMap()
|
||||
|
||||
@@ -57,11 +64,18 @@ type user struct {
|
||||
Avatar field.String
|
||||
Role field.String
|
||||
GoogleID field.String
|
||||
StorageUsed field.Int64
|
||||
PlanID field.String
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
Version field.Int64
|
||||
StorageUsed field.Int64
|
||||
PlanID field.String
|
||||
ReferredByUserID field.String
|
||||
ReferralEligible field.Bool
|
||||
ReferralRewardBps field.Int32
|
||||
ReferralRewardGrantedAt field.Time
|
||||
ReferralRewardPaymentID field.String
|
||||
ReferralRewardAmount field.Float64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
Version field.Int64
|
||||
TelegramID field.String
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
@@ -87,9 +101,16 @@ func (u *user) updateTableName(table string) *user {
|
||||
u.GoogleID = field.NewString(table, "google_id")
|
||||
u.StorageUsed = field.NewInt64(table, "storage_used")
|
||||
u.PlanID = field.NewString(table, "plan_id")
|
||||
u.ReferredByUserID = field.NewString(table, "referred_by_user_id")
|
||||
u.ReferralEligible = field.NewBool(table, "referral_eligible")
|
||||
u.ReferralRewardBps = field.NewInt32(table, "referral_reward_bps")
|
||||
u.ReferralRewardGrantedAt = field.NewTime(table, "referral_reward_granted_at")
|
||||
u.ReferralRewardPaymentID = field.NewString(table, "referral_reward_payment_id")
|
||||
u.ReferralRewardAmount = field.NewFloat64(table, "referral_reward_amount")
|
||||
u.CreatedAt = field.NewTime(table, "created_at")
|
||||
u.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
u.Version = field.NewInt64(table, "version")
|
||||
u.TelegramID = field.NewString(table, "telegram_id")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
@@ -114,7 +135,7 @@ func (u *user) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
}
|
||||
|
||||
func (u *user) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 12)
|
||||
u.fieldMap = make(map[string]field.Expr, 19)
|
||||
u.fieldMap["id"] = u.ID
|
||||
u.fieldMap["email"] = u.Email
|
||||
u.fieldMap["password"] = u.Password
|
||||
@@ -124,9 +145,16 @@ func (u *user) fillFieldMap() {
|
||||
u.fieldMap["google_id"] = u.GoogleID
|
||||
u.fieldMap["storage_used"] = u.StorageUsed
|
||||
u.fieldMap["plan_id"] = u.PlanID
|
||||
u.fieldMap["referred_by_user_id"] = u.ReferredByUserID
|
||||
u.fieldMap["referral_eligible"] = u.ReferralEligible
|
||||
u.fieldMap["referral_reward_bps"] = u.ReferralRewardBps
|
||||
u.fieldMap["referral_reward_granted_at"] = u.ReferralRewardGrantedAt
|
||||
u.fieldMap["referral_reward_payment_id"] = u.ReferralRewardPaymentID
|
||||
u.fieldMap["referral_reward_amount"] = u.ReferralRewardAmount
|
||||
u.fieldMap["created_at"] = u.CreatedAt
|
||||
u.fieldMap["updated_at"] = u.UpdatedAt
|
||||
u.fieldMap["version"] = u.Version
|
||||
u.fieldMap["telegram_id"] = u.TelegramID
|
||||
}
|
||||
|
||||
func (u user) clone(db *gorm.DB) user {
|
||||
|
||||
@@ -35,16 +35,8 @@ func newUserPreference(db *gorm.DB, opts ...gen.DOOption) userPreference {
|
||||
_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()
|
||||
@@ -63,16 +55,8 @@ type userPreference struct {
|
||||
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
|
||||
@@ -97,16 +81,8 @@ func (u *userPreference) updateTableName(table string) *userPreference {
|
||||
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()
|
||||
@@ -136,7 +112,7 @@ func (u *userPreference) GetFieldByName(fieldName string) (field.OrderExpr, bool
|
||||
}
|
||||
|
||||
func (u *userPreference) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 18)
|
||||
u.fieldMap = make(map[string]field.Expr, 10)
|
||||
u.fieldMap["user_id"] = u.UserID
|
||||
u.fieldMap["language"] = u.Language
|
||||
u.fieldMap["locale"] = u.Locale
|
||||
@@ -144,16 +120,8 @@ func (u *userPreference) fillFieldMap() {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ func newVideo(db *gorm.DB, opts ...gen.DOOption) video {
|
||||
_video.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_video.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_video.Version = field.NewInt64(tableName, "version")
|
||||
_video.AdID = field.NewString(tableName, "ad_id")
|
||||
_video.Metadata = field.NewField(tableName, "metadata")
|
||||
|
||||
_video.fillFieldMap()
|
||||
|
||||
@@ -76,6 +78,8 @@ type video struct {
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
Version field.Int64
|
||||
AdID field.String
|
||||
Metadata field.Field
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
@@ -111,6 +115,8 @@ func (v *video) updateTableName(table string) *video {
|
||||
v.CreatedAt = field.NewTime(table, "created_at")
|
||||
v.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
v.Version = field.NewInt64(table, "version")
|
||||
v.AdID = field.NewString(table, "ad_id")
|
||||
v.Metadata = field.NewField(table, "metadata")
|
||||
|
||||
v.fillFieldMap()
|
||||
|
||||
@@ -135,7 +141,7 @@ func (v *video) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
}
|
||||
|
||||
func (v *video) fillFieldMap() {
|
||||
v.fieldMap = make(map[string]field.Expr, 19)
|
||||
v.fieldMap = make(map[string]field.Expr, 21)
|
||||
v.fieldMap["id"] = v.ID
|
||||
v.fieldMap["name"] = v.Name
|
||||
v.fieldMap["title"] = v.Title
|
||||
@@ -155,6 +161,8 @@ func (v *video) fillFieldMap() {
|
||||
v.fieldMap["created_at"] = v.CreatedAt
|
||||
v.fieldMap["updated_at"] = v.UpdatedAt
|
||||
v.fieldMap["version"] = v.Version
|
||||
v.fieldMap["ad_id"] = v.AdID
|
||||
v.fieldMap["metadata"] = v.Metadata
|
||||
}
|
||||
|
||||
func (v video) clone(db *gorm.DB) video {
|
||||
|
||||
@@ -1,427 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user