Files
performance-evaluation-system/backend/update-accounts.ts

34 lines
1000 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import * as dotenv from 'dotenv';
dotenv.config();
import pool from './src/config/database';
async function run() {
const password = '123456';
// 删除 mgr002
await pool.query('DELETE FROM user WHERE username = ?', ['mgr002']);
console.log('删除 mgr002');
// 更新 gm001 → lister / 李总 / 总经理
await pool.query(
'UPDATE user SET username = ?, name = ?, password = ? WHERE username = ?',
['lister', '李总', password, 'gm001']
);
console.log('更新 gm001 → lister');
// 更新 mgr001 → xinxin / 孙薪薪 / 管理层
await pool.query(
'UPDATE user SET username = ?, name = ?, password = ? WHERE username = ?',
['xinxin', '孙薪薪', password, 'mgr001']
);
console.log('更新 mgr001 → xinxin');
const [rows] = await pool.query<any[]>('SELECT user_id, username, name, role, department, position FROM user ORDER BY role');
console.log('\n当前账号');
console.table(rows);
await pool.end();
}
run().catch(console.error);