import { SmsVerification, SmsVerificationType } from '../entities/sms-verification.entity';

export interface ISmsVerificationRepository {
  /** 创建验证记录 */
  create(data: {
    phone: string;
    code: string;
    type: SmsVerificationType;
    expiresAt: Date;
  }): Promise<SmsVerification>;

  /** 查找指定手机号和类型的最新有效验证码 (未过期 + 未验证) */
  findLatestValid(
    phone: string,
    type: SmsVerificationType,
  ): Promise<SmsVerification | null>;

  /** 保存 (更新 attempts / verifiedAt) */
  save(verification: SmsVerification): Promise<SmsVerification>;

  /** 获取今日发送次数 */
  getDailySendCount(phone: string): Promise<number>;

  /** 清理过期记录，返回删除数量 */
  deleteExpired(): Promise<number>;
}

export const SMS_VERIFICATION_REPOSITORY = Symbol(
  'ISmsVerificationRepository',
);
