From 6ab6e517d224d8318a9a4ee189671a35bc2fbd2a Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期五, 01 三月 2024 11:02:47 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/silk/silkServer

---
 models/fineness.go |   31 ++++++++++++++++++++++---------
 1 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/models/fineness.go b/models/fineness.go
index 9486840..e8e7238 100644
--- a/models/fineness.go
+++ b/models/fineness.go
@@ -2,6 +2,7 @@
 
 import (
 	"fmt"
+	"github.com/shopspring/decimal"
 	"gorm.io/gorm"
 	"silkserver/pkg/mysqlx"
 )
@@ -10,15 +11,17 @@
 	// FinenessRegister 绾ゅ害鐧昏
 	FinenessRegister struct {
 		gorm.Model
-		Number        string         `gorm:"type:varchar(255);not null;comment:缂栧彿" json:"number"`        //缂栧彿
-		FinishDate    string         `gorm:"type:varchar(255);not null;comment:钀戒笣鏃堕棿" json:"finishDate"`  //钀戒笣鏃堕棿
-		Workshop      string         `gorm:"type:varchar(255);not null;comment:杞﹂棿" json:"name"`          //杞﹂棿
-		WorkshopGroup string         `gorm:"type:varchar(255);not null;comment:杞︾粍" json:"workshopGroup"` //杞︾粍
-		Market        string         `gorm:"type:varchar(255);not null;comment:搴勫彛" json:"market"`        //搴勫彛
-		Spec          string         `gorm:"type:varchar(255);not null;comment:瑙勬牸" json:"spec"`          //瑙勬牸
-		StartCircle   uint8          `gorm:"type:varchar(255);not null;comment:寮�濮嬪洖鏁�" json:"startCircle"` //寮�濮嬪洖鏁�
-		EndCircle     uint8          `gorm:"type:varchar(255);not null;comment:缁撴潫鍥炴暟" json:"endCircle"`   //缁撴潫鍥炴暟
-		FinenessList  []FinenessItem `gorm:"foreignkey:FinenessRegisterID" json:"finenessList"`
+		Number        string          `gorm:"type:varchar(255);not null;comment:缂栧彿" json:"number"`        //缂栧彿
+		FinishDate    string          `gorm:"type:varchar(255);not null;comment:钀戒笣鏃堕棿" json:"finishDate"`  //钀戒笣鏃堕棿
+		Workshop      string          `gorm:"type:varchar(255);not null;comment:杞﹂棿" json:"name"`          //杞﹂棿
+		WorkshopGroup string          `gorm:"type:varchar(255);not null;comment:杞︾粍" json:"workshopGroup"` //杞︾粍
+		Market        string          `gorm:"type:varchar(255);not null;comment:搴勫彛" json:"market"`        //搴勫彛
+		Spec          string          `gorm:"type:varchar(255);not null;comment:瑙勬牸" json:"spec"`          //瑙勬牸
+		StartCircle   uint8           `gorm:"type:varchar(255);not null;comment:寮�濮嬪洖鏁�" json:"startCircle"` //寮�濮嬪洖鏁�
+		EndCircle     uint8           `gorm:"type:varchar(255);not null;comment:缁撴潫鍥炴暟" json:"endCircle"`   //缁撴潫鍥炴暟
+		FinenessList  []FinenessItem  `gorm:"foreignkey:FinenessRegisterID;references:ID" json:"finenessList"`
+		SumFineness   decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:鍚堣绾ゅ害" json:"sumFineness"`
+		SumQuantity   decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:鍚堣鏁伴噺" json:"sumQuantity"`
 	}
 	FinenessRegisterSearch struct {
 		FinenessRegister
@@ -26,6 +29,7 @@
 		PageNum  int
 		PageSize int
 		Orm      *gorm.DB
+		Preload  bool
 	}
 )
 
@@ -52,6 +56,11 @@
 	return slf
 }
 
+func (slf *FinenessRegisterSearch) SetPreload() *FinenessRegisterSearch {
+	slf.Preload = true
+	return slf
+}
+
 func (slf *FinenessRegisterSearch) SetID(id uint) *FinenessRegisterSearch {
 	slf.ID = id
 	return slf
@@ -77,6 +86,10 @@
 		db = db.Where("number = ?", slf.Number)
 	}
 
+	if slf.Preload {
+		db = db.Model(&FinenessRegister{}).Preload("FinenessList")
+	}
+
 	return db
 }
 

--
Gitblit v1.8.0