From 4405d1f3f1e16f0d42a9779987a488405ca31a0a Mon Sep 17 00:00:00 2001 From: huang <1724659546@qq.com> Date: Sat, 22 Nov 2025 17:29:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/app/api/router.go | 1 + internal/app/service/feed_management_service.go | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/app/api/router.go b/internal/app/api/router.go index 800aeaa..98f03b5 100644 --- a/internal/app/api/router.go +++ b/internal/app/api/router.go @@ -226,6 +226,7 @@ func (a *API) setupRoutes() { // 原料 (RawMaterial) 路由 feedGroup.POST("/raw-materials", a.feedController.CreateRawMaterial) feedGroup.PUT("/raw-materials/:id", a.feedController.UpdateRawMaterial) + feedGroup.PUT("/raw-materials/:id/nutrients", a.feedController.UpdateRawMaterialNutrients) feedGroup.DELETE("/raw-materials/:id", a.feedController.DeleteRawMaterial) feedGroup.GET("/raw-materials/:id", a.feedController.GetRawMaterial) feedGroup.GET("/raw-materials", a.feedController.ListRawMaterials) diff --git a/internal/app/service/feed_management_service.go b/internal/app/service/feed_management_service.go index ba2eb62..3fdb4b2 100644 --- a/internal/app/service/feed_management_service.go +++ b/internal/app/service/feed_management_service.go @@ -245,8 +245,9 @@ func (s *feedManagementServiceImpl) UpdateRawMaterialNutrients(ctx context.Conte nutrients := make([]models.RawMaterialNutrient, len(req.Nutrients)) for i, item := range req.Nutrients { nutrients[i] = models.RawMaterialNutrient{ - NutrientID: item.NutrientID, - Value: item.Value, + RawMaterialID: id, + NutrientID: item.NutrientID, + Value: item.Value, } }