feat: 实现成绩管理系统核心功能

添加响应工具、错误处理中间件和数据库模型
创建用户、学生、课程和成绩相关服务
实现管理员、教师和学生控制器的基本功能
重构路由处理并优化数据库查询
This commit is contained in:
祀梦
2025-12-21 22:10:48 +08:00
parent bcf2c71fad
commit b9a975004b
20 changed files with 659 additions and 937 deletions

17
backend/models/Course.js Normal file
View File

@@ -0,0 +1,17 @@
const db = require('../config/database');
class Course {
static async findByTeacherId(teacherId) {
return await db.query(
'SELECT * FROM courses WHERE teacher_id = ? ORDER BY course_code',
[teacherId]
);
}
static async findById(id) {
const rows = await db.query('SELECT * FROM courses WHERE id = ?', [id]);
return rows[0];
}
}
module.exports = Course;