feat(学生): 添加学生课程查询功能
- 后端添加获取学生课程列表的API路由 - 实现Course模型中的findByStudentId方法查询学生课程 - 新增学生控制器的getCourses方法处理课程请求 - 前端添加课程表格展示及刷新功能
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user