61 lines
1.9 KiB
JavaScript
61 lines
1.9 KiB
JavaScript
// =====================================================
|
|
// 檢查競賽相關數據
|
|
// =====================================================
|
|
|
|
const mysql = require('mysql2/promise');
|
|
|
|
async function checkCompetitionData() {
|
|
console.log('🔍 檢查競賽相關數據...\n');
|
|
|
|
try {
|
|
// 連接數據庫
|
|
const connection = await mysql.createConnection({
|
|
host: 'mysql.theaken.com',
|
|
port: 33306,
|
|
user: 'AI_Platform',
|
|
password: 'Aa123456',
|
|
database: 'db_AI_Platform'
|
|
});
|
|
|
|
console.log('✅ 數據庫連接成功');
|
|
|
|
// 檢查競賽數據
|
|
console.log('\n📊 競賽數據:');
|
|
const [competitions] = await connection.execute('SELECT id, name, type FROM competitions LIMIT 5');
|
|
console.log(competitions);
|
|
|
|
// 檢查競賽規則
|
|
console.log('\n📊 競賽規則:');
|
|
const [rules] = await connection.execute('SELECT * FROM competition_rules LIMIT 10');
|
|
console.log(rules);
|
|
|
|
// 檢查競賽APP關聯
|
|
console.log('\n📊 競賽APP關聯:');
|
|
const [competitionApps] = await connection.execute('SELECT * FROM competition_apps LIMIT 10');
|
|
console.log(competitionApps);
|
|
|
|
// 檢查APP數據
|
|
console.log('\n📊 APP數據:');
|
|
const [apps] = await connection.execute('SELECT id, name, team_id FROM apps LIMIT 5');
|
|
console.log(apps);
|
|
|
|
// 檢查特定APP的競賽關聯
|
|
const appId = "7f7395f4-ad9f-4d14-9e2c-84962ecbcfd7";
|
|
console.log(`\n📊 APP ${appId} 的競賽關聯:`);
|
|
const [appCompetition] = await connection.execute(
|
|
'SELECT ca.*, c.name as competition_name FROM competition_apps ca LEFT JOIN competitions c ON ca.competition_id = c.id WHERE ca.app_id = ?',
|
|
[appId]
|
|
);
|
|
console.log(appCompetition);
|
|
|
|
await connection.end();
|
|
console.log('\n✅ 數據庫連接已關閉');
|
|
|
|
} catch (error) {
|
|
console.error('❌ 檢查失敗:', error.message);
|
|
}
|
|
}
|
|
|
|
// 執行檢查
|
|
checkCompetitionData();
|