新增产品信息用户查询接口
This commit is contained in:
@@ -145,6 +145,9 @@ func newBalanceActivity(db *gorm.DB, opts ...gen.DOOption) balanceActivity {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
@@ -173,6 +176,9 @@ func newBalanceActivity(db *gorm.DB, opts ...gen.DOOption) balanceActivity {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
@@ -184,6 +190,9 @@ func newBalanceActivity(db *gorm.DB, opts ...gen.DOOption) balanceActivity {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
@@ -192,8 +201,16 @@ func newBalanceActivity(db *gorm.DB, opts ...gen.DOOption) balanceActivity {
|
||||
RelationField: field.NewRelation("Bill.Resource.Short.Sku", "models.ProductSku"),
|
||||
Product: struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Bill.Resource.Short.Sku.Product", "models.Product"),
|
||||
Skus: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Bill.Resource.Short.Sku.Product.Skus", "models.ProductSku"),
|
||||
},
|
||||
},
|
||||
Discount: struct {
|
||||
field.RelationField
|
||||
@@ -482,6 +499,9 @@ type balanceActivityBelongsToBill struct {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
|
||||
@@ -143,6 +143,9 @@ func newBill(db *gorm.DB, opts ...gen.DOOption) bill {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
@@ -154,6 +157,9 @@ func newBill(db *gorm.DB, opts ...gen.DOOption) bill {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
@@ -162,8 +168,16 @@ func newBill(db *gorm.DB, opts ...gen.DOOption) bill {
|
||||
RelationField: field.NewRelation("Resource.Short.Sku", "models.ProductSku"),
|
||||
Product: struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Resource.Short.Sku.Product", "models.Product"),
|
||||
Skus: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Resource.Short.Sku.Product.Skus", "models.ProductSku"),
|
||||
},
|
||||
},
|
||||
Discount: struct {
|
||||
field.RelationField
|
||||
@@ -540,6 +554,9 @@ type billBelongsToResource struct {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
|
||||
@@ -138,6 +138,9 @@ func newChannel(db *gorm.DB, opts ...gen.DOOption) channel {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
@@ -149,6 +152,9 @@ func newChannel(db *gorm.DB, opts ...gen.DOOption) channel {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
@@ -157,8 +163,16 @@ func newChannel(db *gorm.DB, opts ...gen.DOOption) channel {
|
||||
RelationField: field.NewRelation("Resource.Short.Sku", "models.ProductSku"),
|
||||
Product: struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Resource.Short.Sku.Product", "models.Product"),
|
||||
Skus: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Resource.Short.Sku.Product.Skus", "models.ProductSku"),
|
||||
},
|
||||
},
|
||||
Discount: struct {
|
||||
field.RelationField
|
||||
@@ -490,6 +504,9 @@ type channelBelongsToResource struct {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
|
||||
@@ -128,6 +128,9 @@ func newLogsUserUsage(db *gorm.DB, opts ...gen.DOOption) logsUserUsage {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
@@ -139,6 +142,9 @@ func newLogsUserUsage(db *gorm.DB, opts ...gen.DOOption) logsUserUsage {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
@@ -147,8 +153,16 @@ func newLogsUserUsage(db *gorm.DB, opts ...gen.DOOption) logsUserUsage {
|
||||
RelationField: field.NewRelation("Resource.Short.Sku", "models.ProductSku"),
|
||||
Product: struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Resource.Short.Sku.Product", "models.Product"),
|
||||
Skus: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Resource.Short.Sku.Product.Skus", "models.ProductSku"),
|
||||
},
|
||||
},
|
||||
Discount: struct {
|
||||
field.RelationField
|
||||
@@ -391,6 +405,9 @@ type logsUserUsageBelongsToResource struct {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
|
||||
@@ -36,6 +36,29 @@ func newProduct(db *gorm.DB, opts ...gen.DOOption) product {
|
||||
_product.Description = field.NewString(tableName, "description")
|
||||
_product.Sort = field.NewInt32(tableName, "sort")
|
||||
_product.Status = field.NewInt(tableName, "status")
|
||||
_product.Skus = productHasManySkus{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Skus", "models.ProductSku"),
|
||||
Product: struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Skus.Product", "models.Product"),
|
||||
Skus: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Skus.Product.Skus", "models.ProductSku"),
|
||||
},
|
||||
},
|
||||
Discount: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Skus.Discount", "models.ProductDiscount"),
|
||||
},
|
||||
}
|
||||
|
||||
_product.fillFieldMap()
|
||||
|
||||
@@ -55,6 +78,7 @@ type product struct {
|
||||
Description field.String
|
||||
Sort field.Int32
|
||||
Status field.Int
|
||||
Skus productHasManySkus
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
@@ -96,7 +120,7 @@ func (p *product) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
}
|
||||
|
||||
func (p *product) fillFieldMap() {
|
||||
p.fieldMap = make(map[string]field.Expr, 9)
|
||||
p.fieldMap = make(map[string]field.Expr, 10)
|
||||
p.fieldMap["id"] = p.ID
|
||||
p.fieldMap["created_at"] = p.CreatedAt
|
||||
p.fieldMap["updated_at"] = p.UpdatedAt
|
||||
@@ -106,18 +130,113 @@ func (p *product) fillFieldMap() {
|
||||
p.fieldMap["description"] = p.Description
|
||||
p.fieldMap["sort"] = p.Sort
|
||||
p.fieldMap["status"] = p.Status
|
||||
|
||||
}
|
||||
|
||||
func (p product) clone(db *gorm.DB) product {
|
||||
p.productDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
p.Skus.db = db.Session(&gorm.Session{Initialized: true})
|
||||
p.Skus.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
return p
|
||||
}
|
||||
|
||||
func (p product) replaceDB(db *gorm.DB) product {
|
||||
p.productDo.ReplaceDB(db)
|
||||
p.Skus.db = db.Session(&gorm.Session{})
|
||||
return p
|
||||
}
|
||||
|
||||
type productHasManySkus struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
|
||||
func (a productHasManySkus) Where(conds ...field.Expr) *productHasManySkus {
|
||||
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 productHasManySkus) WithContext(ctx context.Context) *productHasManySkus {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a productHasManySkus) Session(session *gorm.Session) *productHasManySkus {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a productHasManySkus) Model(m *models.Product) *productHasManySkusTx {
|
||||
return &productHasManySkusTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a productHasManySkus) Unscoped() *productHasManySkus {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type productHasManySkusTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a productHasManySkusTx) Find() (result []*models.ProductSku, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a productHasManySkusTx) Append(values ...*models.ProductSku) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a productHasManySkusTx) Replace(values ...*models.ProductSku) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a productHasManySkusTx) Delete(values ...*models.ProductSku) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a productHasManySkusTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a productHasManySkusTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a productHasManySkusTx) Unscoped() *productHasManySkusTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type productDo struct{ gen.DO }
|
||||
|
||||
func (p productDo) Debug() *productDo {
|
||||
|
||||
@@ -42,6 +42,27 @@ func newProductSku(db *gorm.DB, opts ...gen.DOOption) productSku {
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Product", "models.Product"),
|
||||
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"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_productSku.Discount = productSkuBelongsToDiscount{
|
||||
@@ -151,6 +172,16 @@ type productSkuBelongsToProduct struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a productSkuBelongsToProduct) Where(conds ...field.Expr) *productSkuBelongsToProduct {
|
||||
|
||||
@@ -115,8 +115,16 @@ func newProductSkuUser(db *gorm.DB, opts ...gen.DOOption) productSkuUser {
|
||||
RelationField: field.NewRelation("ProductSku", "models.ProductSku"),
|
||||
Product: struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("ProductSku.Product", "models.Product"),
|
||||
Skus: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("ProductSku.Product.Skus", "models.ProductSku"),
|
||||
},
|
||||
},
|
||||
Discount: struct {
|
||||
field.RelationField
|
||||
@@ -331,6 +339,9 @@ type productSkuUserBelongsToProductSku struct {
|
||||
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
|
||||
@@ -153,6 +153,9 @@ func newProxy(db *gorm.DB, opts ...gen.DOOption) proxy {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
@@ -181,6 +184,9 @@ func newProxy(db *gorm.DB, opts ...gen.DOOption) proxy {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
@@ -192,6 +198,9 @@ func newProxy(db *gorm.DB, opts ...gen.DOOption) proxy {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
@@ -200,8 +209,16 @@ func newProxy(db *gorm.DB, opts ...gen.DOOption) proxy {
|
||||
RelationField: field.NewRelation("Channels.Resource.Short.Sku", "models.ProductSku"),
|
||||
Product: struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Channels.Resource.Short.Sku.Product", "models.Product"),
|
||||
Skus: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Channels.Resource.Short.Sku.Product.Skus", "models.ProductSku"),
|
||||
},
|
||||
},
|
||||
Discount: struct {
|
||||
field.RelationField
|
||||
@@ -387,6 +404,9 @@ type proxyHasManyChannels struct {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
|
||||
@@ -44,6 +44,9 @@ func newResource(db *gorm.DB, opts ...gen.DOOption) resource {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
@@ -52,8 +55,16 @@ func newResource(db *gorm.DB, opts ...gen.DOOption) resource {
|
||||
RelationField: field.NewRelation("Short.Sku", "models.ProductSku"),
|
||||
Product: struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Short.Sku.Product", "models.Product"),
|
||||
Skus: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Short.Sku.Product.Skus", "models.ProductSku"),
|
||||
},
|
||||
},
|
||||
Discount: struct {
|
||||
field.RelationField
|
||||
@@ -266,6 +277,9 @@ type resourceHasOneShort struct {
|
||||
field.RelationField
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
|
||||
@@ -43,8 +43,16 @@ func newResourceLong(db *gorm.DB, opts ...gen.DOOption) resourceLong {
|
||||
RelationField: field.NewRelation("Sku", "models.ProductSku"),
|
||||
Product: struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Sku.Product", "models.Product"),
|
||||
Skus: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Sku.Product.Skus", "models.ProductSku"),
|
||||
},
|
||||
},
|
||||
Discount: struct {
|
||||
field.RelationField
|
||||
@@ -149,6 +157,9 @@ type resourceLongHasOneSku struct {
|
||||
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
|
||||
@@ -43,8 +43,16 @@ func newResourceShort(db *gorm.DB, opts ...gen.DOOption) resourceShort {
|
||||
RelationField: field.NewRelation("Sku", "models.ProductSku"),
|
||||
Product: struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Sku.Product", "models.Product"),
|
||||
Skus: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Sku.Product.Skus", "models.ProductSku"),
|
||||
},
|
||||
},
|
||||
Discount: struct {
|
||||
field.RelationField
|
||||
@@ -149,6 +157,9 @@ type resourceShortHasOneSku struct {
|
||||
|
||||
Product struct {
|
||||
field.RelationField
|
||||
Skus struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Discount struct {
|
||||
field.RelationField
|
||||
|
||||
Reference in New Issue
Block a user