This commit is contained in:
Aditya Siregar
2025-09-18 02:01:50 +07:00
parent 259b8a11b5
commit f64fec1fe2
10 changed files with 743 additions and 247 deletions
+16 -1
View File
@@ -44,7 +44,9 @@ type Router struct {
rewardHandler *handler.RewardHandler
campaignHandler *handler.CampaignHandler
customerAuthHandler *handler.CustomerAuthHandler
customerPointsHandler *handler.CustomerPointsHandler
authMiddleware *middleware.AuthMiddleware
customerAuthMiddleware *middleware.CustomerAuthMiddleware
}
func NewRouter(cfg *config.Config,
@@ -102,7 +104,9 @@ func NewRouter(cfg *config.Config,
campaignService service.CampaignService,
campaignValidator validator.CampaignValidator,
customerAuthService service.CustomerAuthService,
customerAuthValidator validator.CustomerAuthValidator) *Router {
customerAuthValidator validator.CustomerAuthValidator,
customerPointsService service.CustomerPointsService,
customerAuthMiddleware *middleware.CustomerAuthMiddleware) *Router {
return &Router{
config: cfg,
@@ -136,7 +140,9 @@ func NewRouter(cfg *config.Config,
rewardHandler: handler.NewRewardHandler(rewardService, rewardValidator),
campaignHandler: handler.NewCampaignHandler(campaignService, campaignValidator),
customerAuthHandler: handler.NewCustomerAuthHandler(customerAuthService, customerAuthValidator),
customerPointsHandler: handler.NewCustomerPointsHandler(customerPointsService),
authMiddleware: authMiddleware,
customerAuthMiddleware: customerAuthMiddleware,
}
}
@@ -181,6 +187,15 @@ func (r *Router) addAppRoutes(rg *gin.Engine) {
customerAuth.POST("/resend-otp", r.customerAuthHandler.ResendOtp)
}
// Customer authenticated routes
customer := v1.Group("/customer")
customer.Use(r.customerAuthMiddleware.ValidateCustomerToken())
{
customer.GET("/points", r.customerPointsHandler.GetCustomerPoints)
customer.GET("/tokens", r.customerPointsHandler.GetCustomerTokens)
customer.GET("/wallet", r.customerPointsHandler.GetCustomerWallet)
}
organizations := v1.Group("/organizations")
{
organizations.POST("", r.organizationHandler.CreateOrganization)