update product response
This commit is contained in:
parent
3db4afbce6
commit
d695bedc97
@ -19,5 +19,5 @@ type Ingredient struct {
|
|||||||
Metadata Metadata `gorm:"type:jsonb;default:'{}'" json:"metadata"`
|
Metadata Metadata `gorm:"type:jsonb;default:'{}'" json:"metadata"`
|
||||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||||
Unit *Unit `gorm:"foreignKey:UnitID" json:"unit,omitempty"`
|
Unit *Unit `gorm:"foreignKey:UnitID;references:ID" json:"unit,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,7 @@ func (r *ProductRecipeRepository) GetByID(ctx context.Context, id, organizationI
|
|||||||
Preload("Product").
|
Preload("Product").
|
||||||
Preload("ProductVariant").
|
Preload("ProductVariant").
|
||||||
Preload("Ingredient").
|
Preload("Ingredient").
|
||||||
|
Preload("Ingredient.Unit").
|
||||||
Where("id = ? AND organization_id = ?", id, organizationID).
|
Where("id = ? AND organization_id = ?", id, organizationID).
|
||||||
First(&productRecipe).Error
|
First(&productRecipe).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -41,6 +42,7 @@ func (r *ProductRecipeRepository) GetByProductID(ctx context.Context, productID,
|
|||||||
Preload("Product").
|
Preload("Product").
|
||||||
Preload("ProductVariant").
|
Preload("ProductVariant").
|
||||||
Preload("Ingredient").
|
Preload("Ingredient").
|
||||||
|
Preload("Ingredient.Unit").
|
||||||
Where("product_id = ? AND organization_id = ?", productID, organizationID).
|
Where("product_id = ? AND organization_id = ?", productID, organizationID).
|
||||||
Order("created_at DESC").
|
Order("created_at DESC").
|
||||||
Find(&productRecipes).Error
|
Find(&productRecipes).Error
|
||||||
@ -56,6 +58,7 @@ func (r *ProductRecipeRepository) GetByProductAndVariantID(ctx context.Context,
|
|||||||
Preload("Product").
|
Preload("Product").
|
||||||
Preload("ProductVariant").
|
Preload("ProductVariant").
|
||||||
Preload("Ingredient").
|
Preload("Ingredient").
|
||||||
|
Preload("Ingredient.Unit").
|
||||||
Where("product_id = ? AND organization_id = ?", productID, organizationID)
|
Where("product_id = ? AND organization_id = ?", productID, organizationID)
|
||||||
|
|
||||||
if variantID != nil {
|
if variantID != nil {
|
||||||
@ -77,6 +80,7 @@ func (r *ProductRecipeRepository) GetByIngredientID(ctx context.Context, ingredi
|
|||||||
Preload("Product").
|
Preload("Product").
|
||||||
Preload("ProductVariant").
|
Preload("ProductVariant").
|
||||||
Preload("Ingredient").
|
Preload("Ingredient").
|
||||||
|
Preload("Ingredient.Unit").
|
||||||
Where("ingredient_id = ? AND organization_id = ?", ingredientID, organizationID).
|
Where("ingredient_id = ? AND organization_id = ?", ingredientID, organizationID).
|
||||||
Order("created_at DESC").
|
Order("created_at DESC").
|
||||||
Find(&productRecipes).Error
|
Find(&productRecipes).Error
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user