|
|
// 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 newFissionCoin(db *gorm.DB, opts ...gen.DOOption) fissionCoin {
|
|
|
_fissionCoin := fissionCoin{}
|
|
|
|
|
|
_fissionCoin.fissionCoinDo.UseDB(db, opts...)
|
|
|
_fissionCoin.fissionCoinDo.UseModel(&model.FissionCoin{})
|
|
|
|
|
|
tableName := _fissionCoin.fissionCoinDo.TableName()
|
|
|
_fissionCoin.ALL = field.NewAsterisk(tableName)
|
|
|
_fissionCoin.ID = field.NewInt64(tableName, "id")
|
|
|
_fissionCoin.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_fissionCoin.UpdatedAt = field.NewInt64(tableName, "updated_at")
|
|
|
_fissionCoin.CampaignID = field.NewInt64(tableName, "campaign_id")
|
|
|
_fissionCoin.UserID = field.NewInt64(tableName, "user_id")
|
|
|
_fissionCoin.SceneID = field.NewInt64(tableName, "scene_id")
|
|
|
_fissionCoin.UseNum = field.NewInt32(tableName, "use_num")
|
|
|
_fissionCoin.UseCoin = field.NewInt32(tableName, "use_coin")
|
|
|
_fissionCoin.GetCoin = field.NewInt32(tableName, "get_coin")
|
|
|
_fissionCoin.Status = field.NewInt8(tableName, "status")
|
|
|
_fissionCoin.PreSceneOk = field.NewInt8(tableName, "pre_scene_ok")
|
|
|
|
|
|
_fissionCoin.fillFieldMap()
|
|
|
|
|
|
return _fissionCoin
|
|
|
}
|
|
|
|
|
|
type fissionCoin struct {
|
|
|
fissionCoinDo fissionCoinDo
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
ID field.Int64
|
|
|
CreatedAt field.Int64
|
|
|
UpdatedAt field.Int64
|
|
|
CampaignID field.Int64 // 活动id(fission_campaign表)
|
|
|
UserID field.Int64 // 用户id
|
|
|
SceneID field.Int64 // 场次id
|
|
|
UseNum field.Int32 // 投放次数
|
|
|
UseCoin field.Int32 // 投放金币总数
|
|
|
GetCoin field.Int32 // 领取的金币数
|
|
|
Status field.Int8 // 状态(1-未参与,2-待领取,3-已领取,4-未领取)
|
|
|
PreSceneOk field.Int8 // 上一场活动是否结算完毕(0-否,1-是)
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
}
|
|
|
|
|
|
func (f fissionCoin) Table(newTableName string) *fissionCoin {
|
|
|
f.fissionCoinDo.UseTable(newTableName)
|
|
|
return f.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (f fissionCoin) As(alias string) *fissionCoin {
|
|
|
f.fissionCoinDo.DO = *(f.fissionCoinDo.As(alias).(*gen.DO))
|
|
|
return f.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (f *fissionCoin) updateTableName(table string) *fissionCoin {
|
|
|
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.SceneID = field.NewInt64(table, "scene_id")
|
|
|
f.UseNum = field.NewInt32(table, "use_num")
|
|
|
f.UseCoin = field.NewInt32(table, "use_coin")
|
|
|
f.GetCoin = field.NewInt32(table, "get_coin")
|
|
|
f.Status = field.NewInt8(table, "status")
|
|
|
f.PreSceneOk = field.NewInt8(table, "pre_scene_ok")
|
|
|
|
|
|
f.fillFieldMap()
|
|
|
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f *fissionCoin) WithContext(ctx context.Context) *fissionCoinDo {
|
|
|
return f.fissionCoinDo.WithContext(ctx)
|
|
|
}
|
|
|
|
|
|
func (f fissionCoin) TableName() string { return f.fissionCoinDo.TableName() }
|
|
|
|
|
|
func (f fissionCoin) Alias() string { return f.fissionCoinDo.Alias() }
|
|
|
|
|
|
func (f *fissionCoin) 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 *fissionCoin) fillFieldMap() {
|
|
|
f.fieldMap = make(map[string]field.Expr, 11)
|
|
|
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["scene_id"] = f.SceneID
|
|
|
f.fieldMap["use_num"] = f.UseNum
|
|
|
f.fieldMap["use_coin"] = f.UseCoin
|
|
|
f.fieldMap["get_coin"] = f.GetCoin
|
|
|
f.fieldMap["status"] = f.Status
|
|
|
f.fieldMap["pre_scene_ok"] = f.PreSceneOk
|
|
|
}
|
|
|
|
|
|
func (f fissionCoin) clone(db *gorm.DB) fissionCoin {
|
|
|
f.fissionCoinDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f fissionCoin) replaceDB(db *gorm.DB) fissionCoin {
|
|
|
f.fissionCoinDo.ReplaceDB(db)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
type fissionCoinDo struct{ gen.DO }
|
|
|
|
|
|
func (f fissionCoinDo) Debug() *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) WithContext(ctx context.Context) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) ReadDB() *fissionCoinDo {
|
|
|
return f.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) WriteDB() *fissionCoinDo {
|
|
|
return f.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Session(config *gorm.Session) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Clauses(conds ...clause.Expression) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Returning(value interface{}, columns ...string) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Not(conds ...gen.Condition) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Or(conds ...gen.Condition) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Select(conds ...field.Expr) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Where(conds ...gen.Condition) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *fissionCoinDo {
|
|
|
return f.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Order(conds ...field.Expr) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Distinct(cols ...field.Expr) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Omit(cols ...field.Expr) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Join(table schema.Tabler, on ...field.Expr) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) LeftJoin(table schema.Tabler, on ...field.Expr) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) RightJoin(table schema.Tabler, on ...field.Expr) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Group(cols ...field.Expr) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Having(conds ...gen.Condition) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Limit(limit int) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Offset(offset int) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Unscoped() *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Create(values ...*model.FissionCoin) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) CreateInBatches(values []*model.FissionCoin, 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 fissionCoinDo) Save(values ...*model.FissionCoin) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) First() (*model.FissionCoin, error) {
|
|
|
if result, err := f.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionCoin), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Take() (*model.FissionCoin, error) {
|
|
|
if result, err := f.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionCoin), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Last() (*model.FissionCoin, error) {
|
|
|
if result, err := f.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionCoin), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Find() ([]*model.FissionCoin, error) {
|
|
|
result, err := f.DO.Find()
|
|
|
return result.([]*model.FissionCoin), err
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.FissionCoin, err error) {
|
|
|
buf := make([]*model.FissionCoin, 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 fissionCoinDo) FindInBatches(result *[]*model.FissionCoin, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return f.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Attrs(attrs ...field.AssignExpr) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Assign(attrs ...field.AssignExpr) *fissionCoinDo {
|
|
|
return f.withDO(f.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Joins(fields ...field.RelationField) *fissionCoinDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Joins(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Preload(fields ...field.RelationField) *fissionCoinDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Preload(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) FirstOrInit() (*model.FissionCoin, error) {
|
|
|
if result, err := f.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionCoin), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) FirstOrCreate() (*model.FissionCoin, error) {
|
|
|
if result, err := f.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionCoin), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) FindByPage(offset int, limit int) (result []*model.FissionCoin, 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 fissionCoinDo) 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 fissionCoinDo) Scan(result interface{}) (err error) {
|
|
|
return f.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (f fissionCoinDo) Delete(models ...*model.FissionCoin) (result gen.ResultInfo, err error) {
|
|
|
return f.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (f *fissionCoinDo) withDO(do gen.Dao) *fissionCoinDo {
|
|
|
f.DO = *do.(*gen.DO)
|
|
|
return f
|
|
|
}
|