主要更新: - ✅ 完成主题配色从暗色到亮蓝白配色的全面转换 - ✅ 实现高薪岗位页面及后端API集成 - ✅ 完成登录注册页面及认证系统 - ✅ 实现预招录确认功能 - ✅ 添加数据库管理和维护工具脚本 - ✅ 优化错误处理和用户体验 核心功能: 1. 首页 (index.html) - 3D地球、专业分类、过渡岗位 2. 高薪岗位页面 (high.html) - 岗位详情、预招录确认、成功案例 3. 登录注册 (auth.html) - 用户认证、专业分类选择 4. 后端API - RESTful接口,JWT认证,MySQL数据库 技术栈: - 前端:Three.js, GSAP, 原生JavaScript - 后端:Node.js, Express, MySQL - 认证:JWT, bcrypt - 样式:自定义CSS,响应式设计 数据库工具: - kill-by-ids.js - 批量终止MySQL进程 - unlock-all-tables.js - 解锁数据库表 - init-db.js - 初始化数据库 - 其他管理脚本 🤖 Generated with Claude Code Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
117 lines
4.2 KiB
JavaScript
117 lines
4.2 KiB
JavaScript
/**
|
||
* 简单测试预招录确认功能
|
||
* 避免使用复杂查询导致临时表问题
|
||
*/
|
||
|
||
require('dotenv').config();
|
||
const mysql = require('mysql2/promise');
|
||
|
||
async function simpleTest() {
|
||
let connection;
|
||
|
||
try {
|
||
connection = await mysql.createConnection({
|
||
host: process.env.DB_HOST,
|
||
port: process.env.DB_PORT || 3306,
|
||
user: process.env.DB_USER,
|
||
password: process.env.DB_PASSWORD,
|
||
database: process.env.DB_DATABASE
|
||
});
|
||
|
||
console.log('✅ 已连接到数据库\n');
|
||
|
||
// 简单测试1: 查询training_confirmations表
|
||
console.log('📋 测试1: 查询确认记录...');
|
||
const [confirmations] = await connection.query(
|
||
'SELECT id, user_id, training_unit_id FROM training_confirmations LIMIT 5'
|
||
);
|
||
console.log(`✅ 成功查询到 ${confirmations.length} 条记录\n`);
|
||
|
||
// 简单测试2: 尝试INSERT操作
|
||
console.log('📋 测试2: 测试INSERT操作...');
|
||
const testUserId = 99999;
|
||
const testTrainingUnitId = 99999;
|
||
|
||
try {
|
||
// 先清理可能存在的测试数据
|
||
await connection.query(
|
||
'DELETE FROM training_confirmations WHERE user_id = ? AND training_unit_id = ?',
|
||
[testUserId, testTrainingUnitId]
|
||
);
|
||
|
||
// 尝试插入
|
||
const startTime = Date.now();
|
||
await connection.query(
|
||
'INSERT INTO training_confirmations (user_id, training_unit_id) VALUES (?, ?)',
|
||
[testUserId, testTrainingUnitId]
|
||
);
|
||
const endTime = Date.now();
|
||
|
||
console.log(`✅ INSERT操作成功 (耗时: ${endTime - startTime}ms)`);
|
||
|
||
// 验证插入
|
||
const [inserted] = await connection.query(
|
||
'SELECT id FROM training_confirmations WHERE user_id = ? AND training_unit_id = ?',
|
||
[testUserId, testTrainingUnitId]
|
||
);
|
||
|
||
if (inserted.length > 0) {
|
||
console.log(`✅ 成功插入记录,ID: ${inserted[0].id}`);
|
||
}
|
||
|
||
// 清理测试数据
|
||
await connection.query(
|
||
'DELETE FROM training_confirmations WHERE user_id = ? AND training_unit_id = ?',
|
||
[testUserId, testTrainingUnitId]
|
||
);
|
||
console.log('✅ 已清理测试数据\n');
|
||
|
||
} catch (err) {
|
||
console.error('❌ INSERT操作失败:', err.message);
|
||
console.error('错误代码:', err.code);
|
||
|
||
if (err.code === 'ER_LOCK_WAIT_TIMEOUT') {
|
||
console.error('\n⚠️ 数据库仍然存在锁定问题!');
|
||
console.error('建议:');
|
||
console.error('1. 联系数据库管理员检查锁定的事务');
|
||
console.error('2. 或等待锁定的事务超时释放\n');
|
||
process.exit(1);
|
||
}
|
||
}
|
||
|
||
// 简单测试3: 测试UPDATE操作
|
||
console.log('📋 测试3: 测试UPDATE操作...');
|
||
try {
|
||
const startTime = Date.now();
|
||
await connection.query(
|
||
'UPDATE training_confirmations SET user_id = user_id WHERE id = 1'
|
||
);
|
||
const endTime = Date.now();
|
||
console.log(`✅ UPDATE操作成功 (耗时: ${endTime - startTime}ms)\n`);
|
||
} catch (err) {
|
||
console.error('❌ UPDATE操作失败:', err.message);
|
||
if (err.code === 'ER_LOCK_WAIT_TIMEOUT') {
|
||
console.error('⚠️ 数据库存在锁定问题\n');
|
||
}
|
||
}
|
||
|
||
console.log('========================================');
|
||
console.log('✅ 基本功能测试完成!');
|
||
console.log('========================================\n');
|
||
console.log('💡 数据库连接和基本操作正常');
|
||
console.log('📍 现在可以在浏览器中测试预招录确认按钮');
|
||
console.log('🌐 访问: http://localhost:8080/high.html\n');
|
||
|
||
} catch (error) {
|
||
console.error('❌ 测试失败:', error.message);
|
||
console.error('错误代码:', error.code);
|
||
process.exit(1);
|
||
} finally {
|
||
if (connection) {
|
||
await connection.end();
|
||
}
|
||
}
|
||
}
|
||
|
||
simpleTest();
|