import { ContractSigningTask } from '../aggregates';
import { ContractSigningStatus } from '../value-objects';

/**
 * 合同签署任务仓储接口
 */
export interface IContractSigningTaskRepository {
  /**
   * 保存签署任务
   */
  save(task: ContractSigningTask): Promise<ContractSigningTask>;

  /**
   * 根据ID查找
   */
  findById(id: bigint): Promise<ContractSigningTask | null>;

  /**
   * 根据订单号查找
   */
  findByOrderNo(orderNo: string): Promise<ContractSigningTask | null>;

  /**
   * 获取用户所有待签署的任务
   */
  findPendingByUserId(userId: bigint): Promise<ContractSigningTask[]>;

  /**
   * 获取用户所有未完成签署的任务（包括超时的）
   */
  findUnsignedByUserId(userId: bigint): Promise<ContractSigningTask[]>;

  /**
   * 获取所有过期但未标记为超时的任务
   */
  findExpiredPendingTasks(): Promise<ContractSigningTask[]>;

  /**
   * 根据状态查找
   */
  findByStatus(status: ContractSigningStatus): Promise<ContractSigningTask[]>;

  /**
   * 检查订单是否已有签署任务
   */
  existsByOrderNo(orderNo: string): Promise<boolean>;
}

export const CONTRACT_SIGNING_TASK_REPOSITORY = Symbol('IContractSigningTaskRepository');
