|
|
// 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 newProjectUserCoinDeduct(db *gorm.DB, opts ...gen.DOOption) projectUserCoinDeduct {
|
|
|
_projectUserCoinDeduct := projectUserCoinDeduct{}
|
|
|
|
|
|
_projectUserCoinDeduct.projectUserCoinDeductDo.UseDB(db, opts...)
|
|
|
_projectUserCoinDeduct.projectUserCoinDeductDo.UseModel(&model.ProjectUserCoinDeduct{})
|
|
|
|
|
|
tableName := _projectUserCoinDeduct.projectUserCoinDeductDo.TableName()
|
|
|
_projectUserCoinDeduct.ALL = field.NewAsterisk(tableName)
|
|
|
_projectUserCoinDeduct.ID = field.NewInt64(tableName, "id")
|
|
|
_projectUserCoinDeduct.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_projectUserCoinDeduct.UserID = field.NewInt64(tableName, "user_id")
|
|
|
_projectUserCoinDeduct.Source = field.NewString(tableName, "source")
|
|
|
_projectUserCoinDeduct.RelateMark = field.NewString(tableName, "relate_mark")
|
|
|
_projectUserCoinDeduct.RelateID = field.NewInt64(tableName, "relate_id")
|
|
|
_projectUserCoinDeduct.Operate = field.NewString(tableName, "operate")
|
|
|
_projectUserCoinDeduct.Num = field.NewInt32(tableName, "num")
|
|
|
|
|
|
_projectUserCoinDeduct.fillFieldMap()
|
|
|
|
|
|
return _projectUserCoinDeduct
|
|
|
}
|
|
|
|
|
|
type projectUserCoinDeduct struct {
|
|
|
projectUserCoinDeductDo projectUserCoinDeductDo
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
ID field.Int64
|
|
|
CreatedAt field.Int64
|
|
|
UserID field.Int64
|
|
|
Source field.String // 扣除方式(sytem-系统,app-第三方应用)
|
|
|
RelateMark field.String // 关联标识
|
|
|
RelateID field.Int64 // 关联id
|
|
|
Operate field.String // 操作标识
|
|
|
Num field.Int32 // 扣除数量
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeduct) Table(newTableName string) *projectUserCoinDeduct {
|
|
|
p.projectUserCoinDeductDo.UseTable(newTableName)
|
|
|
return p.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeduct) As(alias string) *projectUserCoinDeduct {
|
|
|
p.projectUserCoinDeductDo.DO = *(p.projectUserCoinDeductDo.As(alias).(*gen.DO))
|
|
|
return p.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (p *projectUserCoinDeduct) updateTableName(table string) *projectUserCoinDeduct {
|
|
|
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.Source = field.NewString(table, "source")
|
|
|
p.RelateMark = field.NewString(table, "relate_mark")
|
|
|
p.RelateID = field.NewInt64(table, "relate_id")
|
|
|
p.Operate = field.NewString(table, "operate")
|
|
|
p.Num = field.NewInt32(table, "num")
|
|
|
|
|
|
p.fillFieldMap()
|
|
|
|
|
|
return p
|
|
|
}
|
|
|
|
|
|
func (p *projectUserCoinDeduct) WithContext(ctx context.Context) *projectUserCoinDeductDo {
|
|
|
return p.projectUserCoinDeductDo.WithContext(ctx)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeduct) TableName() string { return p.projectUserCoinDeductDo.TableName() }
|
|
|
|
|
|
func (p projectUserCoinDeduct) Alias() string { return p.projectUserCoinDeductDo.Alias() }
|
|
|
|
|
|
func (p *projectUserCoinDeduct) 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 *projectUserCoinDeduct) 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["source"] = p.Source
|
|
|
p.fieldMap["relate_mark"] = p.RelateMark
|
|
|
p.fieldMap["relate_id"] = p.RelateID
|
|
|
p.fieldMap["operate"] = p.Operate
|
|
|
p.fieldMap["num"] = p.Num
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeduct) clone(db *gorm.DB) projectUserCoinDeduct {
|
|
|
p.projectUserCoinDeductDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return p
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeduct) replaceDB(db *gorm.DB) projectUserCoinDeduct {
|
|
|
p.projectUserCoinDeductDo.ReplaceDB(db)
|
|
|
return p
|
|
|
}
|
|
|
|
|
|
type projectUserCoinDeductDo struct{ gen.DO }
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Debug() *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) WithContext(ctx context.Context) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) ReadDB() *projectUserCoinDeductDo {
|
|
|
return p.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) WriteDB() *projectUserCoinDeductDo {
|
|
|
return p.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Session(config *gorm.Session) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Clauses(conds ...clause.Expression) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Returning(value interface{}, columns ...string) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Not(conds ...gen.Condition) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Or(conds ...gen.Condition) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Select(conds ...field.Expr) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Where(conds ...gen.Condition) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *projectUserCoinDeductDo {
|
|
|
return p.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Order(conds ...field.Expr) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Distinct(cols ...field.Expr) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Omit(cols ...field.Expr) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Join(table schema.Tabler, on ...field.Expr) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) LeftJoin(table schema.Tabler, on ...field.Expr) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) RightJoin(table schema.Tabler, on ...field.Expr) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Group(cols ...field.Expr) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Having(conds ...gen.Condition) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Limit(limit int) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Offset(offset int) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Unscoped() *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Create(values ...*model.ProjectUserCoinDeduct) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return p.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) CreateInBatches(values []*model.ProjectUserCoinDeduct, 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 projectUserCoinDeductDo) Save(values ...*model.ProjectUserCoinDeduct) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return p.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) First() (*model.ProjectUserCoinDeduct, error) {
|
|
|
if result, err := p.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUserCoinDeduct), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Take() (*model.ProjectUserCoinDeduct, error) {
|
|
|
if result, err := p.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUserCoinDeduct), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Last() (*model.ProjectUserCoinDeduct, error) {
|
|
|
if result, err := p.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUserCoinDeduct), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Find() ([]*model.ProjectUserCoinDeduct, error) {
|
|
|
result, err := p.DO.Find()
|
|
|
return result.([]*model.ProjectUserCoinDeduct), err
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectUserCoinDeduct, err error) {
|
|
|
buf := make([]*model.ProjectUserCoinDeduct, 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 projectUserCoinDeductDo) FindInBatches(result *[]*model.ProjectUserCoinDeduct, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return p.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Attrs(attrs ...field.AssignExpr) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Assign(attrs ...field.AssignExpr) *projectUserCoinDeductDo {
|
|
|
return p.withDO(p.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Joins(fields ...field.RelationField) *projectUserCoinDeductDo {
|
|
|
for _, _f := range fields {
|
|
|
p = *p.withDO(p.DO.Joins(_f))
|
|
|
}
|
|
|
return &p
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Preload(fields ...field.RelationField) *projectUserCoinDeductDo {
|
|
|
for _, _f := range fields {
|
|
|
p = *p.withDO(p.DO.Preload(_f))
|
|
|
}
|
|
|
return &p
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) FirstOrInit() (*model.ProjectUserCoinDeduct, error) {
|
|
|
if result, err := p.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUserCoinDeduct), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) FirstOrCreate() (*model.ProjectUserCoinDeduct, error) {
|
|
|
if result, err := p.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUserCoinDeduct), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) FindByPage(offset int, limit int) (result []*model.ProjectUserCoinDeduct, 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 projectUserCoinDeductDo) 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 projectUserCoinDeductDo) Scan(result interface{}) (err error) {
|
|
|
return p.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDeductDo) Delete(models ...*model.ProjectUserCoinDeduct) (result gen.ResultInfo, err error) {
|
|
|
return p.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (p *projectUserCoinDeductDo) withDO(do gen.Dao) *projectUserCoinDeductDo {
|
|
|
p.DO = *do.(*gen.DO)
|
|
|
return p
|
|
|
}
|