|
|
// 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 newFissionFlip(db *gorm.DB, opts ...gen.DOOption) fissionFlip {
|
|
|
_fissionFlip := fissionFlip{}
|
|
|
|
|
|
_fissionFlip.fissionFlipDo.UseDB(db, opts...)
|
|
|
_fissionFlip.fissionFlipDo.UseModel(&model.FissionFlip{})
|
|
|
|
|
|
tableName := _fissionFlip.fissionFlipDo.TableName()
|
|
|
_fissionFlip.ALL = field.NewAsterisk(tableName)
|
|
|
_fissionFlip.ID = field.NewInt64(tableName, "id")
|
|
|
_fissionFlip.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_fissionFlip.UpdatedAt = field.NewInt64(tableName, "updated_at")
|
|
|
_fissionFlip.UserID = field.NewInt64(tableName, "user_id")
|
|
|
_fissionFlip.CampaignID = field.NewInt64(tableName, "campaign_id")
|
|
|
_fissionFlip.Chance = field.NewInt32(tableName, "chance")
|
|
|
_fissionFlip.TaskChance = field.NewInt32(tableName, "task_chance")
|
|
|
_fissionFlip.DayChance = field.NewInt32(tableName, "day_chance")
|
|
|
_fissionFlip.LastSign = field.NewString(tableName, "last_sign")
|
|
|
_fissionFlip.SetInit = field.NewInt8(tableName, "set_init")
|
|
|
|
|
|
_fissionFlip.fillFieldMap()
|
|
|
|
|
|
return _fissionFlip
|
|
|
}
|
|
|
|
|
|
type fissionFlip struct {
|
|
|
fissionFlipDo fissionFlipDo
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
ID field.Int64
|
|
|
CreatedAt field.Int64
|
|
|
UpdatedAt field.Int64
|
|
|
UserID field.Int64 // 活动用户ID(fission_user表主键)
|
|
|
CampaignID field.Int64 // 活动ID(fission_campaign表)
|
|
|
Chance field.Int32 // 抽奖机会数
|
|
|
TaskChance field.Int32 // 完成任务获取的抽奖次数
|
|
|
DayChance field.Int32 // 每日签到获得的抽奖次数
|
|
|
LastSign field.String // 最后签到日期
|
|
|
SetInit field.Int8 // 是否被设置过初始次数(0-否,1-是)
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
}
|
|
|
|
|
|
func (f fissionFlip) Table(newTableName string) *fissionFlip {
|
|
|
f.fissionFlipDo.UseTable(newTableName)
|
|
|
return f.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (f fissionFlip) As(alias string) *fissionFlip {
|
|
|
f.fissionFlipDo.DO = *(f.fissionFlipDo.As(alias).(*gen.DO))
|
|
|
return f.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (f *fissionFlip) updateTableName(table string) *fissionFlip {
|
|
|
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.UserID = field.NewInt64(table, "user_id")
|
|
|
f.CampaignID = field.NewInt64(table, "campaign_id")
|
|
|
f.Chance = field.NewInt32(table, "chance")
|
|
|
f.TaskChance = field.NewInt32(table, "task_chance")
|
|
|
f.DayChance = field.NewInt32(table, "day_chance")
|
|
|
f.LastSign = field.NewString(table, "last_sign")
|
|
|
f.SetInit = field.NewInt8(table, "set_init")
|
|
|
|
|
|
f.fillFieldMap()
|
|
|
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f *fissionFlip) WithContext(ctx context.Context) *fissionFlipDo {
|
|
|
return f.fissionFlipDo.WithContext(ctx)
|
|
|
}
|
|
|
|
|
|
func (f fissionFlip) TableName() string { return f.fissionFlipDo.TableName() }
|
|
|
|
|
|
func (f fissionFlip) Alias() string { return f.fissionFlipDo.Alias() }
|
|
|
|
|
|
func (f *fissionFlip) 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 *fissionFlip) fillFieldMap() {
|
|
|
f.fieldMap = make(map[string]field.Expr, 10)
|
|
|
f.fieldMap["id"] = f.ID
|
|
|
f.fieldMap["created_at"] = f.CreatedAt
|
|
|
f.fieldMap["updated_at"] = f.UpdatedAt
|
|
|
f.fieldMap["user_id"] = f.UserID
|
|
|
f.fieldMap["campaign_id"] = f.CampaignID
|
|
|
f.fieldMap["chance"] = f.Chance
|
|
|
f.fieldMap["task_chance"] = f.TaskChance
|
|
|
f.fieldMap["day_chance"] = f.DayChance
|
|
|
f.fieldMap["last_sign"] = f.LastSign
|
|
|
f.fieldMap["set_init"] = f.SetInit
|
|
|
}
|
|
|
|
|
|
func (f fissionFlip) clone(db *gorm.DB) fissionFlip {
|
|
|
f.fissionFlipDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f fissionFlip) replaceDB(db *gorm.DB) fissionFlip {
|
|
|
f.fissionFlipDo.ReplaceDB(db)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
type fissionFlipDo struct{ gen.DO }
|
|
|
|
|
|
func (f fissionFlipDo) Debug() *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) WithContext(ctx context.Context) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) ReadDB() *fissionFlipDo {
|
|
|
return f.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) WriteDB() *fissionFlipDo {
|
|
|
return f.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Session(config *gorm.Session) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Clauses(conds ...clause.Expression) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Returning(value interface{}, columns ...string) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Not(conds ...gen.Condition) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Or(conds ...gen.Condition) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Select(conds ...field.Expr) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Where(conds ...gen.Condition) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *fissionFlipDo {
|
|
|
return f.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Order(conds ...field.Expr) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Distinct(cols ...field.Expr) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Omit(cols ...field.Expr) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Join(table schema.Tabler, on ...field.Expr) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) LeftJoin(table schema.Tabler, on ...field.Expr) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) RightJoin(table schema.Tabler, on ...field.Expr) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Group(cols ...field.Expr) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Having(conds ...gen.Condition) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Limit(limit int) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Offset(offset int) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Unscoped() *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Create(values ...*model.FissionFlip) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) CreateInBatches(values []*model.FissionFlip, 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 fissionFlipDo) Save(values ...*model.FissionFlip) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) First() (*model.FissionFlip, error) {
|
|
|
if result, err := f.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionFlip), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Take() (*model.FissionFlip, error) {
|
|
|
if result, err := f.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionFlip), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Last() (*model.FissionFlip, error) {
|
|
|
if result, err := f.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionFlip), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Find() ([]*model.FissionFlip, error) {
|
|
|
result, err := f.DO.Find()
|
|
|
return result.([]*model.FissionFlip), err
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.FissionFlip, err error) {
|
|
|
buf := make([]*model.FissionFlip, 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 fissionFlipDo) FindInBatches(result *[]*model.FissionFlip, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return f.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Attrs(attrs ...field.AssignExpr) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Assign(attrs ...field.AssignExpr) *fissionFlipDo {
|
|
|
return f.withDO(f.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Joins(fields ...field.RelationField) *fissionFlipDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Joins(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Preload(fields ...field.RelationField) *fissionFlipDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Preload(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) FirstOrInit() (*model.FissionFlip, error) {
|
|
|
if result, err := f.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionFlip), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) FirstOrCreate() (*model.FissionFlip, error) {
|
|
|
if result, err := f.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionFlip), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) FindByPage(offset int, limit int) (result []*model.FissionFlip, 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 fissionFlipDo) 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 fissionFlipDo) Scan(result interface{}) (err error) {
|
|
|
return f.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (f fissionFlipDo) Delete(models ...*model.FissionFlip) (result gen.ResultInfo, err error) {
|
|
|
return f.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (f *fissionFlipDo) withDO(do gen.Dao) *fissionFlipDo {
|
|
|
f.DO = *do.(*gen.DO)
|
|
|
return f
|
|
|
}
|