From 68200e7e7ac1cfd021b8b37a92b7ab8eb11c759e Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期五, 03 十一月 2023 11:36:46 +0800
Subject: [PATCH] 上架规则列表搜索增加产品和产品类别
---
models/product_category.go | 37 +++++++++++++++++++++++++++----------
1 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/models/product_category.go b/models/product_category.go
index f71115a..62f611d 100644
--- a/models/product_category.go
+++ b/models/product_category.go
@@ -10,15 +10,14 @@
type (
// ProductCategory 浜у搧鍒嗙被
ProductCategory struct {
- WmsModel
- Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
- Name string `json:"name" gorm:"index;type:varchar(255);not null;comment:浣嶇疆鍚嶇О"` //浣嶇疆鍚嶇О
- ParentId int `json:"parentId" gorm:"type:int;not null"` //涓婄骇id
- CompanyId int `json:"companyId" gorm:"type:int;not null"` //鍏徃id
- Company Company `json:"company" gorm:"foreignKey:CompanyId"` //鍏徃
- ForceRemovalStrategy constvar.ForceRemovalStrategy `json:"forceRemovalStrategy" gorm:"type:tinyint;not null;comment:寮哄埗涓嬫灦绛栫暐"` //寮哄埗涓嬫灦绛栫暐
- CostingMethod constvar.CostingMethod `json:"costingMethod" gorm:"type:tinyint;not null;comment:鎴愭湰鏂规硶"` //鎴愭湰鏂规硶
- InventoryValuation constvar.InventoryValuation `json:"inventoryValuation" gorm:"type:tinyint;not null;comment:鎴愭湰鏂规硶"` //搴撳瓨璁′环
+ BaseModelInt
+ Name string `json:"name" gorm:"index;type:varchar(255);not null;comment:鍒嗙被鍚嶇О"` //鍒嗙被鍚嶇О
+ ParentId int `json:"parentId" gorm:"type:int;comment:涓婄骇鍒嗙被id"` //涓婄骇id
+ RouteId int `json:"routeId" gorm:"type:int;comment:璺嚎id"` //璺嚎id
+ RouteName string `json:"routeName" gorm:"type:varchar(512);comment:璺嚎鍚嶇О"` //鍏徃
+ ForceRemovalStrategy constvar.ForceRemovalStrategy `json:"forceRemovalStrategy" gorm:"type:tinyint;comment:寮哄埗涓嬫灦绛栫暐"` //寮哄埗涓嬫灦绛栫暐
+ CostingMethod constvar.CostingMethod `json:"costingMethod" gorm:"type:tinyint;comment:鎴愭湰鏂规硶"` //鎴愭湰鏂规硶
+ InventoryValuation constvar.InventoryValuation `json:"inventoryValuation" gorm:"type:tinyint;comment:搴撳瓨璁′环"` //搴撳瓨璁′环
}
ProductCategorySearch struct {
@@ -29,11 +28,12 @@
Keyword string
Orm *gorm.DB
Preload bool
+ Ids []int
}
)
func (slf *ProductCategory) TableName() string {
- return "ProductCategory"
+ return "wms_product_category"
}
func NewProductCategorySearch() *ProductCategorySearch {
@@ -74,6 +74,10 @@
slf.Preload = preload
return slf
}
+func (slf *ProductCategorySearch) SetIds(ids []int) *ProductCategorySearch {
+ slf.Ids = ids
+ return slf
+}
func (slf *ProductCategorySearch) build() *gorm.DB {
var db = slf.Orm.Model(&ProductCategory{})
@@ -92,6 +96,9 @@
if slf.Name != "" {
db = db.Where("name = ?", slf.Name)
+ }
+ if len(slf.Ids) > 0 {
+ db = db.Where("id in (?)", slf.Ids)
}
return db
@@ -244,3 +251,13 @@
return records, nil
}
+
+func (slf *ProductCategorySearch) Save(record *ProductCategory) error {
+ var db = slf.build()
+
+ if err := db.Omit("CreatedAt").Save(record).Error; err != nil {
+ return fmt.Errorf("save err: %v, record: %+v", err, record)
+ }
+
+ return nil
+}
--
Gitblit v1.8.0