bindbox-game/internal/repository/mysql/dao/livestream_draw_logs.gen.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 newLivestreamDrawLogs(db *gorm.DB, opts ...gen.DOOption) livestreamDrawLogs {
_livestreamDrawLogs := livestreamDrawLogs{}
_livestreamDrawLogs.livestreamDrawLogsDo.UseDB(db, opts...)
_livestreamDrawLogs.livestreamDrawLogsDo.UseModel(&model.LivestreamDrawLogs{})
tableName := _livestreamDrawLogs.livestreamDrawLogsDo.TableName()
_livestreamDrawLogs.ALL = field.NewAsterisk(tableName)
_livestreamDrawLogs.ID = field.NewInt64(tableName, "id")
_livestreamDrawLogs.ActivityID = field.NewInt64(tableName, "activity_id")
_livestreamDrawLogs.PrizeID = field.NewInt64(tableName, "prize_id")
_livestreamDrawLogs.DouyinOrderID = field.NewInt64(tableName, "douyin_order_id")
_livestreamDrawLogs.LocalUserID = field.NewInt64(tableName, "local_user_id")
_livestreamDrawLogs.DouyinUserID = field.NewString(tableName, "douyin_user_id")
_livestreamDrawLogs.PrizeName = field.NewString(tableName, "prize_name")
_livestreamDrawLogs.Level = field.NewInt32(tableName, "level")
_livestreamDrawLogs.SeedHash = field.NewString(tableName, "seed_hash")
_livestreamDrawLogs.RandValue = field.NewInt64(tableName, "rand_value")
_livestreamDrawLogs.WeightsTotal = field.NewInt64(tableName, "weights_total")
_livestreamDrawLogs.CreatedAt = field.NewTime(tableName, "created_at")
_livestreamDrawLogs.fillFieldMap()
return _livestreamDrawLogs
}
// livestreamDrawLogs 直播间中奖记录表
type livestreamDrawLogs struct {
livestreamDrawLogsDo
ALL field.Asterisk
ID field.Int64 // 主键ID
ActivityID field.Int64 // 关联livestream_activities.id
PrizeID field.Int64 // 关联livestream_prizes.id
DouyinOrderID field.Int64 // 关联douyin_orders.id
LocalUserID field.Int64 // 本地用户ID
DouyinUserID field.String // 抖音用户ID
PrizeName field.String // 中奖奖品名称快照
Level field.Int32 // 奖品等级
SeedHash field.String // 哈希种子
RandValue field.Int64 // 随机值
WeightsTotal field.Int64 // 权重总和
CreatedAt field.Time // 中奖时间
fieldMap map[string]field.Expr
}
func (l livestreamDrawLogs) Table(newTableName string) *livestreamDrawLogs {
l.livestreamDrawLogsDo.UseTable(newTableName)
return l.updateTableName(newTableName)
}
func (l livestreamDrawLogs) As(alias string) *livestreamDrawLogs {
l.livestreamDrawLogsDo.DO = *(l.livestreamDrawLogsDo.As(alias).(*gen.DO))
return l.updateTableName(alias)
}
func (l *livestreamDrawLogs) updateTableName(table string) *livestreamDrawLogs {
l.ALL = field.NewAsterisk(table)
l.ID = field.NewInt64(table, "id")
l.ActivityID = field.NewInt64(table, "activity_id")
l.PrizeID = field.NewInt64(table, "prize_id")
l.DouyinOrderID = field.NewInt64(table, "douyin_order_id")
l.LocalUserID = field.NewInt64(table, "local_user_id")
l.DouyinUserID = field.NewString(table, "douyin_user_id")
l.PrizeName = field.NewString(table, "prize_name")
l.Level = field.NewInt32(table, "level")
l.SeedHash = field.NewString(table, "seed_hash")
l.RandValue = field.NewInt64(table, "rand_value")
l.WeightsTotal = field.NewInt64(table, "weights_total")
l.CreatedAt = field.NewTime(table, "created_at")
l.fillFieldMap()
return l
}
func (l *livestreamDrawLogs) 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 *livestreamDrawLogs) fillFieldMap() {
l.fieldMap = make(map[string]field.Expr, 12)
l.fieldMap["id"] = l.ID
l.fieldMap["activity_id"] = l.ActivityID
l.fieldMap["prize_id"] = l.PrizeID
l.fieldMap["douyin_order_id"] = l.DouyinOrderID
l.fieldMap["local_user_id"] = l.LocalUserID
l.fieldMap["douyin_user_id"] = l.DouyinUserID
l.fieldMap["prize_name"] = l.PrizeName
l.fieldMap["level"] = l.Level
l.fieldMap["seed_hash"] = l.SeedHash
l.fieldMap["rand_value"] = l.RandValue
l.fieldMap["weights_total"] = l.WeightsTotal
l.fieldMap["created_at"] = l.CreatedAt
}
func (l livestreamDrawLogs) clone(db *gorm.DB) livestreamDrawLogs {
l.livestreamDrawLogsDo.ReplaceConnPool(db.Statement.ConnPool)
return l
}
func (l livestreamDrawLogs) replaceDB(db *gorm.DB) livestreamDrawLogs {
l.livestreamDrawLogsDo.ReplaceDB(db)
return l
}
type livestreamDrawLogsDo struct{ gen.DO }
func (l livestreamDrawLogsDo) Debug() *livestreamDrawLogsDo {
return l.withDO(l.DO.Debug())
}
func (l livestreamDrawLogsDo) WithContext(ctx context.Context) *livestreamDrawLogsDo {
return l.withDO(l.DO.WithContext(ctx))
}
func (l livestreamDrawLogsDo) ReadDB() *livestreamDrawLogsDo {
return l.Clauses(dbresolver.Read)
}
func (l livestreamDrawLogsDo) WriteDB() *livestreamDrawLogsDo {
return l.Clauses(dbresolver.Write)
}
func (l livestreamDrawLogsDo) Session(config *gorm.Session) *livestreamDrawLogsDo {
return l.withDO(l.DO.Session(config))
}
func (l livestreamDrawLogsDo) Clauses(conds ...clause.Expression) *livestreamDrawLogsDo {
return l.withDO(l.DO.Clauses(conds...))
}
func (l livestreamDrawLogsDo) Returning(value interface{}, columns ...string) *livestreamDrawLogsDo {
return l.withDO(l.DO.Returning(value, columns...))
}
func (l livestreamDrawLogsDo) Not(conds ...gen.Condition) *livestreamDrawLogsDo {
return l.withDO(l.DO.Not(conds...))
}
func (l livestreamDrawLogsDo) Or(conds ...gen.Condition) *livestreamDrawLogsDo {
return l.withDO(l.DO.Or(conds...))
}
func (l livestreamDrawLogsDo) Select(conds ...field.Expr) *livestreamDrawLogsDo {
return l.withDO(l.DO.Select(conds...))
}
func (l livestreamDrawLogsDo) Where(conds ...gen.Condition) *livestreamDrawLogsDo {
return l.withDO(l.DO.Where(conds...))
}
func (l livestreamDrawLogsDo) Order(conds ...field.Expr) *livestreamDrawLogsDo {
return l.withDO(l.DO.Order(conds...))
}
func (l livestreamDrawLogsDo) Distinct(cols ...field.Expr) *livestreamDrawLogsDo {
return l.withDO(l.DO.Distinct(cols...))
}
func (l livestreamDrawLogsDo) Omit(cols ...field.Expr) *livestreamDrawLogsDo {
return l.withDO(l.DO.Omit(cols...))
}
func (l livestreamDrawLogsDo) Join(table schema.Tabler, on ...field.Expr) *livestreamDrawLogsDo {
return l.withDO(l.DO.Join(table, on...))
}
func (l livestreamDrawLogsDo) LeftJoin(table schema.Tabler, on ...field.Expr) *livestreamDrawLogsDo {
return l.withDO(l.DO.LeftJoin(table, on...))
}
func (l livestreamDrawLogsDo) RightJoin(table schema.Tabler, on ...field.Expr) *livestreamDrawLogsDo {
return l.withDO(l.DO.RightJoin(table, on...))
}
func (l livestreamDrawLogsDo) Group(cols ...field.Expr) *livestreamDrawLogsDo {
return l.withDO(l.DO.Group(cols...))
}
func (l livestreamDrawLogsDo) Having(conds ...gen.Condition) *livestreamDrawLogsDo {
return l.withDO(l.DO.Having(conds...))
}
func (l livestreamDrawLogsDo) Limit(limit int) *livestreamDrawLogsDo {
return l.withDO(l.DO.Limit(limit))
}
func (l livestreamDrawLogsDo) Offset(offset int) *livestreamDrawLogsDo {
return l.withDO(l.DO.Offset(offset))
}
func (l livestreamDrawLogsDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *livestreamDrawLogsDo {
return l.withDO(l.DO.Scopes(funcs...))
}
func (l livestreamDrawLogsDo) Unscoped() *livestreamDrawLogsDo {
return l.withDO(l.DO.Unscoped())
}
func (l livestreamDrawLogsDo) Create(values ...*model.LivestreamDrawLogs) error {
if len(values) == 0 {
return nil
}
return l.DO.Create(values)
}
func (l livestreamDrawLogsDo) CreateInBatches(values []*model.LivestreamDrawLogs, 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 livestreamDrawLogsDo) Save(values ...*model.LivestreamDrawLogs) error {
if len(values) == 0 {
return nil
}
return l.DO.Save(values)
}
func (l livestreamDrawLogsDo) First() (*model.LivestreamDrawLogs, error) {
if result, err := l.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.LivestreamDrawLogs), nil
}
}
func (l livestreamDrawLogsDo) Take() (*model.LivestreamDrawLogs, error) {
if result, err := l.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.LivestreamDrawLogs), nil
}
}
func (l livestreamDrawLogsDo) Last() (*model.LivestreamDrawLogs, error) {
if result, err := l.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.LivestreamDrawLogs), nil
}
}
func (l livestreamDrawLogsDo) Find() ([]*model.LivestreamDrawLogs, error) {
result, err := l.DO.Find()
return result.([]*model.LivestreamDrawLogs), err
}
func (l livestreamDrawLogsDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.LivestreamDrawLogs, err error) {
buf := make([]*model.LivestreamDrawLogs, 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 livestreamDrawLogsDo) FindInBatches(result *[]*model.LivestreamDrawLogs, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return l.DO.FindInBatches(result, batchSize, fc)
}
func (l livestreamDrawLogsDo) Attrs(attrs ...field.AssignExpr) *livestreamDrawLogsDo {
return l.withDO(l.DO.Attrs(attrs...))
}
func (l livestreamDrawLogsDo) Assign(attrs ...field.AssignExpr) *livestreamDrawLogsDo {
return l.withDO(l.DO.Assign(attrs...))
}
func (l livestreamDrawLogsDo) Joins(fields ...field.RelationField) *livestreamDrawLogsDo {
for _, _f := range fields {
l = *l.withDO(l.DO.Joins(_f))
}
return &l
}
func (l livestreamDrawLogsDo) Preload(fields ...field.RelationField) *livestreamDrawLogsDo {
for _, _f := range fields {
l = *l.withDO(l.DO.Preload(_f))
}
return &l
}
func (l livestreamDrawLogsDo) FirstOrInit() (*model.LivestreamDrawLogs, error) {
if result, err := l.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.LivestreamDrawLogs), nil
}
}
func (l livestreamDrawLogsDo) FirstOrCreate() (*model.LivestreamDrawLogs, error) {
if result, err := l.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.LivestreamDrawLogs), nil
}
}
func (l livestreamDrawLogsDo) FindByPage(offset int, limit int) (result []*model.LivestreamDrawLogs, 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 livestreamDrawLogsDo) 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 livestreamDrawLogsDo) Scan(result interface{}) (err error) {
return l.DO.Scan(result)
}
func (l livestreamDrawLogsDo) Delete(models ...*model.LivestreamDrawLogs) (result gen.ResultInfo, err error) {
return l.DO.Delete(models)
}
func (l *livestreamDrawLogsDo) withDO(do gen.Dao) *livestreamDrawLogsDo {
l.DO = *do.(*gen.DO)
return l
}