feat: 实现教师资料更新、操作日志和系统设置功能
新增教师资料更新功能,包括个人信息修改和密码更新 添加操作日志记录系统,记录用户关键操作 实现系统设置模块,支持动态配置系统参数 重构数据库模型,新增教师表和系统设置表 优化成绩录入逻辑,支持平时分、期中和期末成绩计算 添加数据导出功能,支持学生、教师和成绩数据导出 完善管理员后台,增加统计图表和操作日志查看
This commit is contained in:
32
backend/models/SystemSetting.js
Normal file
32
backend/models/SystemSetting.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const db = require('../config/database');
|
||||
|
||||
class SystemSetting {
|
||||
static async get(key) {
|
||||
const rows = await db.query('SELECT value FROM system_settings WHERE key = ?', [key]);
|
||||
return rows.length > 0 ? rows[0].value : null;
|
||||
}
|
||||
|
||||
static async getAll() {
|
||||
const rows = await db.query('SELECT key, value FROM system_settings');
|
||||
const settings = {};
|
||||
rows.forEach(row => {
|
||||
settings[row.key] = row.value;
|
||||
});
|
||||
return settings;
|
||||
}
|
||||
|
||||
static async set(key, value) {
|
||||
return await db.query(
|
||||
'INSERT INTO system_settings (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value',
|
||||
[key, value]
|
||||
);
|
||||
}
|
||||
|
||||
static async setMany(settings) {
|
||||
for (const [key, value] of Object.entries(settings)) {
|
||||
await this.set(key, String(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SystemSetting;
|
||||
Reference in New Issue
Block a user