18 lines
338 B
TypeScript
18 lines
338 B
TypeScript
import { v4 as uuidv4 } from 'uuid';
|
|
|
|
/**
|
|
* 领域事件基类
|
|
*/
|
|
export abstract class DomainEvent {
|
|
readonly eventId: string;
|
|
readonly occurredAt: Date;
|
|
abstract readonly eventType: string;
|
|
|
|
constructor() {
|
|
this.eventId = uuidv4();
|
|
this.occurredAt = new Date();
|
|
}
|
|
|
|
abstract toPayload(): Record<string, unknown>;
|
|
}
|