This commit is contained in:
Aditya Siregar
2025-09-13 15:37:26 +07:00
parent 4f6208e479
commit cfe690a40f
15 changed files with 1199 additions and 2 deletions
+15 -1
View File
@@ -40,6 +40,7 @@ type Router struct {
chartOfAccountHandler *handler.ChartOfAccountHandler
accountHandler *handler.AccountHandler
orderIngredientTransactionHandler *handler.OrderIngredientTransactionHandler
voucherHandler *handler.VoucherHandler
authMiddleware *middleware.AuthMiddleware
}
@@ -90,7 +91,9 @@ func NewRouter(cfg *config.Config,
accountService service.AccountService,
accountValidator validator.AccountValidator,
orderIngredientTransactionService service.OrderIngredientTransactionService,
orderIngredientTransactionValidator validator.OrderIngredientTransactionValidator) *Router {
orderIngredientTransactionValidator validator.OrderIngredientTransactionValidator,
voucherService service.VoucherService,
voucherValidator validator.VoucherValidator) *Router {
return &Router{
config: cfg,
@@ -120,6 +123,7 @@ func NewRouter(cfg *config.Config,
chartOfAccountHandler: handler.NewChartOfAccountHandler(chartOfAccountService, chartOfAccountValidator),
accountHandler: handler.NewAccountHandler(accountService, accountValidator),
orderIngredientTransactionHandler: handler.NewOrderIngredientTransactionHandler(&orderIngredientTransactionService, orderIngredientTransactionValidator),
voucherHandler: handler.NewVoucherHandler(voucherService, voucherValidator),
authMiddleware: authMiddleware,
}
}
@@ -426,6 +430,16 @@ func (r *Router) addAppRoutes(rg *gin.Engine) {
orderIngredientTransactions.POST("/bulk", r.orderIngredientTransactionHandler.BulkCreateOrderIngredientTransactions)
}
vouchers := protected.Group("/vouchers")
vouchers.Use(r.authMiddleware.RequireAdminOrManager())
{
vouchers.GET("/spin", r.voucherHandler.GetRandomVouchersForSpin)
vouchers.GET("/rows", r.voucherHandler.GetRandomVouchersByRows)
vouchers.GET("", r.voucherHandler.ListVouchers)
vouchers.GET("/:id", r.voucherHandler.GetVoucherByID)
vouchers.GET("/code/:code", r.voucherHandler.GetVoucherByCode)
}
outlets := protected.Group("/outlets")
outlets.Use(r.authMiddleware.RequireAdminOrManager())
{