import { DomainError } from '@/shared/exceptions/domain.exception';

export class UserId {
  private readonly _value: bigint;

  private constructor(value: bigint) {
    this._value = value;
  }

  static create(value: bigint | number | string): UserId {
    const bigintValue = typeof value === 'bigint' ? value : BigInt(value);
    // 允许负数 userId，用于系统账户：
    // -1: 总部社区 (S0000000001)
    // -2: 成本费账户 (S0000000002)
    // -3: 运营费账户 (S0000000003)
    // -4: RWA底池 (S0000000004)
    // -5: 分享权益池 (S0000000005)
    // -6: 手续费归集账户 (S0000000006)
    return new UserId(bigintValue);
  }

  get value(): bigint {
    return this._value;
  }

  equals(other: UserId): boolean {
    return this._value === other._value;
  }

  toString(): string {
    return this._value.toString();
  }
}
