feat:"完成页面接口的对接"
This commit is contained in:
36
后端/update-admin-role.js
Normal file
36
后端/update-admin-role.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const mysql = require('mysql2/promise');
|
||||
|
||||
async function updateAdminRole() {
|
||||
const connection = await mysql.createConnection({
|
||||
host: '8.130.78.179',
|
||||
port: 9986,
|
||||
user: 'sffx',
|
||||
password: 'wF5WKm35Ddm5NDTn',
|
||||
database: 'sffx'
|
||||
});
|
||||
|
||||
try {
|
||||
// 更新 admin 用户角色
|
||||
const [result] = await connection.execute(
|
||||
'UPDATE users SET role = ? WHERE username = ?',
|
||||
['admin', 'admin']
|
||||
);
|
||||
|
||||
console.log('✅ 更新成功!受影响的行数:', result.affectedRows);
|
||||
|
||||
// 查询验证
|
||||
const [rows] = await connection.execute(
|
||||
'SELECT id, username, email, realName, role, status FROM users WHERE username = ?',
|
||||
['admin']
|
||||
);
|
||||
|
||||
console.log('\n当前 admin 用户信息:');
|
||||
console.table(rows);
|
||||
} catch (error) {
|
||||
console.error('❌ 更新失败:', error.message);
|
||||
} finally {
|
||||
await connection.end();
|
||||
}
|
||||
}
|
||||
|
||||
updateAdminRole();
|
||||
Reference in New Issue
Block a user