|
|
// 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 newFissionChop(db *gorm.DB, opts ...gen.DOOption) fissionChop {
|
|
|
_fissionChop := fissionChop{}
|
|
|
|
|
|
_fissionChop.fissionChopDo.UseDB(db, opts...)
|
|
|
_fissionChop.fissionChopDo.UseModel(&model.FissionChop{})
|
|
|
|
|
|
tableName := _fissionChop.fissionChopDo.TableName()
|
|
|
_fissionChop.ALL = field.NewAsterisk(tableName)
|
|
|
_fissionChop.ID = field.NewInt64(tableName, "id")
|
|
|
_fissionChop.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_fissionChop.UpdatedAt = field.NewInt64(tableName, "updated_at")
|
|
|
_fissionChop.UserID = field.NewInt64(tableName, "user_id")
|
|
|
_fissionChop.CampaignID = field.NewInt64(tableName, "campaign_id")
|
|
|
_fissionChop.ChopRewardID = field.NewInt64(tableName, "chop_reward_id")
|
|
|
|
|
|
_fissionChop.fillFieldMap()
|
|
|
|
|
|
return _fissionChop
|
|
|
}
|
|
|
|
|
|
type fissionChop struct {
|
|
|
fissionChopDo fissionChopDo
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
ID field.Int64
|
|
|
CreatedAt field.Int64
|
|
|
UpdatedAt field.Int64
|
|
|
UserID field.Int64 // 活动用户ID(fission_user表主键)
|
|
|
CampaignID field.Int64 // 活动ID(fission_campaign表)
|
|
|
ChopRewardID field.Int64 // 选择的助力奖品id(fission_chop_reward表)
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
}
|
|
|
|
|
|
func (f fissionChop) Table(newTableName string) *fissionChop {
|
|
|
f.fissionChopDo.UseTable(newTableName)
|
|
|
return f.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (f fissionChop) As(alias string) *fissionChop {
|
|
|
f.fissionChopDo.DO = *(f.fissionChopDo.As(alias).(*gen.DO))
|
|
|
return f.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (f *fissionChop) updateTableName(table string) *fissionChop {
|
|
|
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.ChopRewardID = field.NewInt64(table, "chop_reward_id")
|
|
|
|
|
|
f.fillFieldMap()
|
|
|
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f *fissionChop) WithContext(ctx context.Context) *fissionChopDo {
|
|
|
return f.fissionChopDo.WithContext(ctx)
|
|
|
}
|
|
|
|
|
|
func (f fissionChop) TableName() string { return f.fissionChopDo.TableName() }
|
|
|
|
|
|
func (f fissionChop) Alias() string { return f.fissionChopDo.Alias() }
|
|
|
|
|
|
func (f *fissionChop) 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 *fissionChop) fillFieldMap() {
|
|
|
f.fieldMap = make(map[string]field.Expr, 6)
|
|
|
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["chop_reward_id"] = f.ChopRewardID
|
|
|
}
|
|
|
|
|
|
func (f fissionChop) clone(db *gorm.DB) fissionChop {
|
|
|
f.fissionChopDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f fissionChop) replaceDB(db *gorm.DB) fissionChop {
|
|
|
f.fissionChopDo.ReplaceDB(db)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
type fissionChopDo struct{ gen.DO }
|
|
|
|
|
|
func (f fissionChopDo) Debug() *fissionChopDo {
|
|
|
return f.withDO(f.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) WithContext(ctx context.Context) *fissionChopDo {
|
|
|
return f.withDO(f.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) ReadDB() *fissionChopDo {
|
|
|
return f.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) WriteDB() *fissionChopDo {
|
|
|
return f.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Session(config *gorm.Session) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Clauses(conds ...clause.Expression) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Returning(value interface{}, columns ...string) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Not(conds ...gen.Condition) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Or(conds ...gen.Condition) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Select(conds ...field.Expr) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Where(conds ...gen.Condition) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *fissionChopDo {
|
|
|
return f.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Order(conds ...field.Expr) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Distinct(cols ...field.Expr) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Omit(cols ...field.Expr) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Join(table schema.Tabler, on ...field.Expr) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) LeftJoin(table schema.Tabler, on ...field.Expr) *fissionChopDo {
|
|
|
return f.withDO(f.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) RightJoin(table schema.Tabler, on ...field.Expr) *fissionChopDo {
|
|
|
return f.withDO(f.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Group(cols ...field.Expr) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Having(conds ...gen.Condition) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Limit(limit int) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Offset(offset int) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Unscoped() *fissionChopDo {
|
|
|
return f.withDO(f.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Create(values ...*model.FissionChop) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) CreateInBatches(values []*model.FissionChop, 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 fissionChopDo) Save(values ...*model.FissionChop) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) First() (*model.FissionChop, error) {
|
|
|
if result, err := f.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionChop), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Take() (*model.FissionChop, error) {
|
|
|
if result, err := f.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionChop), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Last() (*model.FissionChop, error) {
|
|
|
if result, err := f.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionChop), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Find() ([]*model.FissionChop, error) {
|
|
|
result, err := f.DO.Find()
|
|
|
return result.([]*model.FissionChop), err
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.FissionChop, err error) {
|
|
|
buf := make([]*model.FissionChop, 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 fissionChopDo) FindInBatches(result *[]*model.FissionChop, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return f.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Attrs(attrs ...field.AssignExpr) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Assign(attrs ...field.AssignExpr) *fissionChopDo {
|
|
|
return f.withDO(f.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Joins(fields ...field.RelationField) *fissionChopDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Joins(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Preload(fields ...field.RelationField) *fissionChopDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Preload(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) FirstOrInit() (*model.FissionChop, error) {
|
|
|
if result, err := f.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionChop), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) FirstOrCreate() (*model.FissionChop, error) {
|
|
|
if result, err := f.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionChop), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) FindByPage(offset int, limit int) (result []*model.FissionChop, 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 fissionChopDo) 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 fissionChopDo) Scan(result interface{}) (err error) {
|
|
|
return f.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (f fissionChopDo) Delete(models ...*model.FissionChop) (result gen.ResultInfo, err error) {
|
|
|
return f.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (f *fissionChopDo) withDO(do gen.Dao) *fissionChopDo {
|
|
|
f.DO = *do.(*gen.DO)
|
|
|
return f
|
|
|
}
|