|
|
// 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 newFissionKeep(db *gorm.DB, opts ...gen.DOOption) fissionKeep {
|
|
|
_fissionKeep := fissionKeep{}
|
|
|
|
|
|
_fissionKeep.fissionKeepDo.UseDB(db, opts...)
|
|
|
_fissionKeep.fissionKeepDo.UseModel(&model.FissionKeep{})
|
|
|
|
|
|
tableName := _fissionKeep.fissionKeepDo.TableName()
|
|
|
_fissionKeep.ALL = field.NewAsterisk(tableName)
|
|
|
_fissionKeep.ID = field.NewInt64(tableName, "id")
|
|
|
_fissionKeep.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_fissionKeep.UpdatedAt = field.NewInt64(tableName, "updated_at")
|
|
|
_fissionKeep.CampaignID = field.NewInt64(tableName, "campaign_id")
|
|
|
_fissionKeep.UserID = field.NewInt64(tableName, "user_id")
|
|
|
_fissionKeep.Num = field.NewInt32(tableName, "num")
|
|
|
_fissionKeep.MachineNum = field.NewFloat64(tableName, "machine_num")
|
|
|
_fissionKeep.CollectNum = field.NewInt32(tableName, "collect_num")
|
|
|
_fissionKeep.Collect = field.NewInt32(tableName, "collect")
|
|
|
_fissionKeep.SecondNum = field.NewInt32(tableName, "second_num")
|
|
|
_fissionKeep.RewardID = field.NewInt64(tableName, "reward_id")
|
|
|
_fissionKeep.RecordID = field.NewInt64(tableName, "record_id")
|
|
|
_fissionKeep.FeedGetAt = field.NewInt64(tableName, "feed_get_at")
|
|
|
_fissionKeep.Step = field.NewInt32(tableName, "step")
|
|
|
_fissionKeep.ExpiredAt = field.NewInt64(tableName, "expired_at")
|
|
|
_fissionKeep.Guided = field.NewInt8(tableName, "guided")
|
|
|
_fissionKeep.InviteLimit = field.NewInt8(tableName, "invite_limit")
|
|
|
_fissionKeep.ReselectAt = field.NewInt64(tableName, "reselect_at")
|
|
|
_fissionKeep.CancelReward = field.NewInt8(tableName, "cancel_reward")
|
|
|
_fissionKeep.ReceiveOffline = field.NewInt64(tableName, "receive_offline")
|
|
|
|
|
|
_fissionKeep.fillFieldMap()
|
|
|
|
|
|
return _fissionKeep
|
|
|
}
|
|
|
|
|
|
type fissionKeep struct {
|
|
|
fissionKeepDo fissionKeepDo
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
ID field.Int64
|
|
|
CreatedAt field.Int64
|
|
|
UpdatedAt field.Int64
|
|
|
CampaignID field.Int64 // 活动ID(fission_campaign表)
|
|
|
UserID field.Int64 // 用户id
|
|
|
Num field.Int32 // 剩余总道具数
|
|
|
MachineNum field.Float64 // 机器产生的道具数
|
|
|
CollectNum field.Int32 // 获得的总一级道具数量
|
|
|
Collect field.Int32 // 可收集的一级道具数量
|
|
|
SecondNum field.Int32 // 收集的二级道具数量
|
|
|
RewardID field.Int64 // 选择的奖品id(fission_campaign_reward表)
|
|
|
RecordID field.Int64 // 选择奖品的获奖记录id(fission_reward_record表)
|
|
|
FeedGetAt field.Int64 // 最后一次获喂养道具的时间
|
|
|
Step field.Int32 // 养成阶段
|
|
|
ExpiredAt field.Int64 // 过期时间戳(单位:s)
|
|
|
Guided field.Int8 // 是否已经进行了引导
|
|
|
InviteLimit field.Int8 // 是否达到邀请上限(0-否,1-是)
|
|
|
ReselectAt field.Int64 // 重新下一个奖品时间
|
|
|
CancelReward field.Int8 // 是否取消了奖品(0-否,1-是)
|
|
|
ReceiveOffline field.Int64 // 最近一次领取离线狗粮时间
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
}
|
|
|
|
|
|
func (f fissionKeep) Table(newTableName string) *fissionKeep {
|
|
|
f.fissionKeepDo.UseTable(newTableName)
|
|
|
return f.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (f fissionKeep) As(alias string) *fissionKeep {
|
|
|
f.fissionKeepDo.DO = *(f.fissionKeepDo.As(alias).(*gen.DO))
|
|
|
return f.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (f *fissionKeep) updateTableName(table string) *fissionKeep {
|
|
|
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.Num = field.NewInt32(table, "num")
|
|
|
f.MachineNum = field.NewFloat64(table, "machine_num")
|
|
|
f.CollectNum = field.NewInt32(table, "collect_num")
|
|
|
f.Collect = field.NewInt32(table, "collect")
|
|
|
f.SecondNum = field.NewInt32(table, "second_num")
|
|
|
f.RewardID = field.NewInt64(table, "reward_id")
|
|
|
f.RecordID = field.NewInt64(table, "record_id")
|
|
|
f.FeedGetAt = field.NewInt64(table, "feed_get_at")
|
|
|
f.Step = field.NewInt32(table, "step")
|
|
|
f.ExpiredAt = field.NewInt64(table, "expired_at")
|
|
|
f.Guided = field.NewInt8(table, "guided")
|
|
|
f.InviteLimit = field.NewInt8(table, "invite_limit")
|
|
|
f.ReselectAt = field.NewInt64(table, "reselect_at")
|
|
|
f.CancelReward = field.NewInt8(table, "cancel_reward")
|
|
|
f.ReceiveOffline = field.NewInt64(table, "receive_offline")
|
|
|
|
|
|
f.fillFieldMap()
|
|
|
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f *fissionKeep) WithContext(ctx context.Context) *fissionKeepDo {
|
|
|
return f.fissionKeepDo.WithContext(ctx)
|
|
|
}
|
|
|
|
|
|
func (f fissionKeep) TableName() string { return f.fissionKeepDo.TableName() }
|
|
|
|
|
|
func (f fissionKeep) Alias() string { return f.fissionKeepDo.Alias() }
|
|
|
|
|
|
func (f *fissionKeep) 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 *fissionKeep) fillFieldMap() {
|
|
|
f.fieldMap = make(map[string]field.Expr, 20)
|
|
|
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["num"] = f.Num
|
|
|
f.fieldMap["machine_num"] = f.MachineNum
|
|
|
f.fieldMap["collect_num"] = f.CollectNum
|
|
|
f.fieldMap["collect"] = f.Collect
|
|
|
f.fieldMap["second_num"] = f.SecondNum
|
|
|
f.fieldMap["reward_id"] = f.RewardID
|
|
|
f.fieldMap["record_id"] = f.RecordID
|
|
|
f.fieldMap["feed_get_at"] = f.FeedGetAt
|
|
|
f.fieldMap["step"] = f.Step
|
|
|
f.fieldMap["expired_at"] = f.ExpiredAt
|
|
|
f.fieldMap["guided"] = f.Guided
|
|
|
f.fieldMap["invite_limit"] = f.InviteLimit
|
|
|
f.fieldMap["reselect_at"] = f.ReselectAt
|
|
|
f.fieldMap["cancel_reward"] = f.CancelReward
|
|
|
f.fieldMap["receive_offline"] = f.ReceiveOffline
|
|
|
}
|
|
|
|
|
|
func (f fissionKeep) clone(db *gorm.DB) fissionKeep {
|
|
|
f.fissionKeepDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f fissionKeep) replaceDB(db *gorm.DB) fissionKeep {
|
|
|
f.fissionKeepDo.ReplaceDB(db)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
type fissionKeepDo struct{ gen.DO }
|
|
|
|
|
|
func (f fissionKeepDo) Debug() *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) WithContext(ctx context.Context) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) ReadDB() *fissionKeepDo {
|
|
|
return f.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) WriteDB() *fissionKeepDo {
|
|
|
return f.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Session(config *gorm.Session) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Clauses(conds ...clause.Expression) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Returning(value interface{}, columns ...string) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Not(conds ...gen.Condition) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Or(conds ...gen.Condition) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Select(conds ...field.Expr) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Where(conds ...gen.Condition) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *fissionKeepDo {
|
|
|
return f.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Order(conds ...field.Expr) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Distinct(cols ...field.Expr) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Omit(cols ...field.Expr) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Join(table schema.Tabler, on ...field.Expr) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) LeftJoin(table schema.Tabler, on ...field.Expr) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) RightJoin(table schema.Tabler, on ...field.Expr) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Group(cols ...field.Expr) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Having(conds ...gen.Condition) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Limit(limit int) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Offset(offset int) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Unscoped() *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Create(values ...*model.FissionKeep) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) CreateInBatches(values []*model.FissionKeep, 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 fissionKeepDo) Save(values ...*model.FissionKeep) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) First() (*model.FissionKeep, error) {
|
|
|
if result, err := f.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionKeep), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Take() (*model.FissionKeep, error) {
|
|
|
if result, err := f.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionKeep), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Last() (*model.FissionKeep, error) {
|
|
|
if result, err := f.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionKeep), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Find() ([]*model.FissionKeep, error) {
|
|
|
result, err := f.DO.Find()
|
|
|
return result.([]*model.FissionKeep), err
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.FissionKeep, err error) {
|
|
|
buf := make([]*model.FissionKeep, 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 fissionKeepDo) FindInBatches(result *[]*model.FissionKeep, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return f.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Attrs(attrs ...field.AssignExpr) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Assign(attrs ...field.AssignExpr) *fissionKeepDo {
|
|
|
return f.withDO(f.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Joins(fields ...field.RelationField) *fissionKeepDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Joins(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Preload(fields ...field.RelationField) *fissionKeepDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Preload(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) FirstOrInit() (*model.FissionKeep, error) {
|
|
|
if result, err := f.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionKeep), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) FirstOrCreate() (*model.FissionKeep, error) {
|
|
|
if result, err := f.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionKeep), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) FindByPage(offset int, limit int) (result []*model.FissionKeep, 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 fissionKeepDo) 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 fissionKeepDo) Scan(result interface{}) (err error) {
|
|
|
return f.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (f fissionKeepDo) Delete(models ...*model.FissionKeep) (result gen.ResultInfo, err error) {
|
|
|
return f.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (f *fissionKeepDo) withDO(do gen.Dao) *fissionKeepDo {
|
|
|
f.DO = *do.(*gen.DO)
|
|
|
return f
|
|
|
}
|