|
|
// 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 newFissionDiceProp(db *gorm.DB, opts ...gen.DOOption) fissionDiceProp {
|
|
|
_fissionDiceProp := fissionDiceProp{}
|
|
|
|
|
|
_fissionDiceProp.fissionDicePropDo.UseDB(db, opts...)
|
|
|
_fissionDiceProp.fissionDicePropDo.UseModel(&model.FissionDiceProp{})
|
|
|
|
|
|
tableName := _fissionDiceProp.fissionDicePropDo.TableName()
|
|
|
_fissionDiceProp.ALL = field.NewAsterisk(tableName)
|
|
|
_fissionDiceProp.ID = field.NewInt64(tableName, "id")
|
|
|
_fissionDiceProp.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_fissionDiceProp.UpdatedAt = field.NewInt64(tableName, "updated_at")
|
|
|
_fissionDiceProp.UserID = field.NewInt64(tableName, "user_id")
|
|
|
_fissionDiceProp.CampaignID = field.NewInt64(tableName, "campaign_id")
|
|
|
_fissionDiceProp.Mark = field.NewString(tableName, "mark")
|
|
|
_fissionDiceProp.Num = field.NewInt32(tableName, "num")
|
|
|
_fissionDiceProp.TotalNum = field.NewInt32(tableName, "total_num")
|
|
|
|
|
|
_fissionDiceProp.fillFieldMap()
|
|
|
|
|
|
return _fissionDiceProp
|
|
|
}
|
|
|
|
|
|
type fissionDiceProp struct {
|
|
|
fissionDicePropDo fissionDicePropDo
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
ID field.Int64
|
|
|
CreatedAt field.Int64
|
|
|
UpdatedAt field.Int64
|
|
|
UserID field.Int64 // 活动用户ID(fission_user表主键)
|
|
|
CampaignID field.Int64 // 活动ID(fission_campaign表)
|
|
|
Mark field.String // 道具标识(chance-再来一次,fixed_roll-固定点数)
|
|
|
Num field.Int32 // 道具卡数量
|
|
|
TotalNum field.Int32 // 道具获得总数
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
}
|
|
|
|
|
|
func (f fissionDiceProp) Table(newTableName string) *fissionDiceProp {
|
|
|
f.fissionDicePropDo.UseTable(newTableName)
|
|
|
return f.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (f fissionDiceProp) As(alias string) *fissionDiceProp {
|
|
|
f.fissionDicePropDo.DO = *(f.fissionDicePropDo.As(alias).(*gen.DO))
|
|
|
return f.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (f *fissionDiceProp) updateTableName(table string) *fissionDiceProp {
|
|
|
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.Mark = field.NewString(table, "mark")
|
|
|
f.Num = field.NewInt32(table, "num")
|
|
|
f.TotalNum = field.NewInt32(table, "total_num")
|
|
|
|
|
|
f.fillFieldMap()
|
|
|
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f *fissionDiceProp) WithContext(ctx context.Context) *fissionDicePropDo {
|
|
|
return f.fissionDicePropDo.WithContext(ctx)
|
|
|
}
|
|
|
|
|
|
func (f fissionDiceProp) TableName() string { return f.fissionDicePropDo.TableName() }
|
|
|
|
|
|
func (f fissionDiceProp) Alias() string { return f.fissionDicePropDo.Alias() }
|
|
|
|
|
|
func (f *fissionDiceProp) 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 *fissionDiceProp) fillFieldMap() {
|
|
|
f.fieldMap = make(map[string]field.Expr, 8)
|
|
|
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["mark"] = f.Mark
|
|
|
f.fieldMap["num"] = f.Num
|
|
|
f.fieldMap["total_num"] = f.TotalNum
|
|
|
}
|
|
|
|
|
|
func (f fissionDiceProp) clone(db *gorm.DB) fissionDiceProp {
|
|
|
f.fissionDicePropDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f fissionDiceProp) replaceDB(db *gorm.DB) fissionDiceProp {
|
|
|
f.fissionDicePropDo.ReplaceDB(db)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
type fissionDicePropDo struct{ gen.DO }
|
|
|
|
|
|
func (f fissionDicePropDo) Debug() *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) WithContext(ctx context.Context) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) ReadDB() *fissionDicePropDo {
|
|
|
return f.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) WriteDB() *fissionDicePropDo {
|
|
|
return f.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Session(config *gorm.Session) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Clauses(conds ...clause.Expression) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Returning(value interface{}, columns ...string) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Not(conds ...gen.Condition) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Or(conds ...gen.Condition) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Select(conds ...field.Expr) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Where(conds ...gen.Condition) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *fissionDicePropDo {
|
|
|
return f.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Order(conds ...field.Expr) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Distinct(cols ...field.Expr) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Omit(cols ...field.Expr) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Join(table schema.Tabler, on ...field.Expr) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) LeftJoin(table schema.Tabler, on ...field.Expr) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) RightJoin(table schema.Tabler, on ...field.Expr) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Group(cols ...field.Expr) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Having(conds ...gen.Condition) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Limit(limit int) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Offset(offset int) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Unscoped() *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Create(values ...*model.FissionDiceProp) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) CreateInBatches(values []*model.FissionDiceProp, 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 fissionDicePropDo) Save(values ...*model.FissionDiceProp) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) First() (*model.FissionDiceProp, error) {
|
|
|
if result, err := f.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionDiceProp), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Take() (*model.FissionDiceProp, error) {
|
|
|
if result, err := f.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionDiceProp), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Last() (*model.FissionDiceProp, error) {
|
|
|
if result, err := f.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionDiceProp), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Find() ([]*model.FissionDiceProp, error) {
|
|
|
result, err := f.DO.Find()
|
|
|
return result.([]*model.FissionDiceProp), err
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.FissionDiceProp, err error) {
|
|
|
buf := make([]*model.FissionDiceProp, 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 fissionDicePropDo) FindInBatches(result *[]*model.FissionDiceProp, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return f.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Attrs(attrs ...field.AssignExpr) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Assign(attrs ...field.AssignExpr) *fissionDicePropDo {
|
|
|
return f.withDO(f.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Joins(fields ...field.RelationField) *fissionDicePropDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Joins(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Preload(fields ...field.RelationField) *fissionDicePropDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Preload(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) FirstOrInit() (*model.FissionDiceProp, error) {
|
|
|
if result, err := f.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionDiceProp), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) FirstOrCreate() (*model.FissionDiceProp, error) {
|
|
|
if result, err := f.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionDiceProp), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) FindByPage(offset int, limit int) (result []*model.FissionDiceProp, 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 fissionDicePropDo) 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 fissionDicePropDo) Scan(result interface{}) (err error) {
|
|
|
return f.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (f fissionDicePropDo) Delete(models ...*model.FissionDiceProp) (result gen.ResultInfo, err error) {
|
|
|
return f.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (f *fissionDicePropDo) withDO(do gen.Dao) *fissionDicePropDo {
|
|
|
f.DO = *do.(*gen.DO)
|
|
|
return f
|
|
|
}
|