From b932538cd4d2090ae82c790441002ad44b0da46a Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期五, 21 七月 2023 13:37:02 +0800
Subject: [PATCH] add
---
model/salesDetails.go | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/model/salesDetails.go b/model/salesDetails.go
index ee8b04b..d2c4ee9 100644
--- a/model/salesDetails.go
+++ b/model/salesDetails.go
@@ -10,6 +10,7 @@
SalesDetails struct {
Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"`
+ Client Client `json:"client" gorm:"foreignKey:ClientId"`
Number string `json:"number" gorm:"column:number;type:varchar(255);comment:閿�鍞瓙鍗曞彿"`
SaleChanceId int `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:閿�鍞満浼歩d"`
SaleType int `json:"saleType" gorm:"column:sale_type;type:int;comment:閿�鍞被鍨�"`
@@ -23,6 +24,7 @@
Conditions string `json:"conditions" gorm:"column:conditions;type:text;comment:鏉′欢"`
Remark string `json:"remark" gorm:"column:remark;type:text;comment:澶囨敞"`
Products []Product `json:"products" gorm:"many2many:salesDetails_product;"`
+ gorm.Model `json:"-"`
}
SalesDetailsSearch struct {
@@ -80,6 +82,6 @@
func (slf *SalesDetailsSearch) FindAll() ([]*SalesDetails, error) {
var db = slf.build()
var records = make([]*SalesDetails, 0)
- err := db.Preload("Products").Find(&records).Error
+ err := db.Preload("Products").Preload("Client").Find(&records).Error
return records, err
}
--
Gitblit v1.8.0