diff --git a/controller/MealController.go b/controller/MealController.go index 30a9890..00e305c 100644 --- a/controller/MealController.go +++ b/controller/MealController.go @@ -89,7 +89,7 @@ func (s *MealController) UpdateMeal(c *gin.Context) { } func (s *MealController) DeleteMeal(c *gin.Context) { - id, _ := uuid.Parse(c.Param("mealsId")) + id, _ := uuid.Parse(c.Param("mealId")) err := s.mealService.Delete(id) if err != nil { c.AbortWithStatusJSON(200, dto.BaseResponse[any]{ diff --git a/repository/FoodConsumptionRepository.go b/repository/FoodConsumptionRepository.go index e1e79d1..0601674 100644 --- a/repository/FoodConsumptionRepository.go +++ b/repository/FoodConsumptionRepository.go @@ -40,7 +40,7 @@ func (r *FoodConsumptionRepository) Create(foodConsumption *model.FoodConsumptio } func (r *FoodConsumptionRepository) Update(foodConsumption *model.FoodConsumption) (sql.Result, error) { - return r.db.NewUpdate().Model(foodConsumption).Exec(r.ctx) + return r.db.NewUpdate().Model(foodConsumption).Where("id = ?", foodConsumption.ID).Exec(r.ctx) } func (r *FoodConsumptionRepository) Delete(foodConsumption *model.FoodConsumption) (sql.Result, error) { diff --git a/repository/MealRepository.go b/repository/MealRepository.go index f3d9ce7..e07b111 100644 --- a/repository/MealRepository.go +++ b/repository/MealRepository.go @@ -34,9 +34,9 @@ func (r *MealRepository) Create(meal *model.Meal) (sql.Result, error) { } func (r *MealRepository) Update(meal *model.Meal) (sql.Result, error) { - return r.db.NewUpdate().Model(meal).Exec(r.ctx) + return r.db.NewUpdate().Model(meal).Where("id = ?", meal.ID).Exec(r.ctx) } func (r *MealRepository) Delete(meal *model.Meal) (sql.Result, error) { - return r.db.NewDelete().Model(meal).Exec(r.ctx) + return r.db.NewDelete().Model(meal).Where("id = ?", meal.ID).Exec(r.ctx) }