fix
wangpengfei
2023-07-12 4dac8667bbac83c06d6e0df113b3ffdda8416e1c
fix

contract preload
1个文件已修改
17 ■■■■ 已修改文件
model/contract.go 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/contract.go
@@ -7,13 +7,14 @@
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:负责人id"`
        Number      string `json:"number" gorm:"column:number;type:varchar(255);comment:合同编号"`
        QuotationId int    `json:"quotationId" gorm:"column:quotation_id;type:int;comment:报价单id"`
        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:负责人id"`
        Number      string    `json:"number" gorm:"column:number;type:varchar(255);comment:合同编号"`
        QuotationId int       `json:"quotationId" gorm:"column:quotation_id;type:int;comment:报价单id"`
        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:合同文件"`
    }
    ContractSearch struct {
@@ -66,7 +67,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
}