From 7f8a45a749419c3da5b81c4683f0b8034f5280f3 Mon Sep 17 00:00:00 2001 From: wangpengfei <274878379@qq.com> Date: 星期二, 25 七月 2023 15:20:09 +0800 Subject: [PATCH] fix --- model/salesDetails.go | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/model/salesDetails.go b/model/salesDetails.go index ee8b04b..8755d28 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,10 @@ 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;"` + LogisticCompany string `json:"logisticCompany" gorm:"column:logistic_company;type:varchar(255);comment:鐗╂祦鍏徃"` + LogisticNumber string `json:"logisticNumber" gorm:"column:logistic_number;type:varchar(255);comment:鐗╂祦鍗曞彿"` + LogisticCost float64 `json:"logisticCost" gorm:"column:logistic_cost;type:decimal(10,2);comment:鐗╂祦璐圭敤"` + gorm.Model `json:"-"` } SalesDetailsSearch struct { @@ -80,6 +85,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