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, } }