Token and session implementation with Redis
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user