|
|
// 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"
|
|
|
|
|
|
"joybuywork/internal/repository/model"
|
|
|
)
|
|
|
|
|
|
func newFissionGashaponLog(db *gorm.DB, opts ...gen.DOOption) fissionGashaponLog {
|
|
|
_fissionGashaponLog := fissionGashaponLog{}
|
|
|
|
|
|
_fissionGashaponLog.fissionGashaponLogDo.UseDB(db, opts...)
|
|
|
_fissionGashaponLog.fissionGashaponLogDo.UseModel(&model.FissionGashaponLog{})
|
|
|
|
|
|
tableName := _fissionGashaponLog.fissionGashaponLogDo.TableName()
|
|
|
_fissionGashaponLog.ALL = field.NewAsterisk(tableName)
|
|
|
_fissionGashaponLog.ID = field.NewInt64(tableName, "id")
|
|
|
_fissionGashaponLog.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_fissionGashaponLog.UserID = field.NewInt64(tableName, "user_id")
|
|
|
_fissionGashaponLog.CampaignID = field.NewInt64(tableName, "campaign_id")
|
|
|
_fissionGashaponLog.GashaponID = field.NewInt64(tableName, "gashapon_id")
|
|
|
_fissionGashaponLog.Type = field.NewInt8(tableName, "type")
|
|
|
_fissionGashaponLog.Source = field.NewString(tableName, "source")
|
|
|
_fissionGashaponLog.Val = field.NewString(tableName, "val")
|
|
|
|
|
|
_fissionGashaponLog.fillFieldMap()
|
|
|
|
|
|
return _fissionGashaponLog
|
|
|
}
|
|
|
|
|
|
type fissionGashaponLog struct {
|
|
|
fissionGashaponLogDo fissionGashaponLogDo
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
ID field.Int64
|
|
|
CreatedAt field.Int64
|
|
|
UserID field.Int64 // 活动用户ID(fission_user表主键)
|
|
|
CampaignID field.Int64 // 活动ID(fission_campaign表)
|
|
|
GashaponID field.Int64 // 玩家id(fission_gashapon表id)
|
|
|
Type field.Int8 // 日志类型(1-获得抽奖机会,2-抽奖)
|
|
|
Source field.String // 来源标识
|
|
|
Val field.String // 数据对象
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLog) Table(newTableName string) *fissionGashaponLog {
|
|
|
f.fissionGashaponLogDo.UseTable(newTableName)
|
|
|
return f.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLog) As(alias string) *fissionGashaponLog {
|
|
|
f.fissionGashaponLogDo.DO = *(f.fissionGashaponLogDo.As(alias).(*gen.DO))
|
|
|
return f.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (f *fissionGashaponLog) updateTableName(table string) *fissionGashaponLog {
|
|
|
f.ALL = field.NewAsterisk(table)
|
|
|
f.ID = field.NewInt64(table, "id")
|
|
|
f.CreatedAt = field.NewInt64(table, "created_at")
|
|
|
f.UserID = field.NewInt64(table, "user_id")
|
|
|
f.CampaignID = field.NewInt64(table, "campaign_id")
|
|
|
f.GashaponID = field.NewInt64(table, "gashapon_id")
|
|
|
f.Type = field.NewInt8(table, "type")
|
|
|
f.Source = field.NewString(table, "source")
|
|
|
f.Val = field.NewString(table, "val")
|
|
|
|
|
|
f.fillFieldMap()
|
|
|
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f *fissionGashaponLog) WithContext(ctx context.Context) *fissionGashaponLogDo {
|
|
|
return f.fissionGashaponLogDo.WithContext(ctx)
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLog) TableName() string { return f.fissionGashaponLogDo.TableName() }
|
|
|
|
|
|
func (f fissionGashaponLog) Alias() string { return f.fissionGashaponLogDo.Alias() }
|
|
|
|
|
|
func (f *fissionGashaponLog) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
|
_f, ok := f.fieldMap[fieldName]
|
|
|
if !ok || _f == nil {
|
|
|
return nil, false
|
|
|
}
|
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
|
return _oe, ok
|
|
|
}
|
|
|
|
|
|
func (f *fissionGashaponLog) fillFieldMap() {
|
|
|
f.fieldMap = make(map[string]field.Expr, 8)
|
|
|
f.fieldMap["id"] = f.ID
|
|
|
f.fieldMap["created_at"] = f.CreatedAt
|
|
|
f.fieldMap["user_id"] = f.UserID
|
|
|
f.fieldMap["campaign_id"] = f.CampaignID
|
|
|
f.fieldMap["gashapon_id"] = f.GashaponID
|
|
|
f.fieldMap["type"] = f.Type
|
|
|
f.fieldMap["source"] = f.Source
|
|
|
f.fieldMap["val"] = f.Val
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLog) clone(db *gorm.DB) fissionGashaponLog {
|
|
|
f.fissionGashaponLogDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLog) replaceDB(db *gorm.DB) fissionGashaponLog {
|
|
|
f.fissionGashaponLogDo.ReplaceDB(db)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
type fissionGashaponLogDo struct{ gen.DO }
|
|
|
|
|
|
func (f fissionGashaponLogDo) Debug() *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) WithContext(ctx context.Context) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) ReadDB() *fissionGashaponLogDo {
|
|
|
return f.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) WriteDB() *fissionGashaponLogDo {
|
|
|
return f.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Session(config *gorm.Session) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Clauses(conds ...clause.Expression) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Returning(value interface{}, columns ...string) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Not(conds ...gen.Condition) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Or(conds ...gen.Condition) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Select(conds ...field.Expr) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Where(conds ...gen.Condition) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *fissionGashaponLogDo {
|
|
|
return f.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Order(conds ...field.Expr) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Distinct(cols ...field.Expr) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Omit(cols ...field.Expr) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Join(table schema.Tabler, on ...field.Expr) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) LeftJoin(table schema.Tabler, on ...field.Expr) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) RightJoin(table schema.Tabler, on ...field.Expr) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Group(cols ...field.Expr) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Having(conds ...gen.Condition) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Limit(limit int) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Offset(offset int) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Unscoped() *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Create(values ...*model.FissionGashaponLog) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) CreateInBatches(values []*model.FissionGashaponLog, batchSize int) error {
|
|
|
return f.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 (f fissionGashaponLogDo) Save(values ...*model.FissionGashaponLog) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) First() (*model.FissionGashaponLog, error) {
|
|
|
if result, err := f.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionGashaponLog), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Take() (*model.FissionGashaponLog, error) {
|
|
|
if result, err := f.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionGashaponLog), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Last() (*model.FissionGashaponLog, error) {
|
|
|
if result, err := f.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionGashaponLog), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Find() ([]*model.FissionGashaponLog, error) {
|
|
|
result, err := f.DO.Find()
|
|
|
return result.([]*model.FissionGashaponLog), err
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.FissionGashaponLog, err error) {
|
|
|
buf := make([]*model.FissionGashaponLog, 0, batchSize)
|
|
|
err = f.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 (f fissionGashaponLogDo) FindInBatches(result *[]*model.FissionGashaponLog, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return f.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Attrs(attrs ...field.AssignExpr) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Assign(attrs ...field.AssignExpr) *fissionGashaponLogDo {
|
|
|
return f.withDO(f.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Joins(fields ...field.RelationField) *fissionGashaponLogDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Joins(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Preload(fields ...field.RelationField) *fissionGashaponLogDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Preload(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) FirstOrInit() (*model.FissionGashaponLog, error) {
|
|
|
if result, err := f.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionGashaponLog), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) FirstOrCreate() (*model.FissionGashaponLog, error) {
|
|
|
if result, err := f.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionGashaponLog), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) FindByPage(offset int, limit int) (result []*model.FissionGashaponLog, count int64, err error) {
|
|
|
result, err = f.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 = f.Offset(-1).Limit(-1).Count()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
|
count, err = f.Count()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
err = f.Offset(offset).Limit(limit).Scan(result)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Scan(result interface{}) (err error) {
|
|
|
return f.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponLogDo) Delete(models ...*model.FissionGashaponLog) (result gen.ResultInfo, err error) {
|
|
|
return f.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (f *fissionGashaponLogDo) withDO(do gen.Dao) *fissionGashaponLogDo {
|
|
|
f.DO = *do.(*gen.DO)
|
|
|
return f
|
|
|
}
|