feat: 完成多多畅职就业服务平台核心功能开发
主要更新: - ✅ 完成主题配色从暗色到亮蓝白配色的全面转换 - ✅ 实现高薪岗位页面及后端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>
This commit is contained in:
125
scripts/test-training-confirmation.js
Normal file
125
scripts/test-training-confirmation.js
Normal file
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* 测试预招录确认功能是否正常
|
||||
*/
|
||||
|
||||
require('dotenv').config();
|
||||
const mysql = require('mysql2/promise');
|
||||
|
||||
async function testConfirmation() {
|
||||
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: 检查是否还有锁定的进程
|
||||
console.log('📋 测试1: 检查锁定的进程...');
|
||||
const [lockedProcesses] = await connection.query(
|
||||
"SELECT Id, State, Info FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State LIKE '%waiting for handler commit%' OR State LIKE '%Locked%'"
|
||||
);
|
||||
|
||||
if (lockedProcesses.length > 0) {
|
||||
console.log(`⚠️ 发现 ${lockedProcesses.length} 个锁定的进程:`);
|
||||
lockedProcesses.forEach(p => {
|
||||
console.log(` - 进程 ${p.Id}: ${p.State}`);
|
||||
});
|
||||
} else {
|
||||
console.log('✅ 没有发现锁定的进程\n');
|
||||
}
|
||||
|
||||
// 测试2: 查看当前所有进程状态
|
||||
console.log('📋 测试2: 当前活动进程...');
|
||||
const [allProcesses] = await connection.query('SHOW FULL PROCESSLIST');
|
||||
console.log(`当前活动进程数: ${allProcesses.length}`);
|
||||
|
||||
const sleepCount = allProcesses.filter(p => p.Command === 'Sleep').length;
|
||||
const queryCount = allProcesses.filter(p => p.Command === 'Query').length;
|
||||
console.log(` - Sleep状态: ${sleepCount}`);
|
||||
console.log(` - Query状态: ${queryCount}\n`);
|
||||
|
||||
// 测试3: 检查training_confirmations表是否可以正常查询
|
||||
console.log('📋 测试3: 查询training_confirmations表...');
|
||||
const [confirmations] = await connection.query(
|
||||
'SELECT COUNT(*) as count FROM training_confirmations'
|
||||
);
|
||||
console.log(`✅ 当前共有 ${confirmations[0].count} 条确认记录\n`);
|
||||
|
||||
// 测试4: 测试是否可以执行INSERT操作(使用一个不存在的user_id和training_unit_id)
|
||||
console.log('📋 测试4: 测试INSERT操作...');
|
||||
const testUserId = 99999;
|
||||
const testTrainingUnitId = 99999;
|
||||
|
||||
try {
|
||||
// 先检查是否存在
|
||||
const [existing] = await connection.query(
|
||||
'SELECT id FROM training_confirmations WHERE user_id = ? AND training_unit_id = ?',
|
||||
[testUserId, testTrainingUnitId]
|
||||
);
|
||||
|
||||
if (existing.length === 0) {
|
||||
// 尝试插入
|
||||
await connection.query(
|
||||
'INSERT INTO training_confirmations (user_id, training_unit_id) VALUES (?, ?)',
|
||||
[testUserId, testTrainingUnitId]
|
||||
);
|
||||
console.log('✅ INSERT操作成功');
|
||||
|
||||
// 清理测试数据
|
||||
await connection.query(
|
||||
'DELETE FROM training_confirmations WHERE user_id = ? AND training_unit_id = ?',
|
||||
[testUserId, testTrainingUnitId]
|
||||
);
|
||||
console.log('✅ 已清理测试数据\n');
|
||||
} else {
|
||||
console.log('⚠️ 测试记录已存在,跳过INSERT测试\n');
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('❌ INSERT操作失败:', err.message);
|
||||
if (err.code === 'ER_LOCK_WAIT_TIMEOUT') {
|
||||
console.error('⚠️ 数据库仍然存在锁定问题!\n');
|
||||
}
|
||||
}
|
||||
|
||||
// 测试5: 检查是否有重复记录
|
||||
console.log('📋 测试5: 检查重复记录...');
|
||||
const [duplicates] = await connection.query(`
|
||||
SELECT user_id, training_unit_id, COUNT(*) as count
|
||||
FROM training_confirmations
|
||||
GROUP BY user_id, training_unit_id
|
||||
HAVING count > 1
|
||||
`);
|
||||
|
||||
if (duplicates.length > 0) {
|
||||
console.log(`⚠️ 发现 ${duplicates.length} 组重复记录:`);
|
||||
duplicates.forEach(dup => {
|
||||
console.log(` - user_id: ${dup.user_id}, training_unit_id: ${dup.training_unit_id}, 数量: ${dup.count}`);
|
||||
});
|
||||
} else {
|
||||
console.log('✅ 没有发现重复记录\n');
|
||||
}
|
||||
|
||||
console.log('========================================');
|
||||
console.log('✅ 所有测试完成!');
|
||||
console.log('========================================\n');
|
||||
console.log('💡 现在可以在浏览器中测试预招录确认按钮了');
|
||||
console.log('📍 访问: http://localhost:8080/high.html');
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ 测试失败:', error.message);
|
||||
console.error('错误详情:', error);
|
||||
process.exit(1);
|
||||
} finally {
|
||||
if (connection) {
|
||||
await connection.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
testConfirmation();
|
||||
Reference in New Issue
Block a user