You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.6 KiB
71 lines
2.6 KiB
// 测试学员端订单接口
|
|
const axios = require('axios');
|
|
|
|
const BASE_URL = 'http://localhost:20080/api';
|
|
|
|
async function testStudentOrdersAPI() {
|
|
console.log('🧪 开始测试学员端订单接口...\n');
|
|
|
|
try {
|
|
// 测试订单列表接口
|
|
console.log('📋 测试订单列表接口...');
|
|
const listResponse = await axios.get(`${BASE_URL}/xy/student/orders`, {
|
|
params: {
|
|
student_id: 31,
|
|
page: 1,
|
|
limit: 10
|
|
}
|
|
});
|
|
|
|
console.log('✅ 订单列表接口响应:');
|
|
console.log('状态码:', listResponse.status);
|
|
console.log('响应数据:', JSON.stringify(listResponse.data, null, 2));
|
|
console.log('');
|
|
|
|
// 测试订单统计接口
|
|
console.log('📊 测试订单统计接口...');
|
|
const statsResponse = await axios.get(`${BASE_URL}/xy/student/orders/stats`, {
|
|
params: {
|
|
student_id: 31
|
|
}
|
|
});
|
|
|
|
console.log('✅ 订单统计接口响应:');
|
|
console.log('状态码:', statsResponse.status);
|
|
console.log('响应数据:', JSON.stringify(statsResponse.data, null, 2));
|
|
console.log('');
|
|
|
|
// 如果有订单数据,测试订单详情接口
|
|
if (listResponse.data.code === 1 && listResponse.data.data && listResponse.data.data.data && listResponse.data.data.data.length > 0) {
|
|
const firstOrder = listResponse.data.data.data[0];
|
|
console.log('📄 测试订单详情接口...');
|
|
|
|
const detailResponse = await axios.get(`${BASE_URL}/xy/student/orders/detail`, {
|
|
params: {
|
|
id: firstOrder.id,
|
|
student_id: 31
|
|
}
|
|
});
|
|
|
|
console.log('✅ 订单详情接口响应:');
|
|
console.log('状态码:', detailResponse.status);
|
|
console.log('响应数据:', JSON.stringify(detailResponse.data, null, 2));
|
|
} else {
|
|
console.log('ℹ️ 没有订单数据,跳过详情接口测试');
|
|
}
|
|
|
|
console.log('\n🎉 所有接口测试完成!');
|
|
|
|
} catch (error) {
|
|
console.error('❌ 接口测试失败:');
|
|
if (error.response) {
|
|
console.error('状态码:', error.response.status);
|
|
console.error('响应数据:', JSON.stringify(error.response.data, null, 2));
|
|
} else {
|
|
console.error('错误信息:', error.message);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 运行测试
|
|
testStudentOrdersAPI();
|
|
|