From 670cb9b9a9bd96f3a71682e944a4cf3f86f51528 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期四, 29 二月 2024 17:54:57 +0800
Subject: [PATCH] 获取纤度登记详情

---
 models/fineness.go |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/models/fineness.go b/models/fineness.go
index 9486840..44b018d 100644
--- a/models/fineness.go
+++ b/models/fineness.go
@@ -18,7 +18,7 @@
 		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"`
+		FinenessList  []FinenessItem `gorm:"foreignkey:FinenessRegisterID;references:ID" json:"finenessList"`
 	}
 	FinenessRegisterSearch struct {
 		FinenessRegister
@@ -26,6 +26,7 @@
 		PageNum  int
 		PageSize int
 		Orm      *gorm.DB
+		Preload  bool
 	}
 )
 
@@ -52,6 +53,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 +83,10 @@
 		db = db.Where("number = ?", slf.Number)
 	}
 
+	if slf.Preload {
+		db = db.Model(&FinenessRegister{}).Preload("FinenessList")
+	}
+
 	return db
 }
 

--
Gitblit v1.8.0