diff --git a/config/server.go b/config/server.go index 10ee173..647ea26 100644 --- a/config/server.go +++ b/config/server.go @@ -1,7 +1,8 @@ package config type Server struct { - Port string `mapstructure:"port"` - BaseUrl string `mapstructure:"common-url"` - LocalUrl string `mapstructure:"local-url"` + Port string `mapstructure:"port"` + BaseUrl string `mapstructure:"common-url"` + LocalUrl string `mapstructure:"local-url"` + SelfOrderUrl string `mapstructure:"self-order-url"` } diff --git a/infra/development.yaml b/infra/development.yaml index 68595c8..5baf5e8 100644 --- a/infra/development.yaml +++ b/infra/development.yaml @@ -1,6 +1,7 @@ server: base-url: local-url: + self-order-url: http://localhost:5174 port: 4000 jwt: diff --git a/internal/handler/table_handler.go b/internal/handler/table_handler.go index c9eee19..e3308b8 100644 --- a/internal/handler/table_handler.go +++ b/internal/handler/table_handler.go @@ -19,14 +19,14 @@ import ( type TableHandler struct { tableService TableService tableValidator *validator.TableValidator - baseURL string + selfOrderURL string } -func NewTableHandler(tableService TableService, tableValidator *validator.TableValidator, baseURL string) *TableHandler { +func NewTableHandler(tableService TableService, tableValidator *validator.TableValidator, selfOrderURL string) *TableHandler { return &TableHandler{ tableService: tableService, tableValidator: tableValidator, - baseURL: baseURL, + selfOrderURL: selfOrderURL, } } @@ -312,7 +312,7 @@ func (h *TableHandler) GenerateQRCode(c *gin.Context) { return } - selfOrderURL := fmt.Sprintf("%s/api/v1/self-order/table/%s", h.baseURL, token) + selfOrderURLResult := fmt.Sprintf("%s/menu?token=%s", h.selfOrderURL, token) size := 256 if sizeStr := c.Query("size"); sizeStr != "" { @@ -321,7 +321,7 @@ func (h *TableHandler) GenerateQRCode(c *gin.Context) { } } - pngBytes, err := qrcode.GeneratePNG(selfOrderURL, size) + pngBytes, err := qrcode.GeneratePNG(selfOrderURLResult, size) if err != nil { logger.FromContext(ctx).WithError(err).Error("TableHandler::GenerateQRCode -> QR generation failed") validationResponseError := contract.NewResponseError(constants.InternalServerErrorCode, constants.TableEntity, "Failed to generate QR code") diff --git a/internal/router/router.go b/internal/router/router.go index 7be1b05..e74d0b4 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -72,7 +72,7 @@ func NewRouter(cfg *config.Config, healthHandler *handler.HealthHandler, authSer paymentMethodHandler: handler.NewPaymentMethodHandler(paymentMethodService, paymentMethodValidator), analyticsHandler: handler.NewAnalyticsHandler(analyticsService, transformer.NewTransformer()), reportHandler: handler.NewReportHandler(reportService, userService), - tableHandler: handler.NewTableHandler(tableService, tableValidator, cfg.Server.BaseUrl), + tableHandler: handler.NewTableHandler(tableService, tableValidator, cfg.Server.SelfOrderUrl), unitHandler: handler.NewUnitHandler(unitService), ingredientHandler: handler.NewIngredientHandler(ingredientService), productRecipeHandler: handler.NewProductRecipeHandler(productRecipeService),