| | |
| | | return nil, errors.New("产品id为空") |
| | | } |
| | | var product test.SupplierMaterial |
| | | err := global.GVA_DB.Model(&test.SupplierMaterial{}).Where("number = ?", req.ProductId).First(&product).Error |
| | | err := global.GVA_DB.Model(&test.SupplierMaterial{}).Where("number = ?", req.ProductId).Order("id desc").First(&product).Error |
| | | if err != nil { |
| | | if err == gorm.ErrRecordNotFound { |
| | | var material test.Material |
| | |
| | | product.PurchasePrice = material.PurchasePrice.InexactFloat64() |
| | | product.Specifications = material.Specs |
| | | product.ModelNumber = material.Type |
| | | product.Name = material.Name |
| | | product.Name = material.Name |
| | | err = global.GVA_DB.Create(&product).Error |
| | | if err != nil { |
| | | return nil, err |