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