You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

408 lines
12 KiB
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// 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 newRedeemMallItem(db *gorm.DB, opts ...gen.DOOption) redeemMallItem {
_redeemMallItem := redeemMallItem{}
_redeemMallItem.redeemMallItemDo.UseDB(db, opts...)
_redeemMallItem.redeemMallItemDo.UseModel(&model.RedeemMallItem{})
tableName := _redeemMallItem.redeemMallItemDo.TableName()
_redeemMallItem.ALL = field.NewAsterisk(tableName)
_redeemMallItem.ID = field.NewInt64(tableName, "id")
_redeemMallItem.CreatedAt = field.NewInt64(tableName, "created_at")
_redeemMallItem.UpdatedAt = field.NewInt64(tableName, "updated_at")
_redeemMallItem.IsDel = field.NewInt8(tableName, "is_del")
_redeemMallItem.MallID = field.NewInt64(tableName, "mall_id")
_redeemMallItem.RewardID = field.NewInt64(tableName, "reward_id")
_redeemMallItem.CoinNum = field.NewInt32(tableName, "coin_num")
_redeemMallItem.Stock = field.NewInt64(tableName, "stock")
_redeemMallItem.UseStock = field.NewInt64(tableName, "use_stock")
_redeemMallItem.UpType = field.NewInt8(tableName, "up_type")
_redeemMallItem.UpCustom = field.NewInt64(tableName, "up_custom")
_redeemMallItem.UpAt = field.NewInt64(tableName, "up_at")
_redeemMallItem.UpFrom = field.NewString(tableName, "up_from")
_redeemMallItem.UpShow = field.NewString(tableName, "up_show")
_redeemMallItem.DownType = field.NewInt8(tableName, "down_type")
_redeemMallItem.DownCustom = field.NewInt64(tableName, "down_custom")
_redeemMallItem.DownAt = field.NewInt64(tableName, "down_at")
_redeemMallItem.DownFrom = field.NewString(tableName, "down_from")
_redeemMallItem.DownShow = field.NewString(tableName, "down_show")
_redeemMallItem.Sort = field.NewInt32(tableName, "sort")
_redeemMallItem.fillFieldMap()
return _redeemMallItem
}
type redeemMallItem struct {
redeemMallItemDo redeemMallItemDo
ALL field.Asterisk
ID field.Int64
CreatedAt field.Int64
UpdatedAt field.Int64
IsDel field.Int8 // 是否删除(0-否,1-是)
MallID field.Int64 // 商城id(redeem_mall表)
RewardID field.Int64 // 奖品id(reward表)
CoinNum field.Int32 // 所需积分数
Stock field.Int64 // 总库存
UseStock field.Int64 // 已使用库存(下架时候结算,-1未结算)
UpType field.Int8 // 上架类型(1-立即上架,2-指定时间)
UpCustom field.Int64 // 自定的上架时间
UpAt field.Int64 // 上架时间
UpFrom field.String // 上架来源
UpShow field.String // 指定上架展示配置
DownType field.Int8 // 下架类型(1-永久上架,2-指定时间下架)
DownCustom field.Int64 // 指定下架时间
DownAt field.Int64 // 下架时间
DownFrom field.String // 下架来源
DownShow field.String // 指定下架展示配置
Sort field.Int32 // 排序
fieldMap map[string]field.Expr
}
func (r redeemMallItem) Table(newTableName string) *redeemMallItem {
r.redeemMallItemDo.UseTable(newTableName)
return r.updateTableName(newTableName)
}
func (r redeemMallItem) As(alias string) *redeemMallItem {
r.redeemMallItemDo.DO = *(r.redeemMallItemDo.As(alias).(*gen.DO))
return r.updateTableName(alias)
}
func (r *redeemMallItem) updateTableName(table string) *redeemMallItem {
r.ALL = field.NewAsterisk(table)
r.ID = field.NewInt64(table, "id")
r.CreatedAt = field.NewInt64(table, "created_at")
r.UpdatedAt = field.NewInt64(table, "updated_at")
r.IsDel = field.NewInt8(table, "is_del")
r.MallID = field.NewInt64(table, "mall_id")
r.RewardID = field.NewInt64(table, "reward_id")
r.CoinNum = field.NewInt32(table, "coin_num")
r.Stock = field.NewInt64(table, "stock")
r.UseStock = field.NewInt64(table, "use_stock")
r.UpType = field.NewInt8(table, "up_type")
r.UpCustom = field.NewInt64(table, "up_custom")
r.UpAt = field.NewInt64(table, "up_at")
r.UpFrom = field.NewString(table, "up_from")
r.UpShow = field.NewString(table, "up_show")
r.DownType = field.NewInt8(table, "down_type")
r.DownCustom = field.NewInt64(table, "down_custom")
r.DownAt = field.NewInt64(table, "down_at")
r.DownFrom = field.NewString(table, "down_from")
r.DownShow = field.NewString(table, "down_show")
r.Sort = field.NewInt32(table, "sort")
r.fillFieldMap()
return r
}
func (r *redeemMallItem) WithContext(ctx context.Context) *redeemMallItemDo {
return r.redeemMallItemDo.WithContext(ctx)
}
func (r redeemMallItem) TableName() string { return r.redeemMallItemDo.TableName() }
func (r redeemMallItem) Alias() string { return r.redeemMallItemDo.Alias() }
func (r *redeemMallItem) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := r.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (r *redeemMallItem) fillFieldMap() {
r.fieldMap = make(map[string]field.Expr, 20)
r.fieldMap["id"] = r.ID
r.fieldMap["created_at"] = r.CreatedAt
r.fieldMap["updated_at"] = r.UpdatedAt
r.fieldMap["is_del"] = r.IsDel
r.fieldMap["mall_id"] = r.MallID
r.fieldMap["reward_id"] = r.RewardID
r.fieldMap["coin_num"] = r.CoinNum
r.fieldMap["stock"] = r.Stock
r.fieldMap["use_stock"] = r.UseStock
r.fieldMap["up_type"] = r.UpType
r.fieldMap["up_custom"] = r.UpCustom
r.fieldMap["up_at"] = r.UpAt
r.fieldMap["up_from"] = r.UpFrom
r.fieldMap["up_show"] = r.UpShow
r.fieldMap["down_type"] = r.DownType
r.fieldMap["down_custom"] = r.DownCustom
r.fieldMap["down_at"] = r.DownAt
r.fieldMap["down_from"] = r.DownFrom
r.fieldMap["down_show"] = r.DownShow
r.fieldMap["sort"] = r.Sort
}
func (r redeemMallItem) clone(db *gorm.DB) redeemMallItem {
r.redeemMallItemDo.ReplaceConnPool(db.Statement.ConnPool)
return r
}
func (r redeemMallItem) replaceDB(db *gorm.DB) redeemMallItem {
r.redeemMallItemDo.ReplaceDB(db)
return r
}
type redeemMallItemDo struct{ gen.DO }
func (r redeemMallItemDo) Debug() *redeemMallItemDo {
return r.withDO(r.DO.Debug())
}
func (r redeemMallItemDo) WithContext(ctx context.Context) *redeemMallItemDo {
return r.withDO(r.DO.WithContext(ctx))
}
func (r redeemMallItemDo) ReadDB() *redeemMallItemDo {
return r.Clauses(dbresolver.Read)
}
func (r redeemMallItemDo) WriteDB() *redeemMallItemDo {
return r.Clauses(dbresolver.Write)
}
func (r redeemMallItemDo) Session(config *gorm.Session) *redeemMallItemDo {
return r.withDO(r.DO.Session(config))
}
func (r redeemMallItemDo) Clauses(conds ...clause.Expression) *redeemMallItemDo {
return r.withDO(r.DO.Clauses(conds...))
}
func (r redeemMallItemDo) Returning(value interface{}, columns ...string) *redeemMallItemDo {
return r.withDO(r.DO.Returning(value, columns...))
}
func (r redeemMallItemDo) Not(conds ...gen.Condition) *redeemMallItemDo {
return r.withDO(r.DO.Not(conds...))
}
func (r redeemMallItemDo) Or(conds ...gen.Condition) *redeemMallItemDo {
return r.withDO(r.DO.Or(conds...))
}
func (r redeemMallItemDo) Select(conds ...field.Expr) *redeemMallItemDo {
return r.withDO(r.DO.Select(conds...))
}
func (r redeemMallItemDo) Where(conds ...gen.Condition) *redeemMallItemDo {
return r.withDO(r.DO.Where(conds...))
}
func (r redeemMallItemDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *redeemMallItemDo {
return r.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
}
func (r redeemMallItemDo) Order(conds ...field.Expr) *redeemMallItemDo {
return r.withDO(r.DO.Order(conds...))
}
func (r redeemMallItemDo) Distinct(cols ...field.Expr) *redeemMallItemDo {
return r.withDO(r.DO.Distinct(cols...))
}
func (r redeemMallItemDo) Omit(cols ...field.Expr) *redeemMallItemDo {
return r.withDO(r.DO.Omit(cols...))
}
func (r redeemMallItemDo) Join(table schema.Tabler, on ...field.Expr) *redeemMallItemDo {
return r.withDO(r.DO.Join(table, on...))
}
func (r redeemMallItemDo) LeftJoin(table schema.Tabler, on ...field.Expr) *redeemMallItemDo {
return r.withDO(r.DO.LeftJoin(table, on...))
}
func (r redeemMallItemDo) RightJoin(table schema.Tabler, on ...field.Expr) *redeemMallItemDo {
return r.withDO(r.DO.RightJoin(table, on...))
}
func (r redeemMallItemDo) Group(cols ...field.Expr) *redeemMallItemDo {
return r.withDO(r.DO.Group(cols...))
}
func (r redeemMallItemDo) Having(conds ...gen.Condition) *redeemMallItemDo {
return r.withDO(r.DO.Having(conds...))
}
func (r redeemMallItemDo) Limit(limit int) *redeemMallItemDo {
return r.withDO(r.DO.Limit(limit))
}
func (r redeemMallItemDo) Offset(offset int) *redeemMallItemDo {
return r.withDO(r.DO.Offset(offset))
}
func (r redeemMallItemDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *redeemMallItemDo {
return r.withDO(r.DO.Scopes(funcs...))
}
func (r redeemMallItemDo) Unscoped() *redeemMallItemDo {
return r.withDO(r.DO.Unscoped())
}
func (r redeemMallItemDo) Create(values ...*model.RedeemMallItem) error {
if len(values) == 0 {
return nil
}
return r.DO.Create(values)
}
func (r redeemMallItemDo) CreateInBatches(values []*model.RedeemMallItem, batchSize int) error {
return r.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 (r redeemMallItemDo) Save(values ...*model.RedeemMallItem) error {
if len(values) == 0 {
return nil
}
return r.DO.Save(values)
}
func (r redeemMallItemDo) First() (*model.RedeemMallItem, error) {
if result, err := r.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.RedeemMallItem), nil
}
}
func (r redeemMallItemDo) Take() (*model.RedeemMallItem, error) {
if result, err := r.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.RedeemMallItem), nil
}
}
func (r redeemMallItemDo) Last() (*model.RedeemMallItem, error) {
if result, err := r.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.RedeemMallItem), nil
}
}
func (r redeemMallItemDo) Find() ([]*model.RedeemMallItem, error) {
result, err := r.DO.Find()
return result.([]*model.RedeemMallItem), err
}
func (r redeemMallItemDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.RedeemMallItem, err error) {
buf := make([]*model.RedeemMallItem, 0, batchSize)
err = r.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 (r redeemMallItemDo) FindInBatches(result *[]*model.RedeemMallItem, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return r.DO.FindInBatches(result, batchSize, fc)
}
func (r redeemMallItemDo) Attrs(attrs ...field.AssignExpr) *redeemMallItemDo {
return r.withDO(r.DO.Attrs(attrs...))
}
func (r redeemMallItemDo) Assign(attrs ...field.AssignExpr) *redeemMallItemDo {
return r.withDO(r.DO.Assign(attrs...))
}
func (r redeemMallItemDo) Joins(fields ...field.RelationField) *redeemMallItemDo {
for _, _f := range fields {
r = *r.withDO(r.DO.Joins(_f))
}
return &r
}
func (r redeemMallItemDo) Preload(fields ...field.RelationField) *redeemMallItemDo {
for _, _f := range fields {
r = *r.withDO(r.DO.Preload(_f))
}
return &r
}
func (r redeemMallItemDo) FirstOrInit() (*model.RedeemMallItem, error) {
if result, err := r.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.RedeemMallItem), nil
}
}
func (r redeemMallItemDo) FirstOrCreate() (*model.RedeemMallItem, error) {
if result, err := r.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.RedeemMallItem), nil
}
}
func (r redeemMallItemDo) FindByPage(offset int, limit int) (result []*model.RedeemMallItem, count int64, err error) {
result, err = r.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 = r.Offset(-1).Limit(-1).Count()
return
}
func (r redeemMallItemDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = r.Count()
if err != nil {
return
}
err = r.Offset(offset).Limit(limit).Scan(result)
return
}
func (r redeemMallItemDo) Scan(result interface{}) (err error) {
return r.DO.Scan(result)
}
func (r redeemMallItemDo) Delete(models ...*model.RedeemMallItem) (result gen.ResultInfo, err error) {
return r.DO.Delete(models)
}
func (r *redeemMallItemDo) withDO(do gen.Dao) *redeemMallItemDo {
r.DO = *do.(*gen.DO)
return r
}