From 7ffcc41e597c5af4169e3e2ab809fdbf869c2154 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期二, 18 七月 2023 16:08:47 +0800
Subject: [PATCH] add
---
model/contract.go | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/model/contract.go b/model/contract.go
index b47cedc..31b639b 100644
--- a/model/contract.go
+++ b/model/contract.go
@@ -7,13 +7,15 @@
type (
Contract struct {
- Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
- ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"`
- MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"`
- Number string `json:"number" gorm:"column:number;type:varchar(255);comment:鍚堝悓缂栧彿"`
- QuotationId int `json:"quotationId" gorm:"column:quotation_id;type:int;comment:鎶ヤ环鍗昳d"`
- StatusId int `json:"statusId" gorm:"column:status_id;type:int;comment:鍚堝悓鐘舵��"`
- File string `json:"file" gorm:"column:file;type:varchar(255);comment:鍚堝悓鏂囦欢"`
+ Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+ ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"`
+ MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"`
+ Number string `json:"number" gorm:"column:number;type:varchar(255);comment:鍚堝悓缂栧彿"`
+ QuotationId int `json:"quotationId" gorm:"column:quotation_id;type:int;comment:鎶ヤ环鍗昳d"`
+ Quotation Quotation `json:"quotation" gorm:"foreignKey:QuotationId;references:Id"`
+ StatusId int `json:"statusId" gorm:"column:status_id;type:int;comment:鍚堝悓鐘舵��"`
+ File string `json:"file" gorm:"column:file;type:varchar(255);comment:鍚堝悓鏂囦欢"`
+ gorm.Model `json:"-"`
}
ContractSearch struct {
@@ -66,7 +68,7 @@
func (slf *ContractSearch) FindAll() ([]*Contract, error) {
var db = slf.build()
var records = make([]*Contract, 0)
- err := db.Find(&records).Error
+ err := db.Preload("Quotation").Find(&records).Error
return records, err
}
--
Gitblit v1.8.0