fix: 修改数据库users表名为user

This commit is contained in:
luozhj33 2026-03-19 14:18:43 +08:00
parent 3f79917ed9
commit 2f47cf4b55

View File

@ -23,7 +23,7 @@ async function register(req, res) {
try { try {
// 检查用户名是否已存在 // 检查用户名是否已存在
const existingUser = await mysql.query( const existingUser = await mysql.query(
'SELECT id FROM users WHERE username = ? AND is_deleted = 0', 'SELECT id FROM user WHERE username = ? AND is_deleted = 0',
[username] [username]
); );
if (existingUser.length > 0) { if (existingUser.length > 0) {
@ -35,7 +35,7 @@ async function register(req, res) {
const salt = generateSalt(); const salt = generateSalt();
const hash = hashPassword(password, salt); const hash = hashPassword(password, salt);
await mysql.query( await mysql.query(
'INSERT INTO users (user_id, username, password, salt, email, phone) VALUES (?, ?, ?, ?, ?, ?)', 'INSERT INTO user (user_id, username, password, salt, email, phone) VALUES (?, ?, ?, ?, ?, ?)',
[user_id, username, hash, salt, email || null, phone || null] [user_id, username, hash, salt, email || null, phone || null]
); );
@ -66,7 +66,7 @@ async function login(req, res) {
try { try {
// 查询用户(仅支持用户名登录) // 查询用户(仅支持用户名登录)
const users = await mysql.query( const users = await mysql.query(
'SELECT user_id, username, password, salt FROM users WHERE username = ? AND is_deleted = 0', 'SELECT user_id, username, password, salt FROM user WHERE username = ? AND is_deleted = 0',
[username] [username]
); );
if (users.length === 0) { if (users.length === 0) {