package hooks import "context" // EventType 业务事件类型,按项目需求在此扩展 type EventType string // Handler 事件处理器接口 type Handler interface { Handle(ctx context.Context, event EventType, payload *EventPayload) error } // HandlerFunc 函数适配器,方便用匿名函数注册 handler type HandlerFunc func(ctx context.Context, event EventType, payload *EventPayload) error func (f HandlerFunc) Handle(ctx context.Context, event EventType, payload *EventPayload) error { return f(ctx, event, payload) } // EventPayload 事件携带的上下文信息 type EventPayload struct { UserID int Extra map[string]any }