import { FundAllocationTargetType } from './fund-allocation-target-type.enum'; export interface FundAllocationDTO { targetType: FundAllocationTargetType; amount: number; targetAccountId: string | null; metadata?: Record; } export class FundAllocation { constructor( public readonly targetType: FundAllocationTargetType, public readonly amount: number, public readonly targetAccountId: string | null, public readonly metadata?: Record, ) { if (amount < 0) { throw new Error('分配金额不能为负数'); } } toDTO(): FundAllocationDTO { return { targetType: this.targetType, amount: this.amount, targetAccountId: this.targetAccountId, metadata: this.metadata, }; } equals(other: FundAllocation): boolean { return ( this.targetType === other.targetType && this.amount === other.amount && this.targetAccountId === other.targetAccountId ); } }