fix: 修改数据库users表名为user
This commit is contained in:
parent
3f79917ed9
commit
2f47cf4b55
@ -23,7 +23,7 @@ async function register(req, res) {
|
||||
try {
|
||||
// 检查用户名是否已存在
|
||||
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]
|
||||
);
|
||||
if (existingUser.length > 0) {
|
||||
@ -35,7 +35,7 @@ async function register(req, res) {
|
||||
const salt = generateSalt();
|
||||
const hash = hashPassword(password, salt);
|
||||
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]
|
||||
);
|
||||
|
||||
@ -66,7 +66,7 @@ async function login(req, res) {
|
||||
try {
|
||||
// 查询用户(仅支持用户名登录)
|
||||
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]
|
||||
);
|
||||
if (users.length === 0) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user