From f4508a84236a4aff1c7b5bfa17a14a8ff95728ba Mon Sep 17 00:00:00 2001
From: yinbentan <yinbentan@live.com>
Date: 星期一, 08 七月 2024 09:45:10 +0800
Subject: [PATCH] 接口调用报错处理

---
 models/location_product_amount.go |   28 ++++++++++++++++++++++------
 1 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/models/location_product_amount.go b/models/location_product_amount.go
index d4990b1..6b82f7c 100644
--- a/models/location_product_amount.go
+++ b/models/location_product_amount.go
@@ -11,10 +11,9 @@
 type (
 	LocationProductAmount struct {
 		WmsModel
-		Id int `json:"id"  gorm:"column:id;primary_key;AUTO_INCREMENT"`
-		//LocationProductId int             `json:"locationProductId" gorm:"type:int;not null;comment:涓婃灦瑙勫垯id"` //涓婃灦瑙勫垯id
-		//LocationProduct   LocationProduct `json:"locationProduct" gorm:"foreignKey:LocationProductId;references:Id"`
+		Id                int             `json:"id"  gorm:"column:id;primary_key;AUTO_INCREMENT"`
 		LocationId        int             `json:"locationId" gorm:"type:int;not null;comment:浣嶇疆id"` //浣嶇疆id
+		WarehouseId       int             `json:"warehouseId" gorm:"type:int;not null;default:0;comment:浠撳簱id"`
 		Location          Location        `json:"location" gorm:"foreignKey:LocationId;references:id"`
 		ProductCategoryID int             `json:"productCategoryId" gorm:"type:int;not null;comment:浜у搧绉嶇被id"` //浜у搧绉嶇被id
 		ProductCategory   ProductCategory `json:"productCategory" gorm:"foreignKey:ProductCategoryID;references:Id"`
@@ -37,6 +36,7 @@
 		ProductIds  []string
 		Ids         []int
 		Query       string
+		Fields      string
 	}
 
 	LocationProductAmountWithOperation struct {
@@ -127,6 +127,16 @@
 	return slf
 }
 
+func (slf *LocationProductAmountSearch) SetWarehouseId(wid int) *LocationProductAmountSearch {
+	slf.WarehouseId = wid
+	return slf
+}
+
+func (slf *LocationProductAmountSearch) SetFields(fields string) *LocationProductAmountSearch {
+	slf.Fields = fields
+	return slf
+}
+
 func (slf *LocationProductAmountSearch) build() *gorm.DB {
 	var db = slf.Orm.Model(&LocationProductAmount{})
 
@@ -148,9 +158,7 @@
 	if slf.Preload {
 		db = db.Model(&LocationProductAmount{}).Preload("Location").Preload("Product").Preload("ProductCategory")
 	}
-	//if slf.LocationProductId != 0 {
-	//	db = db.Where("location_product_id=?", slf.LocationProductId)
-	//}
+
 	if len(slf.ProductIds) > 0 {
 		db = db.Where("product_id in (?)", slf.ProductIds)
 	}
@@ -175,6 +183,14 @@
 		db = db.Where(slf.Query)
 	}
 
+	if slf.WarehouseId != 0 {
+		db = db.Where("warehouse_id = ?", slf.WarehouseId)
+	}
+
+	if slf.Fields != "" {
+		db = db.Select(slf.Fields)
+	}
+
 	return db
 }
 

--
Gitblit v1.8.0