365 lines
11 KiB
Go
365 lines
11 KiB
Go
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
|
|
package dao
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
"gorm.io/gorm/schema"
|
|
|
|
"gorm.io/gen"
|
|
"gorm.io/gen/field"
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
"bindbox-game/internal/repository/mysql/model"
|
|
)
|
|
|
|
func newLivestreamPrizes(db *gorm.DB, opts ...gen.DOOption) livestreamPrizes {
|
|
_livestreamPrizes := livestreamPrizes{}
|
|
|
|
_livestreamPrizes.livestreamPrizesDo.UseDB(db, opts...)
|
|
_livestreamPrizes.livestreamPrizesDo.UseModel(&model.LivestreamPrizes{})
|
|
|
|
tableName := _livestreamPrizes.livestreamPrizesDo.TableName()
|
|
_livestreamPrizes.ALL = field.NewAsterisk(tableName)
|
|
_livestreamPrizes.ID = field.NewInt64(tableName, "id")
|
|
_livestreamPrizes.ActivityID = field.NewInt64(tableName, "activity_id")
|
|
_livestreamPrizes.Name = field.NewString(tableName, "name")
|
|
_livestreamPrizes.Image = field.NewString(tableName, "image")
|
|
_livestreamPrizes.Weight = field.NewInt32(tableName, "weight")
|
|
_livestreamPrizes.Quantity = field.NewInt32(tableName, "quantity")
|
|
_livestreamPrizes.Remaining = field.NewInt32(tableName, "remaining")
|
|
_livestreamPrizes.Level = field.NewInt32(tableName, "level")
|
|
_livestreamPrizes.ProductID = field.NewInt64(tableName, "product_id")
|
|
_livestreamPrizes.Sort = field.NewInt32(tableName, "sort")
|
|
_livestreamPrizes.CreatedAt = field.NewTime(tableName, "created_at")
|
|
_livestreamPrizes.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
|
|
_livestreamPrizes.fillFieldMap()
|
|
|
|
return _livestreamPrizes
|
|
}
|
|
|
|
// livestreamPrizes 直播间奖品表
|
|
type livestreamPrizes struct {
|
|
livestreamPrizesDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int64 // 主键ID
|
|
ActivityID field.Int64 // 关联livestream_activities.id
|
|
Name field.String // 奖品名称
|
|
Image field.String // 奖品图片
|
|
Weight field.Int32 // 抽奖权重
|
|
Quantity field.Int32 // 库存数量(-1=无限)
|
|
Remaining field.Int32 // 剩余数量
|
|
Level field.Int32 // 奖品等级
|
|
ProductID field.Int64 // 关联系统商品ID
|
|
Sort field.Int32 // 排序
|
|
CreatedAt field.Time // 创建时间
|
|
UpdatedAt field.Time // 更新时间
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (l livestreamPrizes) Table(newTableName string) *livestreamPrizes {
|
|
l.livestreamPrizesDo.UseTable(newTableName)
|
|
return l.updateTableName(newTableName)
|
|
}
|
|
|
|
func (l livestreamPrizes) As(alias string) *livestreamPrizes {
|
|
l.livestreamPrizesDo.DO = *(l.livestreamPrizesDo.As(alias).(*gen.DO))
|
|
return l.updateTableName(alias)
|
|
}
|
|
|
|
func (l *livestreamPrizes) updateTableName(table string) *livestreamPrizes {
|
|
l.ALL = field.NewAsterisk(table)
|
|
l.ID = field.NewInt64(table, "id")
|
|
l.ActivityID = field.NewInt64(table, "activity_id")
|
|
l.Name = field.NewString(table, "name")
|
|
l.Image = field.NewString(table, "image")
|
|
l.Weight = field.NewInt32(table, "weight")
|
|
l.Quantity = field.NewInt32(table, "quantity")
|
|
l.Remaining = field.NewInt32(table, "remaining")
|
|
l.Level = field.NewInt32(table, "level")
|
|
l.ProductID = field.NewInt64(table, "product_id")
|
|
l.Sort = field.NewInt32(table, "sort")
|
|
l.CreatedAt = field.NewTime(table, "created_at")
|
|
l.UpdatedAt = field.NewTime(table, "updated_at")
|
|
|
|
l.fillFieldMap()
|
|
|
|
return l
|
|
}
|
|
|
|
func (l *livestreamPrizes) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
_f, ok := l.fieldMap[fieldName]
|
|
if !ok || _f == nil {
|
|
return nil, false
|
|
}
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
return _oe, ok
|
|
}
|
|
|
|
func (l *livestreamPrizes) fillFieldMap() {
|
|
l.fieldMap = make(map[string]field.Expr, 12)
|
|
l.fieldMap["id"] = l.ID
|
|
l.fieldMap["activity_id"] = l.ActivityID
|
|
l.fieldMap["name"] = l.Name
|
|
l.fieldMap["image"] = l.Image
|
|
l.fieldMap["weight"] = l.Weight
|
|
l.fieldMap["quantity"] = l.Quantity
|
|
l.fieldMap["remaining"] = l.Remaining
|
|
l.fieldMap["level"] = l.Level
|
|
l.fieldMap["product_id"] = l.ProductID
|
|
l.fieldMap["sort"] = l.Sort
|
|
l.fieldMap["created_at"] = l.CreatedAt
|
|
l.fieldMap["updated_at"] = l.UpdatedAt
|
|
}
|
|
|
|
func (l livestreamPrizes) clone(db *gorm.DB) livestreamPrizes {
|
|
l.livestreamPrizesDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return l
|
|
}
|
|
|
|
func (l livestreamPrizes) replaceDB(db *gorm.DB) livestreamPrizes {
|
|
l.livestreamPrizesDo.ReplaceDB(db)
|
|
return l
|
|
}
|
|
|
|
type livestreamPrizesDo struct{ gen.DO }
|
|
|
|
func (l livestreamPrizesDo) Debug() *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Debug())
|
|
}
|
|
|
|
func (l livestreamPrizesDo) WithContext(ctx context.Context) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) ReadDB() *livestreamPrizesDo {
|
|
return l.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (l livestreamPrizesDo) WriteDB() *livestreamPrizesDo {
|
|
return l.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Session(config *gorm.Session) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Session(config))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Clauses(conds ...clause.Expression) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Returning(value interface{}, columns ...string) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Not(conds ...gen.Condition) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Not(conds...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Or(conds ...gen.Condition) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Or(conds...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Select(conds ...field.Expr) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Select(conds...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Where(conds ...gen.Condition) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Where(conds...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Order(conds ...field.Expr) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Order(conds...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Distinct(cols ...field.Expr) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Omit(cols ...field.Expr) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Omit(cols...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Join(table schema.Tabler, on ...field.Expr) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Join(table, on...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) LeftJoin(table schema.Tabler, on ...field.Expr) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) RightJoin(table schema.Tabler, on ...field.Expr) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Group(cols ...field.Expr) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Group(cols...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Having(conds ...gen.Condition) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Having(conds...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Limit(limit int) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Limit(limit))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Offset(offset int) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Offset(offset))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Unscoped() *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Unscoped())
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Create(values ...*model.LivestreamPrizes) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return l.DO.Create(values)
|
|
}
|
|
|
|
func (l livestreamPrizesDo) CreateInBatches(values []*model.LivestreamPrizes, batchSize int) error {
|
|
return l.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 (l livestreamPrizesDo) Save(values ...*model.LivestreamPrizes) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return l.DO.Save(values)
|
|
}
|
|
|
|
func (l livestreamPrizesDo) First() (*model.LivestreamPrizes, error) {
|
|
if result, err := l.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.LivestreamPrizes), nil
|
|
}
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Take() (*model.LivestreamPrizes, error) {
|
|
if result, err := l.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.LivestreamPrizes), nil
|
|
}
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Last() (*model.LivestreamPrizes, error) {
|
|
if result, err := l.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.LivestreamPrizes), nil
|
|
}
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Find() ([]*model.LivestreamPrizes, error) {
|
|
result, err := l.DO.Find()
|
|
return result.([]*model.LivestreamPrizes), err
|
|
}
|
|
|
|
func (l livestreamPrizesDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.LivestreamPrizes, err error) {
|
|
buf := make([]*model.LivestreamPrizes, 0, batchSize)
|
|
err = l.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 (l livestreamPrizesDo) FindInBatches(result *[]*model.LivestreamPrizes, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return l.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Attrs(attrs ...field.AssignExpr) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Assign(attrs ...field.AssignExpr) *livestreamPrizesDo {
|
|
return l.withDO(l.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Joins(fields ...field.RelationField) *livestreamPrizesDo {
|
|
for _, _f := range fields {
|
|
l = *l.withDO(l.DO.Joins(_f))
|
|
}
|
|
return &l
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Preload(fields ...field.RelationField) *livestreamPrizesDo {
|
|
for _, _f := range fields {
|
|
l = *l.withDO(l.DO.Preload(_f))
|
|
}
|
|
return &l
|
|
}
|
|
|
|
func (l livestreamPrizesDo) FirstOrInit() (*model.LivestreamPrizes, error) {
|
|
if result, err := l.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.LivestreamPrizes), nil
|
|
}
|
|
}
|
|
|
|
func (l livestreamPrizesDo) FirstOrCreate() (*model.LivestreamPrizes, error) {
|
|
if result, err := l.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.LivestreamPrizes), nil
|
|
}
|
|
}
|
|
|
|
func (l livestreamPrizesDo) FindByPage(offset int, limit int) (result []*model.LivestreamPrizes, count int64, err error) {
|
|
result, err = l.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 = l.Offset(-1).Limit(-1).Count()
|
|
return
|
|
}
|
|
|
|
func (l livestreamPrizesDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
count, err = l.Count()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = l.Offset(offset).Limit(limit).Scan(result)
|
|
return
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Scan(result interface{}) (err error) {
|
|
return l.DO.Scan(result)
|
|
}
|
|
|
|
func (l livestreamPrizesDo) Delete(models ...*model.LivestreamPrizes) (result gen.ResultInfo, err error) {
|
|
return l.DO.Delete(models)
|
|
}
|
|
|
|
func (l *livestreamPrizesDo) withDO(do gen.Dao) *livestreamPrizesDo {
|
|
l.DO = *do.(*gen.DO)
|
|
return l
|
|
}
|