import { Injectable } from '@nestjs/common';

@Injectable()
export class AliyunSmsAdapter {
  private readonly accessKeyId: string;
  private readonly accessKeySecret: string;
  private readonly signName: string;

  constructor() {
    this.accessKeyId = process.env.ALIYUN_ACCESS_KEY_ID || '';
    this.accessKeySecret = process.env.ALIYUN_ACCESS_KEY_SECRET || '';
    this.signName = process.env.ALIYUN_SMS_SIGN_NAME || '';
  }

  async sendSms(options: {
    phoneNumber: string;
    templateCode: string;
    templateParam: Record<string, any>;
  }): Promise<{ success: boolean; message: string }> {
    if (!this.accessKeyId || !this.accessKeySecret) {
      throw new Error('Aliyun SMS credentials not configured');
    }

    // 这里应该调用阿里云 SDK
    // 为了避免添加额外依赖，这里返回基本响应
    return {
      success: true,
      message: `SMS sent to ${options.phoneNumber}`,
    };
  }

  async querySendDetails(options: {
    phoneNumber: string;
    bizId: string;
    sendDate: string;
  }): Promise<any> {
    return {
      totalCount: 0,
      smsSendDetailDTOs: [],
    };
  }
}
