|
|
// 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 newFissionCampaignGashapon(db *gorm.DB, opts ...gen.DOOption) fissionCampaignGashapon {
|
|
|
_fissionCampaignGashapon := fissionCampaignGashapon{}
|
|
|
|
|
|
_fissionCampaignGashapon.fissionCampaignGashaponDo.UseDB(db, opts...)
|
|
|
_fissionCampaignGashapon.fissionCampaignGashaponDo.UseModel(&model.FissionCampaignGashapon{})
|
|
|
|
|
|
tableName := _fissionCampaignGashapon.fissionCampaignGashaponDo.TableName()
|
|
|
_fissionCampaignGashapon.ALL = field.NewAsterisk(tableName)
|
|
|
_fissionCampaignGashapon.ID = field.NewInt64(tableName, "id")
|
|
|
_fissionCampaignGashapon.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_fissionCampaignGashapon.UpdatedAt = field.NewInt64(tableName, "updated_at")
|
|
|
_fissionCampaignGashapon.IsDel = field.NewUint8(tableName, "is_del")
|
|
|
_fissionCampaignGashapon.CampaignID = field.NewInt64(tableName, "campaign_id")
|
|
|
_fissionCampaignGashapon.InitChance = field.NewInt32(tableName, "init_chance")
|
|
|
_fissionCampaignGashapon.DayChance = field.NewInt32(tableName, "day_chance")
|
|
|
|
|
|
_fissionCampaignGashapon.fillFieldMap()
|
|
|
|
|
|
return _fissionCampaignGashapon
|
|
|
}
|
|
|
|
|
|
type fissionCampaignGashapon struct {
|
|
|
fissionCampaignGashaponDo fissionCampaignGashaponDo
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
ID field.Int64
|
|
|
CreatedAt field.Int64
|
|
|
UpdatedAt field.Int64
|
|
|
IsDel field.Uint8 // 是否已删除(1-是,0-否)
|
|
|
CampaignID field.Int64 // 活动ID
|
|
|
InitChance field.Int32 // 初始抽奖机会次数
|
|
|
DayChance field.Int32 // 每日获得的抽奖次数
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashapon) Table(newTableName string) *fissionCampaignGashapon {
|
|
|
f.fissionCampaignGashaponDo.UseTable(newTableName)
|
|
|
return f.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashapon) As(alias string) *fissionCampaignGashapon {
|
|
|
f.fissionCampaignGashaponDo.DO = *(f.fissionCampaignGashaponDo.As(alias).(*gen.DO))
|
|
|
return f.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (f *fissionCampaignGashapon) updateTableName(table string) *fissionCampaignGashapon {
|
|
|
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.IsDel = field.NewUint8(table, "is_del")
|
|
|
f.CampaignID = field.NewInt64(table, "campaign_id")
|
|
|
f.InitChance = field.NewInt32(table, "init_chance")
|
|
|
f.DayChance = field.NewInt32(table, "day_chance")
|
|
|
|
|
|
f.fillFieldMap()
|
|
|
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f *fissionCampaignGashapon) WithContext(ctx context.Context) *fissionCampaignGashaponDo {
|
|
|
return f.fissionCampaignGashaponDo.WithContext(ctx)
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashapon) TableName() string { return f.fissionCampaignGashaponDo.TableName() }
|
|
|
|
|
|
func (f fissionCampaignGashapon) Alias() string { return f.fissionCampaignGashaponDo.Alias() }
|
|
|
|
|
|
func (f *fissionCampaignGashapon) 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 *fissionCampaignGashapon) fillFieldMap() {
|
|
|
f.fieldMap = make(map[string]field.Expr, 7)
|
|
|
f.fieldMap["id"] = f.ID
|
|
|
f.fieldMap["created_at"] = f.CreatedAt
|
|
|
f.fieldMap["updated_at"] = f.UpdatedAt
|
|
|
f.fieldMap["is_del"] = f.IsDel
|
|
|
f.fieldMap["campaign_id"] = f.CampaignID
|
|
|
f.fieldMap["init_chance"] = f.InitChance
|
|
|
f.fieldMap["day_chance"] = f.DayChance
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashapon) clone(db *gorm.DB) fissionCampaignGashapon {
|
|
|
f.fissionCampaignGashaponDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashapon) replaceDB(db *gorm.DB) fissionCampaignGashapon {
|
|
|
f.fissionCampaignGashaponDo.ReplaceDB(db)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
type fissionCampaignGashaponDo struct{ gen.DO }
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Debug() *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) WithContext(ctx context.Context) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) ReadDB() *fissionCampaignGashaponDo {
|
|
|
return f.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) WriteDB() *fissionCampaignGashaponDo {
|
|
|
return f.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Session(config *gorm.Session) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Clauses(conds ...clause.Expression) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Returning(value interface{}, columns ...string) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Not(conds ...gen.Condition) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Or(conds ...gen.Condition) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Select(conds ...field.Expr) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Where(conds ...gen.Condition) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *fissionCampaignGashaponDo {
|
|
|
return f.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Order(conds ...field.Expr) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Distinct(cols ...field.Expr) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Omit(cols ...field.Expr) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Join(table schema.Tabler, on ...field.Expr) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) LeftJoin(table schema.Tabler, on ...field.Expr) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) RightJoin(table schema.Tabler, on ...field.Expr) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Group(cols ...field.Expr) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Having(conds ...gen.Condition) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Limit(limit int) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Offset(offset int) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Unscoped() *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Create(values ...*model.FissionCampaignGashapon) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) CreateInBatches(values []*model.FissionCampaignGashapon, 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 fissionCampaignGashaponDo) Save(values ...*model.FissionCampaignGashapon) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) First() (*model.FissionCampaignGashapon, error) {
|
|
|
if result, err := f.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionCampaignGashapon), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Take() (*model.FissionCampaignGashapon, error) {
|
|
|
if result, err := f.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionCampaignGashapon), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Last() (*model.FissionCampaignGashapon, error) {
|
|
|
if result, err := f.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionCampaignGashapon), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Find() ([]*model.FissionCampaignGashapon, error) {
|
|
|
result, err := f.DO.Find()
|
|
|
return result.([]*model.FissionCampaignGashapon), err
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.FissionCampaignGashapon, err error) {
|
|
|
buf := make([]*model.FissionCampaignGashapon, 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 fissionCampaignGashaponDo) FindInBatches(result *[]*model.FissionCampaignGashapon, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return f.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Attrs(attrs ...field.AssignExpr) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Assign(attrs ...field.AssignExpr) *fissionCampaignGashaponDo {
|
|
|
return f.withDO(f.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Joins(fields ...field.RelationField) *fissionCampaignGashaponDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Joins(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Preload(fields ...field.RelationField) *fissionCampaignGashaponDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Preload(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) FirstOrInit() (*model.FissionCampaignGashapon, error) {
|
|
|
if result, err := f.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionCampaignGashapon), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) FirstOrCreate() (*model.FissionCampaignGashapon, error) {
|
|
|
if result, err := f.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionCampaignGashapon), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) FindByPage(offset int, limit int) (result []*model.FissionCampaignGashapon, 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 fissionCampaignGashaponDo) 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 fissionCampaignGashaponDo) Scan(result interface{}) (err error) {
|
|
|
return f.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (f fissionCampaignGashaponDo) Delete(models ...*model.FissionCampaignGashapon) (result gen.ResultInfo, err error) {
|
|
|
return f.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (f *fissionCampaignGashaponDo) withDO(do gen.Dao) *fissionCampaignGashaponDo {
|
|
|
f.DO = *do.(*gen.DO)
|
|
|
return f
|
|
|
}
|