const axios = require('axios'); const API_BASE_URL = 'http://localhost:5352/api/government'; const api = axios.create({ baseURL: API_BASE_URL, timeout: 10000, headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer test-token' } }); async function testDataCenterAPI() { console.log('开始测试数据中心API...\n'); try { // 测试获取数据中心统计数据 console.log('1. 测试获取数据中心统计数据...'); const response = await api.get('/data-center'); console.log('数据中心统计:', JSON.stringify(response.data, null, 2)); console.log('✅ 获取数据中心统计数据成功\n'); // 测试获取市场价格信息 console.log('2. 测试获取市场价格信息...'); const priceResponse = await api.get('/market-price?type=beef'); console.log('市场价格信息:', JSON.stringify(priceResponse.data, null, 2)); console.log('✅ 获取市场价格信息成功\n'); // 测试获取部门列表 console.log('3. 测试获取部门列表...'); const deptResponse = await api.get('/departments'); console.log('部门列表:', JSON.stringify(deptResponse.data, null, 2)); console.log('✅ 获取部门列表成功\n'); // 测试获取行政人员列表 console.log('4. 测试获取行政人员列表...'); const staffResponse = await api.get('/admin-staff'); console.log('行政人员列表:', JSON.stringify(staffResponse.data, null, 2)); console.log('✅ 获取行政人员列表成功\n'); console.log('🎉 所有数据中心API测试通过!'); } catch (error) { console.error('❌ API测试失败:', error.response ? error.response.data : error.message); } } testDataCenterAPI();