feat: 实现成绩管理系统核心功能
添加响应工具、错误处理中间件和数据库模型 创建用户、学生、课程和成绩相关服务 实现管理员、教师和学生控制器的基本功能 重构路由处理并优化数据库查询
This commit is contained in:
17
backend/models/Course.js
Normal file
17
backend/models/Course.js
Normal 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;
|
||||
Reference in New Issue
Block a user