From a0125ef3d6ce35be7b6dc4919c4192dba4a7329a Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期四, 16 十一月 2023 14:33:51 +0800
Subject: [PATCH] 报废数量bug

---
 models/operation_details.go |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/models/operation_details.go b/models/operation_details.go
index 8517d8c..067ba63 100644
--- a/models/operation_details.go
+++ b/models/operation_details.go
@@ -100,6 +100,9 @@
 	if slf.ProductId != "" {
 		db = db.Where("product_id = ?", slf.ProductId)
 	}
+	if slf.Preload {
+		db = db.Preload("Product")
+	}
 
 	return db
 }
@@ -207,7 +210,7 @@
 	if slf.PageNum*slf.PageSize > 0 {
 		db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
 	}
-	if err := db.Preload("Product").Find(&records).Error; err != nil {
+	if err := db.Find(&records).Error; err != nil {
 		return records, fmt.Errorf("find records err: %v", err)
 	}
 

--
Gitblit v1.8.0