Update product receipe

This commit is contained in:
Aditya Siregar
2025-08-10 21:46:44 +07:00
parent 265248ba49
commit b72ab4ef3d
14 changed files with 1287 additions and 12 deletions
+16 -1
View File
@@ -32,6 +32,7 @@ type Router struct {
tableHandler *handler.TableHandler
unitHandler *handler.UnitHandler
ingredientHandler *handler.IngredientHandler
productRecipeHandler *handler.ProductRecipeHandler
authMiddleware *middleware.AuthMiddleware
}
@@ -67,7 +68,8 @@ func NewRouter(cfg *config.Config,
tableService *service.TableServiceImpl,
tableValidator *validator.TableValidator,
unitService handler.UnitService,
ingredientService handler.IngredientService) *Router {
ingredientService handler.IngredientService,
productRecipeService service.ProductRecipeService) *Router {
return &Router{
config: cfg,
@@ -89,6 +91,7 @@ func NewRouter(cfg *config.Config,
tableHandler: handler.NewTableHandler(tableService, tableValidator),
unitHandler: handler.NewUnitHandler(unitService),
ingredientHandler: handler.NewIngredientHandler(ingredientService),
productRecipeHandler: handler.NewProductRecipeHandler(productRecipeService),
authMiddleware: authMiddleware,
}
}
@@ -289,6 +292,18 @@ func (r *Router) addAppRoutes(rg *gin.Engine) {
ingredients.DELETE("/:id", r.ingredientHandler.Delete)
}
productRecipes := protected.Group("/product-recipes")
productRecipes.Use(r.authMiddleware.RequireAdminOrManager())
{
productRecipes.POST("", r.productRecipeHandler.Create)
productRecipes.POST("/bulk", r.productRecipeHandler.BulkCreate)
productRecipes.GET("/:id", r.productRecipeHandler.GetByID)
productRecipes.PUT("/:id", r.productRecipeHandler.Update)
productRecipes.DELETE("/:id", r.productRecipeHandler.Delete)
productRecipes.GET("/product/:product_id", r.productRecipeHandler.GetByProductID)
productRecipes.GET("/ingredient/:ingredient_id", r.productRecipeHandler.GetByIngredientID)
}
outlets := protected.Group("/outlets")
outlets.Use(r.authMiddleware.RequireAdminOrManager())
{