update url qrcode table

This commit is contained in:
Efril 2026-05-10 14:13:20 +07:00
parent 9f653eef37
commit 1834dd0b19
4 changed files with 11 additions and 9 deletions

View File

@ -4,4 +4,5 @@ type Server struct {
Port string `mapstructure:"port"` Port string `mapstructure:"port"`
BaseUrl string `mapstructure:"common-url"` BaseUrl string `mapstructure:"common-url"`
LocalUrl string `mapstructure:"local-url"` LocalUrl string `mapstructure:"local-url"`
SelfOrderUrl string `mapstructure:"self-order-url"`
} }

View File

@ -1,6 +1,7 @@
server: server:
base-url: base-url:
local-url: local-url:
self-order-url: http://localhost:5174
port: 4000 port: 4000
jwt: jwt:

View File

@ -19,14 +19,14 @@ import (
type TableHandler struct { type TableHandler struct {
tableService TableService tableService TableService
tableValidator *validator.TableValidator 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{ return &TableHandler{
tableService: tableService, tableService: tableService,
tableValidator: tableValidator, tableValidator: tableValidator,
baseURL: baseURL, selfOrderURL: selfOrderURL,
} }
} }
@ -312,7 +312,7 @@ func (h *TableHandler) GenerateQRCode(c *gin.Context) {
return 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 size := 256
if sizeStr := c.Query("size"); sizeStr != "" { 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 { if err != nil {
logger.FromContext(ctx).WithError(err).Error("TableHandler::GenerateQRCode -> QR generation failed") logger.FromContext(ctx).WithError(err).Error("TableHandler::GenerateQRCode -> QR generation failed")
validationResponseError := contract.NewResponseError(constants.InternalServerErrorCode, constants.TableEntity, "Failed to generate QR code") validationResponseError := contract.NewResponseError(constants.InternalServerErrorCode, constants.TableEntity, "Failed to generate QR code")

View File

@ -72,7 +72,7 @@ func NewRouter(cfg *config.Config, healthHandler *handler.HealthHandler, authSer
paymentMethodHandler: handler.NewPaymentMethodHandler(paymentMethodService, paymentMethodValidator), paymentMethodHandler: handler.NewPaymentMethodHandler(paymentMethodService, paymentMethodValidator),
analyticsHandler: handler.NewAnalyticsHandler(analyticsService, transformer.NewTransformer()), analyticsHandler: handler.NewAnalyticsHandler(analyticsService, transformer.NewTransformer()),
reportHandler: handler.NewReportHandler(reportService, userService), 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), unitHandler: handler.NewUnitHandler(unitService),
ingredientHandler: handler.NewIngredientHandler(ingredientService), ingredientHandler: handler.NewIngredientHandler(ingredientService),
productRecipeHandler: handler.NewProductRecipeHandler(productRecipeService), productRecipeHandler: handler.NewProductRecipeHandler(productRecipeService),