first commit

This commit is contained in:
2026-04-11 11:51:54 +08:00
commit b12a84e388
99 changed files with 19620 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
import * as dotenv from 'dotenv';
dotenv.config();
import pool from './src/config/database';
async function run() {
console.log('开始清理测试数据...');
// 1. 清理 AI 结果
const [ai] = await pool.query<any>('DELETE FROM ai_result');
console.log(`删除 ai_result: ${ai.affectedRows}`);
// 2. 清理操作日志
const [logs] = await pool.query<any>('DELETE FROM operation_log');
console.log(`删除 operation_log: ${logs.affectedRows}`);
// 3. 清理考勤数据
const [att] = await pool.query<any>('DELETE FROM attendance');
console.log(`删除 attendance: ${att.affectedRows}`);
// 4. 清理绩效项明细
const [items] = await pool.query<any>('DELETE FROM perf_item');
console.log(`删除 perf_item: ${items.affectedRows}`);
// 5. 清理绩效主表
const [perf] = await pool.query<any>('DELETE FROM performance_month');
console.log(`删除 performance_month: ${perf.affectedRows}`);
// 6. 清理测试员工账号(保留管理层和总经理账号)
const [users] = await pool.query<any>("DELETE FROM user WHERE role = 'employee'");
console.log(`删除测试员工账号: ${users.affectedRows}`);
// 重置自增ID
await pool.query('ALTER TABLE ai_result AUTO_INCREMENT = 1');
await pool.query('ALTER TABLE operation_log AUTO_INCREMENT = 1');
await pool.query('ALTER TABLE attendance AUTO_INCREMENT = 1');
await pool.query('ALTER TABLE perf_item AUTO_INCREMENT = 1');
await pool.query('ALTER TABLE performance_month AUTO_INCREMENT = 1');
await pool.query('ALTER TABLE user AUTO_INCREMENT = 1');
// 查看剩余账号
const [remaining] = await pool.query<any[]>('SELECT user_id, username, name, role FROM user ORDER BY role');
console.log('\n剩余账号:');
console.table(remaining);
await pool.end();
console.log('\n清理完成');
}
run().catch(console.error);