70 lines
2.1 KiB
JavaScript
70 lines
2.1 KiB
JavaScript
// =====================================================
|
|
// 檢查競賽詳細數據
|
|
// =====================================================
|
|
|
|
const mysql = require('mysql2/promise');
|
|
|
|
async function checkCompetitionDataDetails() {
|
|
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('✅ 數據庫連接成功');
|
|
|
|
const competitionId = "be4b0a71-91f1-11f0-bb38-4adff2d0e33e";
|
|
|
|
// 檢查競賽評審關聯
|
|
console.log('\n📊 競賽評審關聯:');
|
|
const [competitionJudges] = await connection.execute(`
|
|
SELECT cj.*, j.name as judge_name
|
|
FROM competition_judges cj
|
|
LEFT JOIN judges j ON cj.judge_id = j.id
|
|
WHERE cj.competition_id = ?
|
|
`, [competitionId]);
|
|
console.log(competitionJudges);
|
|
|
|
// 檢查競賽APP關聯
|
|
console.log('\n📊 競賽APP關聯:');
|
|
const [competitionApps] = await connection.execute(`
|
|
SELECT ca.*, a.name as app_name
|
|
FROM competition_apps ca
|
|
LEFT JOIN apps a ON ca.app_id = a.id
|
|
WHERE ca.competition_id = ?
|
|
`, [competitionId]);
|
|
console.log(competitionApps);
|
|
|
|
// 檢查評分記錄
|
|
console.log('\n📊 評分記錄:');
|
|
const [judgeScores] = await connection.execute(`
|
|
SELECT js.*, j.name as judge_name, a.name as app_name
|
|
FROM judge_scores js
|
|
LEFT JOIN judges j ON js.judge_id = j.id
|
|
LEFT JOIN apps a ON js.app_id = a.id
|
|
WHERE js.competition_id = ?
|
|
`, [competitionId]);
|
|
console.log(judgeScores);
|
|
|
|
// 檢查所有競賽
|
|
console.log('\n📊 所有競賽:');
|
|
const [competitions] = await connection.execute('SELECT id, name FROM competitions');
|
|
console.log(competitions);
|
|
|
|
await connection.end();
|
|
console.log('\n✅ 數據庫連接已關閉');
|
|
|
|
} catch (error) {
|
|
console.error('❌ 檢查失敗:', error.message);
|
|
}
|
|
}
|
|
|
|
// 執行檢查
|
|
checkCompetitionDataDetails();
|