From a48026b8a0c952bb84065abaf164eb4763537066 Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期四, 16 十一月 2023 14:33:59 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS

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

diff --git a/models/location_product_amount.go b/models/location_product_amount.go
index 94cf597..dc1d0c3 100644
--- a/models/location_product_amount.go
+++ b/models/location_product_amount.go
@@ -17,7 +17,7 @@
 		LocationId        int             `json:"locationId" gorm:"type:int;not null;comment:浣嶇疆id"` //浣嶇疆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"`
+		ProductCategory   ProductCategory `json:"productCategory" gorm:"foreignKey:ProductCategoryID;references:ID"`
 		ProductId         string          `json:"productId" gorm:"type:varchar(191);not null;comment:浜у搧id"` //浜у搧id
 		Product           Material        `json:"product" gorm:"foreignKey:ProductId;references:ID"`
 		Amount            decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:搴撳瓨鏁伴噺"` //搴撳瓨鏁伴噺
@@ -124,7 +124,11 @@
 	}
 
 	if slf.Keyword != "" {
-		db = db.Where("product_name like ?", fmt.Sprintf("%%%v%%", slf.Keyword))
+		db = db.Joins("left join wms_location on wms_location_product_amount.location_id = wms_location.id").
+			Joins("left join material on wms_location_product_amount.product_id = material.id").
+			Joins("left join wms_product_category on wms_location_product_amount.product_category_id = wms_product_category.id").
+			Where("wms_location.name like ?", "%"+slf.Keyword+"%").Or("material.name like ?", "%"+slf.Keyword+"%").
+			Or("wms_product_category.name like ?", "%"+slf.Keyword+"%")
 	}
 
 	if slf.Preload {

--
Gitblit v1.8.0