fix(audit): use uuid.New() for ticket workflow audit IDs

Fixes 'invalid input syntax for type uuid' error when writing ticket
workflow audit logs. The audit Event.ID field was using fmt.Sprintf
with nanoseconds ('wf-%d') which doesn't match PostgreSQL's uuid type.

Also adds uuid import to ticket_workflow.go.

Verified: full chain webhook→assign→resolve→close produces 3 audit
logs correctly, no more 'invalid uuid' errors in logs.
This commit is contained in:
Your Name
2026-05-04 13:44:39 +08:00
parent c7cb174c58
commit 087de4e102
23 changed files with 1459 additions and 195 deletions

View File

@@ -9,6 +9,7 @@ import (
"time"
"github.com/bridge/ai-customer-service/internal/domain/audit"
"github.com/google/uuid"
"github.com/bridge/ai-customer-service/internal/domain/ticket"
)
@@ -36,7 +37,7 @@ func (s *TicketWorkflowStore) writeAudit(ctx context.Context, ticketID, action,
}
now := time.Now()
event := audit.Event{
ID: fmt.Sprintf("wf-%d", now.UnixNano()),
ID: uuid.New().String(),
Type: "ticket_state_changed",
Action: action,
TicketID: ticketID,