From 0eac8cd498471e510c1887a914e6e28d1dfb4b19 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期二, 31 十月 2023 11:54:49 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS

---
 models/location_product.go |   29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/models/location_product.go b/models/location_product.go
index f737765..6a66ba5 100644
--- a/models/location_product.go
+++ b/models/location_product.go
@@ -3,21 +3,23 @@
 import (
 	"fmt"
 	"gorm.io/gorm"
+	"wms/constvar"
 	"wms/pkg/mysqlx"
 )
 
 type (
 	LocationProduct struct {
 		WmsModel
-		Id                int             `json:"id"  gorm:"column:id;primary_key;AUTO_INCREMENT"`
-		LocationId        int             `json:"locationId" gorm:"type:int;not null;comment:浣嶇疆id"` //浣嶇疆id
-		Location          Location        `json:"location" gorm:"foreignKey:LocationId;references:id"`
-		AreaId            int             `json:"areaId" grom:"type:int;not null;comment:鍖哄煙id"` //鍖哄煙id
-		Area              Location        `json:"area" gorm:"foreignKey:AreaId;references:id"`
-		ProductCategoryID int             `json:"productCategoryId" gorm:"type:int;not null;comment:浜у搧绉嶇被id"` //浜у搧绉嶇被id
-		ProductCategory   ProductCategory `json:"productCategory"`
-		ProductId         string          `json:"productId" gorm:"type:varchar(191);not null;comment:浜у搧id"` //浜у搧id
-		Product           Material        `json:"product" gorm:"foreignKey:ProductId;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
+		Location          Location          `json:"location" gorm:"foreignKey:LocationId;references:id"`
+		AreaId            int               `json:"areaId" grom:"type:int;not null;comment:鍖哄煙id"` //鍖哄煙id
+		Area              Location          `json:"area" gorm:"foreignKey:AreaId;references:id"`
+		ProductCategoryID int               `json:"productCategoryId" gorm:"type:int;not null;comment:浜у搧绉嶇被id"` //浜у搧绉嶇被id
+		ProductCategory   ProductCategory   `json:"productCategory"`
+		ProductId         string            `json:"productId" gorm:"type:varchar(191);not null;comment:浜у搧id"` //浜у搧id
+		Product           Material          `json:"product" gorm:"foreignKey:ProductId;references:ID"`
+		RuleType          constvar.RuleType `json:"ruleType" gorm:"type:int(11);not null;comment:涓婃灦瑙勫垯绫诲瀷 1锛氫骇鍝佺被鍨嬶紱2锛氫骇鍝佺被鍒被鍨�"`
 	}
 
 	LocationProductSearch struct {
@@ -90,6 +92,11 @@
 	return slf
 }
 
+func (slf *LocationProductSearch) SetProductCategoryId(productCategoryID int) *LocationProductSearch {
+	slf.ProductCategoryID = productCategoryID
+	return slf
+}
+
 func (slf *LocationProductSearch) build() *gorm.DB {
 	var db = slf.Orm.Model(&LocationProduct{})
 
@@ -130,6 +137,10 @@
 		db = db.Where("area_id = ?", slf.AreaId)
 	}
 
+	if slf.ProductCategoryID != 0 {
+		db = db.Where("product_category_id = ?", slf.ProductCategoryID)
+	}
+
 	return db
 }
 

--
Gitblit v1.8.0