From f45e4cb8045fe60f96f467dc4ea1e2ae57445712 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期三, 03 七月 2024 23:13:40 +0800
Subject: [PATCH] 默认位置parent_id为视图位置id

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

diff --git a/models/location_product_amount.go b/models/location_product_amount.go
index 447b469..d4990b1 100644
--- a/models/location_product_amount.go
+++ b/models/location_product_amount.go
@@ -47,10 +47,11 @@
 		ProductId               string                     `json:"productId" gorm:"column:product_id"`
 		ProductName             string                     `json:"productName" gorm:"column:product_name"`
 		Amount                  decimal.Decimal            `json:"amount" gorm:"column:amount"`
+		AmountMoreUnits         []UnitItems                `json:"amountMoreUnits" gorm:"-"` //鍦ㄥ簱鏁伴噺澶氬崟浣�
 		Unit                    string                     `json:"unit" gorm:"column:unit"`
 		CreateDate              string                     `json:"createDate" gorm:"column:create_date"`
-		AdjustAmount            decimal.Decimal            `json:"adjustAmount" gorm:"column:adjust_amount"`
-		DifferenceAmount        decimal.Decimal            `json:"differenceAmount" gorm:"-"`
+		AdjustAmount            decimal.Decimal            `json:"adjustAmount" gorm:"column:adjust_amount"` //宸��
+		DifferenceAmount        decimal.Decimal            `json:"differenceAmount" gorm:"-"`                //璁℃暟鏁伴噺
 		OperationId             int                        `json:"operationId" gorm:"column:operation_id"`
 		Status                  constvar.OperationStatus   `json:"status" gorm:"status"`
 		BaseOperationType       constvar.BaseOperationType `json:"baseOperationType" gorm:"base_operation_type"`
@@ -253,6 +254,9 @@
 		db      = slf.build()
 	)
 
+	if slf.PageNum*slf.PageSize > 0 {
+		db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
+	}
 	if err := db.Find(&records).Error; err != nil {
 		return records, fmt.Errorf("find records err: %v", err)
 	}
@@ -311,3 +315,13 @@
 	}
 	return result, nil
 }
+
+func (slf *LocationProductAmountSearch) Save(record *LocationProductAmount) 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