import { ContributionAccountAggregate } from '../aggregates/contribution-account.aggregate';

/**
 * 贡献值账户仓库接口
 */
export interface IContributionAccountRepository {
  /**
   * 根据账户序列号查找
   */
  findByAccountSequence(accountSequence: string): Promise<ContributionAccountAggregate | null>;

  /**
   * 根据账户序列号查找（带锁）
   */
  findByAccountSequenceForUpdate(
    accountSequence: string,
    tx?: any,
  ): Promise<ContributionAccountAggregate | null>;

  /**
   * 保存（创建或更新）
   */
  save(account: ContributionAccountAggregate, tx?: any): Promise<ContributionAccountAggregate>;

  /**
   * 批量保存
   */
  saveMany(accounts: ContributionAccountAggregate[], tx?: any): Promise<void>;

  /**
   * 获取所有有效贡献值大于0的账户
   */
  findAllWithEffectiveContribution(): Promise<ContributionAccountAggregate[]>;

  /**
   * 获取全网有效贡献值总和
   */
  getNetworkTotalEffectiveContribution(): Promise<string>;

  /**
   * 分页查询
   */
  findMany(options: {
    page?: number;
    limit?: number;
    orderBy?: 'effectiveContribution' | 'personalContribution';
    order?: 'asc' | 'desc';
  }): Promise<{
    items: ContributionAccountAggregate[];
    total: number;
  }>;
}

export const CONTRIBUTION_ACCOUNT_REPOSITORY = Symbol('IContributionAccountRepository');
