后端版本服务器部署成功

This commit is contained in:
2025-09-11 13:11:04 +08:00
parent a1cd342c99
commit 9b7a0482e1
24 changed files with 1039 additions and 1157 deletions

View File

@@ -89,7 +89,7 @@ class UserMySQL {
// 更新密码
static async updatePassword(id, newPassword) {
const sql = 'UPDATE users SET password = ?, updated_at = NOW() WHERE id = ?';
const sql = 'UPDATE users SET password_hash = ?, updated_at = NOW() WHERE id = ?';
const result = await query(sql, [newPassword, id]);
return result.affectedRows > 0;
}
@@ -154,25 +154,11 @@ class UserMySQL {
return rows[0].count > 0;
}
// 检查用户名是否已存在
static async isUsernameExists(username, excludeId = null) {
let sql = 'SELECT COUNT(*) as count FROM users WHERE username = ?';
const params = [username];
if (excludeId) {
sql += ' AND id != ?';
params.push(excludeId);
}
const rows = await query(sql, params);
return rows[0].count > 0;
}
// 安全返回用户信息(去除敏感信息)
static sanitize(user) {
if (!user) return null;
const { password, ...safeUser } = user;
const { password_hash, ...safeUser } = user;
return safeUser;
}
}