Token and session implementation with Redis

This commit is contained in:
2026-05-08 18:41:14 +07:00
parent fe57aab3b4
commit 3c103b7692
20 changed files with 545 additions and 90 deletions
+9 -1
View File
@@ -37,9 +37,10 @@ type OrderServiceImpl struct {
orderIngredientTransactionProcessor processor.OrderIngredientTransactionProcessor
productRecipeRepo repository.ProductRecipeRepository
txManager *repository.TxManager
sessionRepo repository.SessionRepository
}
func NewOrderServiceImpl(orderProcessor processor.OrderProcessor, tableRepo repository.TableRepositoryInterface, orderIngredientTransactionService *OrderIngredientTransactionService, orderIngredientTransactionProcessor processor.OrderIngredientTransactionProcessor, productRecipeRepo repository.ProductRecipeRepository, txManager *repository.TxManager) *OrderServiceImpl {
func NewOrderServiceImpl(orderProcessor processor.OrderProcessor, tableRepo repository.TableRepositoryInterface, orderIngredientTransactionService *OrderIngredientTransactionService, orderIngredientTransactionProcessor processor.OrderIngredientTransactionProcessor, productRecipeRepo repository.ProductRecipeRepository, txManager *repository.TxManager, sessionRepo repository.SessionRepository) *OrderServiceImpl {
return &OrderServiceImpl{
orderProcessor: orderProcessor,
tableRepo: tableRepo,
@@ -47,6 +48,7 @@ func NewOrderServiceImpl(orderProcessor processor.OrderProcessor, tableRepo repo
orderIngredientTransactionProcessor: orderIngredientTransactionProcessor,
productRecipeRepo: productRecipeRepo,
txManager: txManager,
sessionRepo: sessionRepo,
}
}
@@ -621,6 +623,12 @@ func (s *OrderServiceImpl) handleTableReleaseOnPayment(ctx context.Context, orde
if err := s.tableRepo.ReleaseTable(ctx, table.ID, order.TotalAmount); err != nil {
return fmt.Errorf("failed to release table: %w", err)
}
if s.sessionRepo != nil {
if err := s.sessionRepo.CloseByTableID(ctx, table.ID); err != nil {
fmt.Printf("Warning: failed to close self-order session for table %s: %v\n", table.ID, err)
}
}
}
}