feat: 实现教师资料更新、操作日志和系统设置功能
新增教师资料更新功能,包括个人信息修改和密码更新 添加操作日志记录系统,记录用户关键操作 实现系统设置模块,支持动态配置系统参数 重构数据库模型,新增教师表和系统设置表 优化成绩录入逻辑,支持平时分、期中和期末成绩计算 添加数据导出功能,支持学生、教师和成绩数据导出 完善管理员后台,增加统计图表和操作日志查看
This commit is contained in:
48
backend/scripts/migrate_v2.js
Normal file
48
backend/scripts/migrate_v2.js
Normal file
@@ -0,0 +1,48 @@
|
||||
const db = require('../config/database');
|
||||
|
||||
async function migrate() {
|
||||
try {
|
||||
console.log('Starting migration v2...');
|
||||
|
||||
// 1. System Settings Table
|
||||
await db.query(`
|
||||
CREATE TABLE IF NOT EXISTS system_settings (
|
||||
key TEXT PRIMARY KEY,
|
||||
value TEXT
|
||||
)
|
||||
`);
|
||||
|
||||
// Default settings
|
||||
const defaultSettings = [
|
||||
['system_name', '学校成绩管理系统'],
|
||||
['current_semester', '2023-2024-2'],
|
||||
['allow_course_selection', '1'],
|
||||
['allow_grade_check', '1']
|
||||
];
|
||||
|
||||
for (const [key, value] of defaultSettings) {
|
||||
await db.query('INSERT OR IGNORE INTO system_settings (key, value) VALUES (?, ?)', [key, value]);
|
||||
}
|
||||
|
||||
// 2. Operation Logs Table
|
||||
await db.query(`
|
||||
CREATE TABLE IF NOT EXISTS operation_logs (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id TEXT,
|
||||
operation_type TEXT,
|
||||
operation_target TEXT,
|
||||
description TEXT,
|
||||
ip_address TEXT,
|
||||
created_at TEXT DEFAULT (datetime('now', 'localtime'))
|
||||
)
|
||||
`);
|
||||
|
||||
console.log('Migration v2 completed successfully.');
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
console.error('Migration v2 failed:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
migrate();
|
||||
Reference in New Issue
Block a user