|
|
// 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 newFissionGashapon(db *gorm.DB, opts ...gen.DOOption) fissionGashapon {
|
|
|
_fissionGashapon := fissionGashapon{}
|
|
|
|
|
|
_fissionGashapon.fissionGashaponDo.UseDB(db, opts...)
|
|
|
_fissionGashapon.fissionGashaponDo.UseModel(&model.FissionGashapon{})
|
|
|
|
|
|
tableName := _fissionGashapon.fissionGashaponDo.TableName()
|
|
|
_fissionGashapon.ALL = field.NewAsterisk(tableName)
|
|
|
_fissionGashapon.ID = field.NewInt64(tableName, "id")
|
|
|
_fissionGashapon.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_fissionGashapon.UpdatedAt = field.NewInt64(tableName, "updated_at")
|
|
|
_fissionGashapon.UserID = field.NewInt64(tableName, "user_id")
|
|
|
_fissionGashapon.CampaignID = field.NewInt64(tableName, "campaign_id")
|
|
|
_fissionGashapon.Chance = field.NewInt32(tableName, "chance")
|
|
|
_fissionGashapon.TaskChance = field.NewInt32(tableName, "task_chance")
|
|
|
_fissionGashapon.DayChance = field.NewInt32(tableName, "day_chance")
|
|
|
_fissionGashapon.LastSign = field.NewString(tableName, "last_sign")
|
|
|
_fissionGashapon.SetInit = field.NewInt8(tableName, "set_init")
|
|
|
|
|
|
_fissionGashapon.fillFieldMap()
|
|
|
|
|
|
return _fissionGashapon
|
|
|
}
|
|
|
|
|
|
type fissionGashapon struct {
|
|
|
fissionGashaponDo fissionGashaponDo
|
|
|
|
|
|
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 fissionGashapon) Table(newTableName string) *fissionGashapon {
|
|
|
f.fissionGashaponDo.UseTable(newTableName)
|
|
|
return f.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (f fissionGashapon) As(alias string) *fissionGashapon {
|
|
|
f.fissionGashaponDo.DO = *(f.fissionGashaponDo.As(alias).(*gen.DO))
|
|
|
return f.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (f *fissionGashapon) updateTableName(table string) *fissionGashapon {
|
|
|
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 *fissionGashapon) WithContext(ctx context.Context) *fissionGashaponDo {
|
|
|
return f.fissionGashaponDo.WithContext(ctx)
|
|
|
}
|
|
|
|
|
|
func (f fissionGashapon) TableName() string { return f.fissionGashaponDo.TableName() }
|
|
|
|
|
|
func (f fissionGashapon) Alias() string { return f.fissionGashaponDo.Alias() }
|
|
|
|
|
|
func (f *fissionGashapon) 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 *fissionGashapon) 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 fissionGashapon) clone(db *gorm.DB) fissionGashapon {
|
|
|
f.fissionGashaponDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f fissionGashapon) replaceDB(db *gorm.DB) fissionGashapon {
|
|
|
f.fissionGashaponDo.ReplaceDB(db)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
type fissionGashaponDo struct{ gen.DO }
|
|
|
|
|
|
func (f fissionGashaponDo) Debug() *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) WithContext(ctx context.Context) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) ReadDB() *fissionGashaponDo {
|
|
|
return f.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) WriteDB() *fissionGashaponDo {
|
|
|
return f.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Session(config *gorm.Session) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Clauses(conds ...clause.Expression) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Returning(value interface{}, columns ...string) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Not(conds ...gen.Condition) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Or(conds ...gen.Condition) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Select(conds ...field.Expr) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Where(conds ...gen.Condition) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *fissionGashaponDo {
|
|
|
return f.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Order(conds ...field.Expr) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Distinct(cols ...field.Expr) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Omit(cols ...field.Expr) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Join(table schema.Tabler, on ...field.Expr) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) LeftJoin(table schema.Tabler, on ...field.Expr) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) RightJoin(table schema.Tabler, on ...field.Expr) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Group(cols ...field.Expr) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Having(conds ...gen.Condition) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Limit(limit int) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Offset(offset int) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Unscoped() *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Create(values ...*model.FissionGashapon) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) CreateInBatches(values []*model.FissionGashapon, 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 fissionGashaponDo) Save(values ...*model.FissionGashapon) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) First() (*model.FissionGashapon, error) {
|
|
|
if result, err := f.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionGashapon), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Take() (*model.FissionGashapon, error) {
|
|
|
if result, err := f.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionGashapon), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Last() (*model.FissionGashapon, error) {
|
|
|
if result, err := f.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionGashapon), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Find() ([]*model.FissionGashapon, error) {
|
|
|
result, err := f.DO.Find()
|
|
|
return result.([]*model.FissionGashapon), err
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.FissionGashapon, err error) {
|
|
|
buf := make([]*model.FissionGashapon, 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 fissionGashaponDo) FindInBatches(result *[]*model.FissionGashapon, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return f.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Attrs(attrs ...field.AssignExpr) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Assign(attrs ...field.AssignExpr) *fissionGashaponDo {
|
|
|
return f.withDO(f.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Joins(fields ...field.RelationField) *fissionGashaponDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Joins(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Preload(fields ...field.RelationField) *fissionGashaponDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Preload(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) FirstOrInit() (*model.FissionGashapon, error) {
|
|
|
if result, err := f.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionGashapon), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) FirstOrCreate() (*model.FissionGashapon, error) {
|
|
|
if result, err := f.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionGashapon), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) FindByPage(offset int, limit int) (result []*model.FissionGashapon, 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 fissionGashaponDo) 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 fissionGashaponDo) Scan(result interface{}) (err error) {
|
|
|
return f.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (f fissionGashaponDo) Delete(models ...*model.FissionGashapon) (result gen.ResultInfo, err error) {
|
|
|
return f.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (f *fissionGashaponDo) withDO(do gen.Dao) *fissionGashaponDo {
|
|
|
f.DO = *do.(*gen.DO)
|
|
|
return f
|
|
|
}
|