2026-03-18 13:07:06 +08:00
|
|
|
// 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 queries
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"gorm.io/gorm"
|
|
|
|
|
"gorm.io/gorm/clause"
|
|
|
|
|
"gorm.io/gorm/schema"
|
|
|
|
|
|
|
|
|
|
"gorm.io/gen"
|
|
|
|
|
"gorm.io/gen/field"
|
|
|
|
|
|
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
|
|
|
|
|
|
"platform/web/models"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func newProductSku(db *gorm.DB, opts ...gen.DOOption) productSku {
|
|
|
|
|
_productSku := productSku{}
|
|
|
|
|
|
|
|
|
|
_productSku.productSkuDo.UseDB(db, opts...)
|
|
|
|
|
_productSku.productSkuDo.UseModel(&models.ProductSku{})
|
|
|
|
|
|
|
|
|
|
tableName := _productSku.productSkuDo.TableName()
|
|
|
|
|
_productSku.ALL = field.NewAsterisk(tableName)
|
|
|
|
|
_productSku.ID = field.NewInt32(tableName, "id")
|
|
|
|
|
_productSku.CreatedAt = field.NewTime(tableName, "created_at")
|
|
|
|
|
_productSku.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
|
|
|
_productSku.DeletedAt = field.NewField(tableName, "deleted_at")
|
|
|
|
|
_productSku.ProductID = field.NewInt32(tableName, "product_id")
|
2026-03-24 16:25:21 +08:00
|
|
|
_productSku.DiscountId = field.NewInt32(tableName, "discount_id")
|
2026-03-18 13:07:06 +08:00
|
|
|
_productSku.Code = field.NewString(tableName, "code")
|
|
|
|
|
_productSku.Name = field.NewString(tableName, "name")
|
|
|
|
|
_productSku.Price = field.NewField(tableName, "price")
|
2026-04-07 13:51:19 +08:00
|
|
|
_productSku.PriceMin = field.NewField(tableName, "price_min")
|
2026-04-07 13:22:37 +08:00
|
|
|
_productSku.Status = field.NewInt32(tableName, "status")
|
2026-04-15 16:56:24 +08:00
|
|
|
_productSku.Sort = field.NewInt32(tableName, "sort")
|
2026-04-20 11:20:44 +08:00
|
|
|
_productSku.CountMin = field.NewInt32(tableName, "count_min")
|
2026-03-18 13:07:06 +08:00
|
|
|
_productSku.Product = productSkuBelongsToProduct{
|
|
|
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
|
|
|
|
|
|
RelationField: field.NewRelation("Product", "models.Product"),
|
2026-04-14 15:06:08 +08:00
|
|
|
Skus: struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
Product struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
}
|
|
|
|
|
Discount struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
}
|
|
|
|
|
}{
|
|
|
|
|
RelationField: field.NewRelation("Product.Skus", "models.ProductSku"),
|
|
|
|
|
Product: struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
}{
|
|
|
|
|
RelationField: field.NewRelation("Product.Skus.Product", "models.Product"),
|
|
|
|
|
},
|
|
|
|
|
Discount: struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
}{
|
|
|
|
|
RelationField: field.NewRelation("Product.Skus.Discount", "models.ProductDiscount"),
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-03-18 13:07:06 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-24 16:25:21 +08:00
|
|
|
_productSku.Discount = productSkuBelongsToDiscount{
|
|
|
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
|
|
|
|
|
|
RelationField: field.NewRelation("Discount", "models.ProductDiscount"),
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-18 13:07:06 +08:00
|
|
|
_productSku.fillFieldMap()
|
|
|
|
|
|
|
|
|
|
return _productSku
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type productSku struct {
|
|
|
|
|
productSkuDo
|
|
|
|
|
|
2026-03-24 16:25:21 +08:00
|
|
|
ALL field.Asterisk
|
|
|
|
|
ID field.Int32
|
|
|
|
|
CreatedAt field.Time
|
|
|
|
|
UpdatedAt field.Time
|
|
|
|
|
DeletedAt field.Field
|
|
|
|
|
ProductID field.Int32
|
|
|
|
|
DiscountId field.Int32
|
|
|
|
|
Code field.String
|
|
|
|
|
Name field.String
|
|
|
|
|
Price field.Field
|
2026-04-07 13:51:19 +08:00
|
|
|
PriceMin field.Field
|
2026-04-07 13:22:37 +08:00
|
|
|
Status field.Int32
|
2026-04-15 16:56:24 +08:00
|
|
|
Sort field.Int32
|
2026-04-20 11:20:44 +08:00
|
|
|
CountMin field.Int32
|
2026-03-24 16:25:21 +08:00
|
|
|
Product productSkuBelongsToProduct
|
|
|
|
|
|
|
|
|
|
Discount productSkuBelongsToDiscount
|
2026-03-18 13:07:06 +08:00
|
|
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSku) Table(newTableName string) *productSku {
|
|
|
|
|
p.productSkuDo.UseTable(newTableName)
|
|
|
|
|
return p.updateTableName(newTableName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSku) As(alias string) *productSku {
|
|
|
|
|
p.productSkuDo.DO = *(p.productSkuDo.As(alias).(*gen.DO))
|
|
|
|
|
return p.updateTableName(alias)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *productSku) updateTableName(table string) *productSku {
|
|
|
|
|
p.ALL = field.NewAsterisk(table)
|
|
|
|
|
p.ID = field.NewInt32(table, "id")
|
|
|
|
|
p.CreatedAt = field.NewTime(table, "created_at")
|
|
|
|
|
p.UpdatedAt = field.NewTime(table, "updated_at")
|
|
|
|
|
p.DeletedAt = field.NewField(table, "deleted_at")
|
|
|
|
|
p.ProductID = field.NewInt32(table, "product_id")
|
2026-03-24 16:25:21 +08:00
|
|
|
p.DiscountId = field.NewInt32(table, "discount_id")
|
2026-03-18 13:07:06 +08:00
|
|
|
p.Code = field.NewString(table, "code")
|
|
|
|
|
p.Name = field.NewString(table, "name")
|
|
|
|
|
p.Price = field.NewField(table, "price")
|
2026-04-07 13:51:19 +08:00
|
|
|
p.PriceMin = field.NewField(table, "price_min")
|
2026-04-07 13:22:37 +08:00
|
|
|
p.Status = field.NewInt32(table, "status")
|
2026-04-15 16:56:24 +08:00
|
|
|
p.Sort = field.NewInt32(table, "sort")
|
2026-04-20 11:20:44 +08:00
|
|
|
p.CountMin = field.NewInt32(table, "count_min")
|
2026-03-18 13:07:06 +08:00
|
|
|
|
|
|
|
|
p.fillFieldMap()
|
|
|
|
|
|
|
|
|
|
return p
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *productSku) 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 *productSku) fillFieldMap() {
|
2026-04-20 11:20:44 +08:00
|
|
|
p.fieldMap = make(map[string]field.Expr, 15)
|
2026-03-18 13:07:06 +08:00
|
|
|
p.fieldMap["id"] = p.ID
|
|
|
|
|
p.fieldMap["created_at"] = p.CreatedAt
|
|
|
|
|
p.fieldMap["updated_at"] = p.UpdatedAt
|
|
|
|
|
p.fieldMap["deleted_at"] = p.DeletedAt
|
|
|
|
|
p.fieldMap["product_id"] = p.ProductID
|
2026-03-24 16:25:21 +08:00
|
|
|
p.fieldMap["discount_id"] = p.DiscountId
|
2026-03-18 13:07:06 +08:00
|
|
|
p.fieldMap["code"] = p.Code
|
|
|
|
|
p.fieldMap["name"] = p.Name
|
|
|
|
|
p.fieldMap["price"] = p.Price
|
2026-04-07 13:51:19 +08:00
|
|
|
p.fieldMap["price_min"] = p.PriceMin
|
2026-04-07 13:22:37 +08:00
|
|
|
p.fieldMap["status"] = p.Status
|
2026-04-15 16:56:24 +08:00
|
|
|
p.fieldMap["sort"] = p.Sort
|
2026-04-20 11:20:44 +08:00
|
|
|
p.fieldMap["count_min"] = p.CountMin
|
2026-03-18 13:07:06 +08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSku) clone(db *gorm.DB) productSku {
|
|
|
|
|
p.productSkuDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
|
|
p.Product.db = db.Session(&gorm.Session{Initialized: true})
|
|
|
|
|
p.Product.db.Statement.ConnPool = db.Statement.ConnPool
|
2026-03-24 16:25:21 +08:00
|
|
|
p.Discount.db = db.Session(&gorm.Session{Initialized: true})
|
|
|
|
|
p.Discount.db.Statement.ConnPool = db.Statement.ConnPool
|
2026-03-18 13:07:06 +08:00
|
|
|
return p
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSku) replaceDB(db *gorm.DB) productSku {
|
|
|
|
|
p.productSkuDo.ReplaceDB(db)
|
|
|
|
|
p.Product.db = db.Session(&gorm.Session{})
|
2026-03-24 16:25:21 +08:00
|
|
|
p.Discount.db = db.Session(&gorm.Session{})
|
2026-03-18 13:07:06 +08:00
|
|
|
return p
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type productSkuBelongsToProduct struct {
|
|
|
|
|
db *gorm.DB
|
|
|
|
|
|
|
|
|
|
field.RelationField
|
2026-04-14 15:06:08 +08:00
|
|
|
|
|
|
|
|
Skus struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
Product struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
}
|
|
|
|
|
Discount struct {
|
|
|
|
|
field.RelationField
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-18 13:07:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToProduct) Where(conds ...field.Expr) *productSkuBelongsToProduct {
|
|
|
|
|
if len(conds) == 0 {
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exprs := make([]clause.Expression, 0, len(conds))
|
|
|
|
|
for _, cond := range conds {
|
|
|
|
|
exprs = append(exprs, cond.BeCond().(clause.Expression))
|
|
|
|
|
}
|
|
|
|
|
a.db = a.db.Clauses(clause.Where{Exprs: exprs})
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToProduct) WithContext(ctx context.Context) *productSkuBelongsToProduct {
|
|
|
|
|
a.db = a.db.WithContext(ctx)
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToProduct) Session(session *gorm.Session) *productSkuBelongsToProduct {
|
|
|
|
|
a.db = a.db.Session(session)
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToProduct) Model(m *models.ProductSku) *productSkuBelongsToProductTx {
|
|
|
|
|
return &productSkuBelongsToProductTx{a.db.Model(m).Association(a.Name())}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToProduct) Unscoped() *productSkuBelongsToProduct {
|
|
|
|
|
a.db = a.db.Unscoped()
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type productSkuBelongsToProductTx struct{ tx *gorm.Association }
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToProductTx) Find() (result *models.Product, err error) {
|
|
|
|
|
return result, a.tx.Find(&result)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToProductTx) Append(values ...*models.Product) (err error) {
|
|
|
|
|
targetValues := make([]interface{}, len(values))
|
|
|
|
|
for i, v := range values {
|
|
|
|
|
targetValues[i] = v
|
|
|
|
|
}
|
|
|
|
|
return a.tx.Append(targetValues...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToProductTx) Replace(values ...*models.Product) (err error) {
|
|
|
|
|
targetValues := make([]interface{}, len(values))
|
|
|
|
|
for i, v := range values {
|
|
|
|
|
targetValues[i] = v
|
|
|
|
|
}
|
|
|
|
|
return a.tx.Replace(targetValues...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToProductTx) Delete(values ...*models.Product) (err error) {
|
|
|
|
|
targetValues := make([]interface{}, len(values))
|
|
|
|
|
for i, v := range values {
|
|
|
|
|
targetValues[i] = v
|
|
|
|
|
}
|
|
|
|
|
return a.tx.Delete(targetValues...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToProductTx) Clear() error {
|
|
|
|
|
return a.tx.Clear()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToProductTx) Count() int64 {
|
|
|
|
|
return a.tx.Count()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToProductTx) Unscoped() *productSkuBelongsToProductTx {
|
|
|
|
|
a.tx = a.tx.Unscoped()
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-24 16:25:21 +08:00
|
|
|
type productSkuBelongsToDiscount struct {
|
|
|
|
|
db *gorm.DB
|
|
|
|
|
|
|
|
|
|
field.RelationField
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToDiscount) Where(conds ...field.Expr) *productSkuBelongsToDiscount {
|
|
|
|
|
if len(conds) == 0 {
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exprs := make([]clause.Expression, 0, len(conds))
|
|
|
|
|
for _, cond := range conds {
|
|
|
|
|
exprs = append(exprs, cond.BeCond().(clause.Expression))
|
|
|
|
|
}
|
|
|
|
|
a.db = a.db.Clauses(clause.Where{Exprs: exprs})
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToDiscount) WithContext(ctx context.Context) *productSkuBelongsToDiscount {
|
|
|
|
|
a.db = a.db.WithContext(ctx)
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToDiscount) Session(session *gorm.Session) *productSkuBelongsToDiscount {
|
|
|
|
|
a.db = a.db.Session(session)
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToDiscount) Model(m *models.ProductSku) *productSkuBelongsToDiscountTx {
|
|
|
|
|
return &productSkuBelongsToDiscountTx{a.db.Model(m).Association(a.Name())}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToDiscount) Unscoped() *productSkuBelongsToDiscount {
|
|
|
|
|
a.db = a.db.Unscoped()
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type productSkuBelongsToDiscountTx struct{ tx *gorm.Association }
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToDiscountTx) Find() (result *models.ProductDiscount, err error) {
|
|
|
|
|
return result, a.tx.Find(&result)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToDiscountTx) Append(values ...*models.ProductDiscount) (err error) {
|
|
|
|
|
targetValues := make([]interface{}, len(values))
|
|
|
|
|
for i, v := range values {
|
|
|
|
|
targetValues[i] = v
|
|
|
|
|
}
|
|
|
|
|
return a.tx.Append(targetValues...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToDiscountTx) Replace(values ...*models.ProductDiscount) (err error) {
|
|
|
|
|
targetValues := make([]interface{}, len(values))
|
|
|
|
|
for i, v := range values {
|
|
|
|
|
targetValues[i] = v
|
|
|
|
|
}
|
|
|
|
|
return a.tx.Replace(targetValues...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToDiscountTx) Delete(values ...*models.ProductDiscount) (err error) {
|
|
|
|
|
targetValues := make([]interface{}, len(values))
|
|
|
|
|
for i, v := range values {
|
|
|
|
|
targetValues[i] = v
|
|
|
|
|
}
|
|
|
|
|
return a.tx.Delete(targetValues...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToDiscountTx) Clear() error {
|
|
|
|
|
return a.tx.Clear()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToDiscountTx) Count() int64 {
|
|
|
|
|
return a.tx.Count()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a productSkuBelongsToDiscountTx) Unscoped() *productSkuBelongsToDiscountTx {
|
|
|
|
|
a.tx = a.tx.Unscoped()
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-18 13:07:06 +08:00
|
|
|
type productSkuDo struct{ gen.DO }
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Debug() *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Debug())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) WithContext(ctx context.Context) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.WithContext(ctx))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) ReadDB() *productSkuDo {
|
|
|
|
|
return p.Clauses(dbresolver.Read)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) WriteDB() *productSkuDo {
|
|
|
|
|
return p.Clauses(dbresolver.Write)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Session(config *gorm.Session) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Session(config))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Clauses(conds ...clause.Expression) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Clauses(conds...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Returning(value interface{}, columns ...string) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Returning(value, columns...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Not(conds ...gen.Condition) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Not(conds...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Or(conds ...gen.Condition) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Or(conds...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Select(conds ...field.Expr) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Select(conds...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Where(conds ...gen.Condition) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Where(conds...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Order(conds ...field.Expr) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Order(conds...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Distinct(cols ...field.Expr) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Distinct(cols...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Omit(cols ...field.Expr) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Omit(cols...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Join(table schema.Tabler, on ...field.Expr) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Join(table, on...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) LeftJoin(table schema.Tabler, on ...field.Expr) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.LeftJoin(table, on...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) RightJoin(table schema.Tabler, on ...field.Expr) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.RightJoin(table, on...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Group(cols ...field.Expr) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Group(cols...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Having(conds ...gen.Condition) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Having(conds...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Limit(limit int) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Limit(limit))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Offset(offset int) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Offset(offset))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Scopes(funcs...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Unscoped() *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Unscoped())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Create(values ...*models.ProductSku) error {
|
|
|
|
|
if len(values) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return p.DO.Create(values)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) CreateInBatches(values []*models.ProductSku, 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 productSkuDo) Save(values ...*models.ProductSku) error {
|
|
|
|
|
if len(values) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return p.DO.Save(values)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) First() (*models.ProductSku, error) {
|
|
|
|
|
if result, err := p.DO.First(); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
} else {
|
|
|
|
|
return result.(*models.ProductSku), nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Take() (*models.ProductSku, error) {
|
|
|
|
|
if result, err := p.DO.Take(); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
} else {
|
|
|
|
|
return result.(*models.ProductSku), nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Last() (*models.ProductSku, error) {
|
|
|
|
|
if result, err := p.DO.Last(); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
} else {
|
|
|
|
|
return result.(*models.ProductSku), nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Find() ([]*models.ProductSku, error) {
|
|
|
|
|
result, err := p.DO.Find()
|
|
|
|
|
return result.([]*models.ProductSku), err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.ProductSku, err error) {
|
|
|
|
|
buf := make([]*models.ProductSku, 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 productSkuDo) FindInBatches(result *[]*models.ProductSku, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
|
|
return p.DO.FindInBatches(result, batchSize, fc)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Attrs(attrs ...field.AssignExpr) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Attrs(attrs...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Assign(attrs ...field.AssignExpr) *productSkuDo {
|
|
|
|
|
return p.withDO(p.DO.Assign(attrs...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Joins(fields ...field.RelationField) *productSkuDo {
|
|
|
|
|
for _, _f := range fields {
|
|
|
|
|
p = *p.withDO(p.DO.Joins(_f))
|
|
|
|
|
}
|
|
|
|
|
return &p
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Preload(fields ...field.RelationField) *productSkuDo {
|
|
|
|
|
for _, _f := range fields {
|
|
|
|
|
p = *p.withDO(p.DO.Preload(_f))
|
|
|
|
|
}
|
|
|
|
|
return &p
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) FirstOrInit() (*models.ProductSku, error) {
|
|
|
|
|
if result, err := p.DO.FirstOrInit(); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
} else {
|
|
|
|
|
return result.(*models.ProductSku), nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) FirstOrCreate() (*models.ProductSku, error) {
|
|
|
|
|
if result, err := p.DO.FirstOrCreate(); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
} else {
|
|
|
|
|
return result.(*models.ProductSku), nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) FindByPage(offset int, limit int) (result []*models.ProductSku, 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 productSkuDo) 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 productSkuDo) Scan(result interface{}) (err error) {
|
|
|
|
|
return p.DO.Scan(result)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p productSkuDo) Delete(models ...*models.ProductSku) (result gen.ResultInfo, err error) {
|
|
|
|
|
return p.DO.Delete(models)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *productSkuDo) withDO(do gen.Dao) *productSkuDo {
|
|
|
|
|
p.DO = *do.(*gen.DO)
|
|
|
|
|
return p
|
|
|
|
|
}
|