upstream sync
This commit is contained in:
@@ -182,6 +182,29 @@ func GetContractByID(contractID uint64) (models.Contract, int, error) {
|
||||
return contract, http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
return contract, http.StatusOK, nil
|
||||
// Fetch the product
|
||||
var product models.ProductTemplate
|
||||
if err := shared.GetDb().Unscoped().Where("id = ?", contract.ProductID).First(&product).Error; err != nil {
|
||||
log.Printf("GetContractByID Error: Could not fetch product: %v", err)
|
||||
return contract, http.StatusInternalServerError, err
|
||||
}
|
||||
contract.ProductName = product.Name
|
||||
|
||||
// Fetch the seller
|
||||
var seller models.Company
|
||||
if err := shared.GetDb().Unscoped().Where("id = ?", contract.SellerID).First(&seller).Error; err != nil {
|
||||
log.Printf("GetContractByID Error: Could not fetch seller: %v", err)
|
||||
return contract, http.StatusInternalServerError, err
|
||||
}
|
||||
contract.SellerName = seller.Name
|
||||
|
||||
// Fetch the buyer
|
||||
var buyer models.Company
|
||||
if err := shared.GetDb().Unscoped().Where("id = ?", contract.BuyerID).First(&buyer).Error; err != nil {
|
||||
log.Printf("GetContractByID Error: Could not fetch buyer: %v", err)
|
||||
return contract, http.StatusInternalServerError, err
|
||||
}
|
||||
contract.BuyerName = buyer.Name
|
||||
|
||||
return contract, http.StatusOK, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user