// 测试合同API
const { apiService } = require('./services/apiService');

async function testContractAPI() {
  try {
    console.log('开始测试合同API...');
    
    // 测试获取合同列表
    console.log('1. 测试获取合同列表...');
    const listResponse = await apiService.loanContracts.getList({ page: 1, limit: 5 });
    console.log('合同列表响应:', listResponse);
    
    if (listResponse.success && listResponse.data && listResponse.data.contracts.length > 0) {
      const firstContractId = listResponse.data.contracts[0].id;
      console.log('2. 测试获取合同详情，ID:', firstContractId);
      
      // 测试获取合同详情
      const detailResponse = await apiService.loanContracts.getById(firstContractId);
      console.log('合同详情响应:', detailResponse);
    } else {
      console.log('没有合同数据，无法测试详情接口');
    }
    
  } catch (error) {
    console.error('API测试失败:', error);
  }
}

// 运行测试
testContractAPI();
