|
|
// 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 newProjectUserCoinUse(db *gorm.DB, opts ...gen.DOOption) projectUserCoinUse {
|
|
|
_projectUserCoinUse := projectUserCoinUse{}
|
|
|
|
|
|
_projectUserCoinUse.projectUserCoinUseDo.UseDB(db, opts...)
|
|
|
_projectUserCoinUse.projectUserCoinUseDo.UseModel(&model.ProjectUserCoinUse{})
|
|
|
|
|
|
tableName := _projectUserCoinUse.projectUserCoinUseDo.TableName()
|
|
|
_projectUserCoinUse.ALL = field.NewAsterisk(tableName)
|
|
|
_projectUserCoinUse.ID = field.NewInt64(tableName, "id")
|
|
|
_projectUserCoinUse.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_projectUserCoinUse.UserID = field.NewInt64(tableName, "user_id")
|
|
|
_projectUserCoinUse.Num = field.NewInt32(tableName, "num")
|
|
|
_projectUserCoinUse.Source = field.NewString(tableName, "source")
|
|
|
_projectUserCoinUse.SourceID = field.NewInt64(tableName, "source_id")
|
|
|
_projectUserCoinUse.Operate = field.NewString(tableName, "operate")
|
|
|
_projectUserCoinUse.CoinIds = field.NewString(tableName, "coin_ids")
|
|
|
|
|
|
_projectUserCoinUse.fillFieldMap()
|
|
|
|
|
|
return _projectUserCoinUse
|
|
|
}
|
|
|
|
|
|
type projectUserCoinUse struct {
|
|
|
projectUserCoinUseDo projectUserCoinUseDo
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
ID field.Int64
|
|
|
CreatedAt field.Int64
|
|
|
UserID field.Int64
|
|
|
Num field.Int32
|
|
|
Source field.String // 使用来源(campaign-活动,center-任务中心)
|
|
|
SourceID field.Int64 // 使用来源id
|
|
|
Operate field.String // 操作标识
|
|
|
CoinIds field.String // 扣除关联的积分id
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUse) Table(newTableName string) *projectUserCoinUse {
|
|
|
p.projectUserCoinUseDo.UseTable(newTableName)
|
|
|
return p.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUse) As(alias string) *projectUserCoinUse {
|
|
|
p.projectUserCoinUseDo.DO = *(p.projectUserCoinUseDo.As(alias).(*gen.DO))
|
|
|
return p.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (p *projectUserCoinUse) updateTableName(table string) *projectUserCoinUse {
|
|
|
p.ALL = field.NewAsterisk(table)
|
|
|
p.ID = field.NewInt64(table, "id")
|
|
|
p.CreatedAt = field.NewInt64(table, "created_at")
|
|
|
p.UserID = field.NewInt64(table, "user_id")
|
|
|
p.Num = field.NewInt32(table, "num")
|
|
|
p.Source = field.NewString(table, "source")
|
|
|
p.SourceID = field.NewInt64(table, "source_id")
|
|
|
p.Operate = field.NewString(table, "operate")
|
|
|
p.CoinIds = field.NewString(table, "coin_ids")
|
|
|
|
|
|
p.fillFieldMap()
|
|
|
|
|
|
return p
|
|
|
}
|
|
|
|
|
|
func (p *projectUserCoinUse) WithContext(ctx context.Context) *projectUserCoinUseDo {
|
|
|
return p.projectUserCoinUseDo.WithContext(ctx)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUse) TableName() string { return p.projectUserCoinUseDo.TableName() }
|
|
|
|
|
|
func (p projectUserCoinUse) Alias() string { return p.projectUserCoinUseDo.Alias() }
|
|
|
|
|
|
func (p *projectUserCoinUse) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
|
_f, ok := p.fieldMap[fieldName]
|
|
|
if !ok || _f == nil {
|
|
|
return nil, false
|
|
|
}
|
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
|
return _oe, ok
|
|
|
}
|
|
|
|
|
|
func (p *projectUserCoinUse) fillFieldMap() {
|
|
|
p.fieldMap = make(map[string]field.Expr, 8)
|
|
|
p.fieldMap["id"] = p.ID
|
|
|
p.fieldMap["created_at"] = p.CreatedAt
|
|
|
p.fieldMap["user_id"] = p.UserID
|
|
|
p.fieldMap["num"] = p.Num
|
|
|
p.fieldMap["source"] = p.Source
|
|
|
p.fieldMap["source_id"] = p.SourceID
|
|
|
p.fieldMap["operate"] = p.Operate
|
|
|
p.fieldMap["coin_ids"] = p.CoinIds
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUse) clone(db *gorm.DB) projectUserCoinUse {
|
|
|
p.projectUserCoinUseDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return p
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUse) replaceDB(db *gorm.DB) projectUserCoinUse {
|
|
|
p.projectUserCoinUseDo.ReplaceDB(db)
|
|
|
return p
|
|
|
}
|
|
|
|
|
|
type projectUserCoinUseDo struct{ gen.DO }
|
|
|
|
|
|
func (p projectUserCoinUseDo) Debug() *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) WithContext(ctx context.Context) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) ReadDB() *projectUserCoinUseDo {
|
|
|
return p.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) WriteDB() *projectUserCoinUseDo {
|
|
|
return p.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Session(config *gorm.Session) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Clauses(conds ...clause.Expression) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Returning(value interface{}, columns ...string) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Not(conds ...gen.Condition) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Or(conds ...gen.Condition) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Select(conds ...field.Expr) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Where(conds ...gen.Condition) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *projectUserCoinUseDo {
|
|
|
return p.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Order(conds ...field.Expr) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Distinct(cols ...field.Expr) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Omit(cols ...field.Expr) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Join(table schema.Tabler, on ...field.Expr) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) LeftJoin(table schema.Tabler, on ...field.Expr) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) RightJoin(table schema.Tabler, on ...field.Expr) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Group(cols ...field.Expr) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Having(conds ...gen.Condition) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Limit(limit int) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Offset(offset int) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Unscoped() *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Create(values ...*model.ProjectUserCoinUse) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return p.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) CreateInBatches(values []*model.ProjectUserCoinUse, batchSize int) error {
|
|
|
return p.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 (p projectUserCoinUseDo) Save(values ...*model.ProjectUserCoinUse) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return p.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) First() (*model.ProjectUserCoinUse, error) {
|
|
|
if result, err := p.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUserCoinUse), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Take() (*model.ProjectUserCoinUse, error) {
|
|
|
if result, err := p.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUserCoinUse), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Last() (*model.ProjectUserCoinUse, error) {
|
|
|
if result, err := p.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUserCoinUse), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Find() ([]*model.ProjectUserCoinUse, error) {
|
|
|
result, err := p.DO.Find()
|
|
|
return result.([]*model.ProjectUserCoinUse), err
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectUserCoinUse, err error) {
|
|
|
buf := make([]*model.ProjectUserCoinUse, 0, batchSize)
|
|
|
err = p.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 (p projectUserCoinUseDo) FindInBatches(result *[]*model.ProjectUserCoinUse, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return p.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Attrs(attrs ...field.AssignExpr) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Assign(attrs ...field.AssignExpr) *projectUserCoinUseDo {
|
|
|
return p.withDO(p.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Joins(fields ...field.RelationField) *projectUserCoinUseDo {
|
|
|
for _, _f := range fields {
|
|
|
p = *p.withDO(p.DO.Joins(_f))
|
|
|
}
|
|
|
return &p
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Preload(fields ...field.RelationField) *projectUserCoinUseDo {
|
|
|
for _, _f := range fields {
|
|
|
p = *p.withDO(p.DO.Preload(_f))
|
|
|
}
|
|
|
return &p
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) FirstOrInit() (*model.ProjectUserCoinUse, error) {
|
|
|
if result, err := p.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUserCoinUse), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) FirstOrCreate() (*model.ProjectUserCoinUse, error) {
|
|
|
if result, err := p.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUserCoinUse), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) FindByPage(offset int, limit int) (result []*model.ProjectUserCoinUse, count int64, err error) {
|
|
|
result, err = p.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 = p.Offset(-1).Limit(-1).Count()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
|
count, err = p.Count()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
err = p.Offset(offset).Limit(limit).Scan(result)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Scan(result interface{}) (err error) {
|
|
|
return p.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinUseDo) Delete(models ...*model.ProjectUserCoinUse) (result gen.ResultInfo, err error) {
|
|
|
return p.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (p *projectUserCoinUseDo) withDO(do gen.Dao) *projectUserCoinUseDo {
|
|
|
p.DO = *do.(*gen.DO)
|
|
|
return p
|
|
|
}
|