|
|
// 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 newProjectUserCoin(db *gorm.DB, opts ...gen.DOOption) projectUserCoin {
|
|
|
_projectUserCoin := projectUserCoin{}
|
|
|
|
|
|
_projectUserCoin.projectUserCoinDo.UseDB(db, opts...)
|
|
|
_projectUserCoin.projectUserCoinDo.UseModel(&model.ProjectUserCoin{})
|
|
|
|
|
|
tableName := _projectUserCoin.projectUserCoinDo.TableName()
|
|
|
_projectUserCoin.ALL = field.NewAsterisk(tableName)
|
|
|
_projectUserCoin.ID = field.NewInt64(tableName, "id")
|
|
|
_projectUserCoin.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_projectUserCoin.UpdatedAt = field.NewInt64(tableName, "updated_at")
|
|
|
_projectUserCoin.ProjectID = field.NewInt64(tableName, "project_id")
|
|
|
_projectUserCoin.UserID = field.NewInt64(tableName, "user_id")
|
|
|
_projectUserCoin.CoinNum = field.NewInt32(tableName, "coin_num")
|
|
|
_projectUserCoin.CoinUse = field.NewInt32(tableName, "coin_use")
|
|
|
_projectUserCoin.ExpiredAt = field.NewInt64(tableName, "expired_at")
|
|
|
_projectUserCoin.IsExpired = field.NewInt8(tableName, "is_expired")
|
|
|
_projectUserCoin.IsUsed = field.NewInt8(tableName, "is_used")
|
|
|
_projectUserCoin.Source = field.NewString(tableName, "source")
|
|
|
_projectUserCoin.SourceID = field.NewInt64(tableName, "source_id")
|
|
|
_projectUserCoin.SourceData = field.NewString(tableName, "source_data")
|
|
|
|
|
|
_projectUserCoin.fillFieldMap()
|
|
|
|
|
|
return _projectUserCoin
|
|
|
}
|
|
|
|
|
|
type projectUserCoin struct {
|
|
|
projectUserCoinDo projectUserCoinDo
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
ID field.Int64
|
|
|
CreatedAt field.Int64
|
|
|
UpdatedAt field.Int64
|
|
|
ProjectID field.Int64 // 项目id
|
|
|
UserID field.Int64 // 项目用户ID
|
|
|
CoinNum field.Int32 // 积分
|
|
|
CoinUse field.Int32 // 可用积分
|
|
|
ExpiredAt field.Int64 // 过期时间
|
|
|
IsExpired field.Int8 // 是否会过期(1-是,0-否)
|
|
|
IsUsed field.Int8 // 是否使用完毕(1-是,0-否)
|
|
|
Source field.String // 来源
|
|
|
SourceID field.Int64 // 来源唯一id
|
|
|
SourceData field.String // 来源数据
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoin) Table(newTableName string) *projectUserCoin {
|
|
|
p.projectUserCoinDo.UseTable(newTableName)
|
|
|
return p.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoin) As(alias string) *projectUserCoin {
|
|
|
p.projectUserCoinDo.DO = *(p.projectUserCoinDo.As(alias).(*gen.DO))
|
|
|
return p.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (p *projectUserCoin) updateTableName(table string) *projectUserCoin {
|
|
|
p.ALL = field.NewAsterisk(table)
|
|
|
p.ID = field.NewInt64(table, "id")
|
|
|
p.CreatedAt = field.NewInt64(table, "created_at")
|
|
|
p.UpdatedAt = field.NewInt64(table, "updated_at")
|
|
|
p.ProjectID = field.NewInt64(table, "project_id")
|
|
|
p.UserID = field.NewInt64(table, "user_id")
|
|
|
p.CoinNum = field.NewInt32(table, "coin_num")
|
|
|
p.CoinUse = field.NewInt32(table, "coin_use")
|
|
|
p.ExpiredAt = field.NewInt64(table, "expired_at")
|
|
|
p.IsExpired = field.NewInt8(table, "is_expired")
|
|
|
p.IsUsed = field.NewInt8(table, "is_used")
|
|
|
p.Source = field.NewString(table, "source")
|
|
|
p.SourceID = field.NewInt64(table, "source_id")
|
|
|
p.SourceData = field.NewString(table, "source_data")
|
|
|
|
|
|
p.fillFieldMap()
|
|
|
|
|
|
return p
|
|
|
}
|
|
|
|
|
|
func (p *projectUserCoin) WithContext(ctx context.Context) *projectUserCoinDo {
|
|
|
return p.projectUserCoinDo.WithContext(ctx)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoin) TableName() string { return p.projectUserCoinDo.TableName() }
|
|
|
|
|
|
func (p projectUserCoin) Alias() string { return p.projectUserCoinDo.Alias() }
|
|
|
|
|
|
func (p *projectUserCoin) 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 *projectUserCoin) fillFieldMap() {
|
|
|
p.fieldMap = make(map[string]field.Expr, 13)
|
|
|
p.fieldMap["id"] = p.ID
|
|
|
p.fieldMap["created_at"] = p.CreatedAt
|
|
|
p.fieldMap["updated_at"] = p.UpdatedAt
|
|
|
p.fieldMap["project_id"] = p.ProjectID
|
|
|
p.fieldMap["user_id"] = p.UserID
|
|
|
p.fieldMap["coin_num"] = p.CoinNum
|
|
|
p.fieldMap["coin_use"] = p.CoinUse
|
|
|
p.fieldMap["expired_at"] = p.ExpiredAt
|
|
|
p.fieldMap["is_expired"] = p.IsExpired
|
|
|
p.fieldMap["is_used"] = p.IsUsed
|
|
|
p.fieldMap["source"] = p.Source
|
|
|
p.fieldMap["source_id"] = p.SourceID
|
|
|
p.fieldMap["source_data"] = p.SourceData
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoin) clone(db *gorm.DB) projectUserCoin {
|
|
|
p.projectUserCoinDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return p
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoin) replaceDB(db *gorm.DB) projectUserCoin {
|
|
|
p.projectUserCoinDo.ReplaceDB(db)
|
|
|
return p
|
|
|
}
|
|
|
|
|
|
type projectUserCoinDo struct{ gen.DO }
|
|
|
|
|
|
func (p projectUserCoinDo) Debug() *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) WithContext(ctx context.Context) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) ReadDB() *projectUserCoinDo {
|
|
|
return p.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) WriteDB() *projectUserCoinDo {
|
|
|
return p.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Session(config *gorm.Session) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Clauses(conds ...clause.Expression) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Returning(value interface{}, columns ...string) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Not(conds ...gen.Condition) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Or(conds ...gen.Condition) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Select(conds ...field.Expr) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Where(conds ...gen.Condition) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *projectUserCoinDo {
|
|
|
return p.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Order(conds ...field.Expr) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Distinct(cols ...field.Expr) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Omit(cols ...field.Expr) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Join(table schema.Tabler, on ...field.Expr) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) LeftJoin(table schema.Tabler, on ...field.Expr) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) RightJoin(table schema.Tabler, on ...field.Expr) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Group(cols ...field.Expr) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Having(conds ...gen.Condition) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Limit(limit int) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Offset(offset int) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Unscoped() *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Create(values ...*model.ProjectUserCoin) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return p.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) CreateInBatches(values []*model.ProjectUserCoin, 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 projectUserCoinDo) Save(values ...*model.ProjectUserCoin) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return p.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) First() (*model.ProjectUserCoin, error) {
|
|
|
if result, err := p.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUserCoin), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Take() (*model.ProjectUserCoin, error) {
|
|
|
if result, err := p.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUserCoin), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Last() (*model.ProjectUserCoin, error) {
|
|
|
if result, err := p.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUserCoin), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Find() ([]*model.ProjectUserCoin, error) {
|
|
|
result, err := p.DO.Find()
|
|
|
return result.([]*model.ProjectUserCoin), err
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectUserCoin, err error) {
|
|
|
buf := make([]*model.ProjectUserCoin, 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 projectUserCoinDo) FindInBatches(result *[]*model.ProjectUserCoin, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return p.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Attrs(attrs ...field.AssignExpr) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Assign(attrs ...field.AssignExpr) *projectUserCoinDo {
|
|
|
return p.withDO(p.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Joins(fields ...field.RelationField) *projectUserCoinDo {
|
|
|
for _, _f := range fields {
|
|
|
p = *p.withDO(p.DO.Joins(_f))
|
|
|
}
|
|
|
return &p
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Preload(fields ...field.RelationField) *projectUserCoinDo {
|
|
|
for _, _f := range fields {
|
|
|
p = *p.withDO(p.DO.Preload(_f))
|
|
|
}
|
|
|
return &p
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) FirstOrInit() (*model.ProjectUserCoin, error) {
|
|
|
if result, err := p.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUserCoin), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) FirstOrCreate() (*model.ProjectUserCoin, error) {
|
|
|
if result, err := p.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUserCoin), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) FindByPage(offset int, limit int) (result []*model.ProjectUserCoin, 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 projectUserCoinDo) 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 projectUserCoinDo) Scan(result interface{}) (err error) {
|
|
|
return p.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (p projectUserCoinDo) Delete(models ...*model.ProjectUserCoin) (result gen.ResultInfo, err error) {
|
|
|
return p.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (p *projectUserCoinDo) withDO(do gen.Dao) *projectUserCoinDo {
|
|
|
p.DO = *do.(*gen.DO)
|
|
|
return p
|
|
|
}
|