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:
270
api/controllers/transitionProgressController.js
Normal file
270
api/controllers/transitionProgressController.js
Normal file
@@ -0,0 +1,270 @@
|
||||
/**
|
||||
* 面试进度控制器
|
||||
* 基于high.html的最新数据结构
|
||||
*/
|
||||
|
||||
const db = require('../../config/database');
|
||||
|
||||
/**
|
||||
* 获取我的面试进度列表
|
||||
* GET /api/transition-progress
|
||||
* 需要登录
|
||||
*/
|
||||
exports.getMyProgress = async (req, res) => {
|
||||
try {
|
||||
const userId = req.user.id;
|
||||
|
||||
const [records] = await db.query(
|
||||
`SELECT
|
||||
id,
|
||||
company,
|
||||
job,
|
||||
status,
|
||||
status_type,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM transition_progress
|
||||
WHERE user_id = ?
|
||||
ORDER BY created_at DESC`,
|
||||
[userId]
|
||||
);
|
||||
|
||||
return res.json({
|
||||
success: true,
|
||||
data: records
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('获取面试进度失败:', error);
|
||||
return res.status(500).json({
|
||||
success: false,
|
||||
message: '获取面试进度失败',
|
||||
error: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 创建面试进度记录
|
||||
* POST /api/transition-progress
|
||||
* 需要登录
|
||||
*/
|
||||
exports.create = async (req, res) => {
|
||||
try {
|
||||
const userId = req.user.id;
|
||||
const {
|
||||
company,
|
||||
job,
|
||||
status,
|
||||
status_type
|
||||
} = req.body;
|
||||
|
||||
// 验证必填字段
|
||||
if (!company || !job || !status) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
message: '缺少必填字段 (company, job, status)'
|
||||
});
|
||||
}
|
||||
|
||||
// 验证status_type
|
||||
if (status_type && !['offer', 'hr', 'ing', 'pending'].includes(status_type)) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
message: 'status_type 必须是 offer, hr, ing 或 pending'
|
||||
});
|
||||
}
|
||||
|
||||
const [result] = await db.query(
|
||||
`INSERT INTO transition_progress
|
||||
(user_id, company, job, status, status_type)
|
||||
VALUES (?, ?, ?, ?, ?)`,
|
||||
[
|
||||
userId,
|
||||
company,
|
||||
job,
|
||||
status,
|
||||
status_type || 'pending'
|
||||
]
|
||||
);
|
||||
|
||||
return res.status(201).json({
|
||||
success: true,
|
||||
message: '面试进度记录创建成功',
|
||||
data: { id: result.insertId }
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('创建面试进度失败:', error);
|
||||
return res.status(500).json({
|
||||
success: false,
|
||||
message: '创建面试进度失败',
|
||||
error: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新面试进度
|
||||
* PUT /api/transition-progress/:id
|
||||
* 需要登录
|
||||
*/
|
||||
exports.update = async (req, res) => {
|
||||
try {
|
||||
const { id } = req.params;
|
||||
const userId = req.user.id;
|
||||
const updateData = req.body;
|
||||
|
||||
// 检查记录是否存在且属于当前用户
|
||||
const [existing] = await db.query(
|
||||
'SELECT id FROM transition_progress WHERE id = ? AND user_id = ?',
|
||||
[id, userId]
|
||||
);
|
||||
|
||||
if (existing.length === 0) {
|
||||
return res.status(404).json({
|
||||
success: false,
|
||||
message: '面试进度记录不存在或无权访问'
|
||||
});
|
||||
}
|
||||
|
||||
const updates = [];
|
||||
const params = [];
|
||||
|
||||
const allowedFields = ['company', 'job', 'status', 'status_type'];
|
||||
|
||||
for (const field of allowedFields) {
|
||||
if (updateData[field] !== undefined) {
|
||||
// 验证status_type
|
||||
if (field === 'status_type' && !['offer', 'hr', 'ing', 'pending'].includes(updateData[field])) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
message: 'status_type 必须是 offer, hr, ing 或 pending'
|
||||
});
|
||||
}
|
||||
updates.push(`${field} = ?`);
|
||||
params.push(updateData[field]);
|
||||
}
|
||||
}
|
||||
|
||||
if (updates.length === 0) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
message: '没有要更新的字段'
|
||||
});
|
||||
}
|
||||
|
||||
params.push(id);
|
||||
await db.query(
|
||||
`UPDATE transition_progress SET ${updates.join(', ')} WHERE id = ?`,
|
||||
params
|
||||
);
|
||||
|
||||
return res.json({
|
||||
success: true,
|
||||
message: '面试进度更新成功'
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('更新面试进度失败:', error);
|
||||
return res.status(500).json({
|
||||
success: false,
|
||||
message: '更新面试进度失败',
|
||||
error: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除面试进度记录
|
||||
* DELETE /api/transition-progress/:id
|
||||
* 需要登录
|
||||
*/
|
||||
exports.delete = async (req, res) => {
|
||||
try {
|
||||
const { id } = req.params;
|
||||
const userId = req.user.id;
|
||||
|
||||
const [result] = await db.query(
|
||||
'DELETE FROM transition_progress WHERE id = ? AND user_id = ?',
|
||||
[id, userId]
|
||||
);
|
||||
|
||||
if (result.affectedRows === 0) {
|
||||
return res.status(404).json({
|
||||
success: false,
|
||||
message: '面试进度记录不存在或无权访问'
|
||||
});
|
||||
}
|
||||
|
||||
return res.json({
|
||||
success: true,
|
||||
message: '面试进度删除成功'
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('删除面试进度失败:', error);
|
||||
return res.status(500).json({
|
||||
success: false,
|
||||
message: '删除面试进度失败',
|
||||
error: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取所有面试进度记录 (管理员)
|
||||
* GET /api/transition-progress/all
|
||||
* 需要管理员权限
|
||||
*/
|
||||
exports.getAll = async (req, res) => {
|
||||
try {
|
||||
const page = parseInt(req.query.page) || 1;
|
||||
const limit = parseInt(req.query.limit) || 20;
|
||||
const offset = (page - 1) * limit;
|
||||
const statusType = req.query.status_type;
|
||||
|
||||
// 构建查询条件
|
||||
let whereClause = '';
|
||||
const params = [];
|
||||
|
||||
if (statusType && ['offer', 'hr', 'ing', 'pending'].includes(statusType)) {
|
||||
whereClause = 'WHERE status_type = ?';
|
||||
params.push(statusType);
|
||||
}
|
||||
|
||||
// 查询总数
|
||||
const [countResult] = await db.query(
|
||||
`SELECT COUNT(*) as total FROM transition_progress ${whereClause}`,
|
||||
params
|
||||
);
|
||||
const total = countResult[0].total;
|
||||
|
||||
// 查询记录列表
|
||||
const [records] = await db.query(
|
||||
`SELECT
|
||||
tp.*,
|
||||
u.username
|
||||
FROM transition_progress tp
|
||||
LEFT JOIN users u ON tp.user_id = u.id
|
||||
${whereClause}
|
||||
ORDER BY tp.created_at DESC
|
||||
LIMIT ? OFFSET ?`,
|
||||
[...params, limit, offset]
|
||||
);
|
||||
|
||||
return res.json({
|
||||
success: true,
|
||||
data: {
|
||||
records,
|
||||
total,
|
||||
page,
|
||||
limit,
|
||||
totalPages: Math.ceil(total / limit)
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('获取所有面试进度失败:', error);
|
||||
return res.status(500).json({
|
||||
success: false,
|
||||
message: '获取所有面试进度失败',
|
||||
error: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user