saveinmed/backend/internal/notifications/service.go
Gabbriiel 90467db1ec refactor: substitui backend Medusa por backend Go e corrige testes do marketplace
- Remove backend Medusa.js (TypeScript) e substitui pelo backend Go (saveinmed-performance-core)
- Corrige testes auth.test.ts: alinha paths de API (v1/ sem barra inicial) e campo access_token
- Corrige GroupedProductCard.test.tsx: ajusta distância formatada (toFixed) e troca userEvent por fireEvent com fakeTimers
- Corrige AuthContext.test.tsx: usa vi.hoisted() para mocks e corrige parênteses no waitFor

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 04:56:37 -06:00

37 lines
1.5 KiB
Go

package notifications
import (
"context"
"log"
"github.com/saveinmed/backend-go/internal/domain"
)
// NotificationService defines the contract for sending alerts.
type NotificationService interface {
NotifyOrderCreated(ctx context.Context, order *domain.Order, buyer, seller *domain.User) error
NotifyOrderStatusChanged(ctx context.Context, order *domain.Order, buyer *domain.User) error
}
// LoggerNotificationService prints notifications to stdout for dev/MVP.
type LoggerNotificationService struct{}
func NewLoggerNotificationService() *LoggerNotificationService {
return &LoggerNotificationService{}
}
func (s *LoggerNotificationService) NotifyOrderCreated(ctx context.Context, order *domain.Order, buyer, seller *domain.User) error {
log.Printf("📧 [EMAIL] To: Seller <%s>\n Subject: Novo Pedido #%s recebido!\n Body: Olá %s, você recebeu um novo pedido de %s. Total: R$ %.2f",
seller.Email, order.ID, seller.Name, buyer.Name, float64(order.TotalCents)/100)
log.Printf("📧 [EMAIL] To: Buyer <%s>\n Subject: Pedido #%s confirmado!\n Body: Olá %s, seu pedido foi recebido e está aguardando processamento.",
buyer.Email, order.ID, buyer.Name)
return nil
}
func (s *LoggerNotificationService) NotifyOrderStatusChanged(ctx context.Context, order *domain.Order, buyer *domain.User) error {
log.Printf("📧 [EMAIL] To: Buyer <%s>\n Subject: Atualização do Pedido #%s\n Body: Olá %s, seu pedido mudou para status: %s.",
buyer.Email, order.ID, buyer.Name, order.Status)
return nil
}