feat(学生): 添加学生课程查询功能

- 后端添加获取学生课程列表的API路由
- 实现Course模型中的findByStudentId方法查询学生课程
- 新增学生控制器的getCourses方法处理课程请求
- 前端添加课程表格展示及刷新功能
This commit is contained in:
2025-12-21 22:55:43 +08:00
parent 00e2f6ac88
commit f360194efd
6 changed files with 129 additions and 6 deletions

View File

@@ -30,6 +30,20 @@ class StudentController {
error(res, '服务器错误');
}
}
static async getCourses(req, res) {
try {
const userId = req.session.user.id;
const data = await StudentService.getStudentCourses(userId);
success(res, data);
} catch (err) {
if (err.message === '学生信息不存在') {
return error(res, err.message, 404);
}
console.error('Get Courses Error:', err);
error(res, '服务器错误');
}
}
}
module.exports = StudentController;