以下为学生信息管理的主要前端界面
项目仓库 CYHone/vue-student-ms: 学生信息管理系统前端界面 (github.com)
项目仓库 CYHone/student-ms-server: 学生信息管理系统后端代码 (github.com)
4.1、学生功能
登录界面可以以三种身份登录:学生、教师、管理员。
选择学生身份登录。
注册输入相关信息,输入邮箱,得到邮箱验证码。
主题后端代码
@RestController
//@CrossOrigin("*")
@RequestMapping("/student")
public class StudentController {
@Autowired
private StudentService studentService;
@Autowired
private EmailService emailService;
@Autowired
private StringRedisTemplate stringRedisTemplate;
//@CrossOrigin(origins = "http://localhost:5173", allowCredentials = "true")
@PostMapping("/registerCode")
public Result sendRegisterCode(@RequestBody String encodedEmail){
if (encodedEmail == null || encodedEmail.isEmpty()) {
return Result.error("请输入邮箱!");
}
String email = URLDecoder.decode(encodedEmail, StandardCharsets.UTF_8);
System.out.println("Decoded email: " + email);
EmailDTO emailDTO = new EmailDTO();
// 设置验证码
String code = RandomUtil.getVerifyCode();
System.out.println("验证码: " + code);
String content = "验证码为 " + code + " ,五分钟有效,请妥善保管!";
// 邮件内容
emailDTO.setEmail(email);
emailDTO.setTitle("学生信息管理系统——注册服务");
emailDTO.setContent(content);
// 查询用户
Student student = studentService.findByEmail(email);
if(student == null){
//没被注册
System.out.println("没被注册");
System.out.println("准备向邮箱发送 " );
try {
emailService.sendMsg(emailDTO);
// 往Redis中存储一个键值对
ValueOperations<String, String> operations = stringRedisTemplate.opsForValue();
operations.set(emailDTO.getEmail(), code, 300, TimeUnit.SECONDS);
return Result.success();
} catch (Exception e) {
e.printStackTrace();
return Result.error("邮件发送失败!");
}
}
return Result.error("已被注册!");
}
@PostMapping("/register")
public Result register(@RequestBody Student student) {
System.out.println("正在验证学生注册:" + student);
//还需要进行验证码判断
ValueOperations<String, String> operations = stringRedisTemplate.opsForValue();
student.setPassword((Md5Util.getMD5String(student.getPassword())));
studentService.save(student);
operations.getOperations().delete(student.getEmail());
return Result.success("注册成功");
}
@PostMapping("/login")
public ResponseEntity<Student> login(@RequestBody Student student) {
System.out.println("正在验证学生登录:" + student);
Student s = studentService.findByEmail(student.getEmail());
System.out.println("查询到的学生:" + s);
if (s == null || !Md5Util.checkPassword(student.getPassword(), s.getPassword())) {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(null);
} else {
System.out.println(s.getName() + "成功登录");
return ResponseEntity.ok(s);
}
}
@PostMapping("updateStudent")
public boolean updateStudent(@RequestBody Student student) {
System.out.println("更新 " + student);
student.setPassword((Md5Util.getMD5String(student.getPassword())));
System.out.println("更新加密 " + student);
return studentService.updateById(student);
}
}
图4.5 学生登录界面
图4.6 学生主页界面
学生选课功能以及分页查询
选课信息查询: 学生能够查询自己已选课程的信息,包括课程名称、任课教师、上课时间和地点等。
课程成绩查询: 学生可以查询自己的课程成绩,系统提供成绩的详细查询和报表下载功能,方便学生了解自己的学业情况和学习进度。
图4.7 学生选课界面
图4.8 学生退课界面
@RestController
@RequestMapping("/student")
public class CourseController {
private final CourseService courseService;
@Autowired
public CourseController(CourseService courseService) {
this.courseService = courseService;
}
@PostMapping("/courses")
public Map<String, Object> getAllCourses(@RequestBody Map<String, Integer> paginationParams) {
int offset = paginationParams.getOrDefault("offset", 0);
int limit = paginationParams.getOrDefault("limit", 10); // 默认每页显示 10 条数据
List<CourseDTO> courses = courseService.getAllCourses(offset, limit);
int totalCount = courseService.getTotalCount(); // 获取总记录数
Map<String, Object> result = new HashMap<>();
result.put("courses", courses);
result.put("totalCount", totalCount);
return result;
}
@PostMapping("/searchCourse")
public Map<String, Object> getCourses(@RequestBody Map<String, Object> requestData) {
int offset = (int) requestData.getOrDefault("offset", 0);
int limit = (int) requestData.getOrDefault("limit", 10);
String keyword = (String) requestData.getOrDefault("keyword", "");
String type = (String) requestData.getOrDefault("type", "courseName");
List<CourseDTO> courses = courseService.getCourses(offset, limit, keyword, type);
int totalCount = courseService.getCoursesCount(keyword, type);
Map<String, Object> result = new HashMap<>();
result.put("courses", courses);
result.put("totalCount", totalCount);
return result;
}
@PostMapping("/selectCourse")
public boolean selectCourse(@RequestBody SelectCourseRequest request) {
Integer courseID = request.getCourseID();
System.out.println("课程号"+courseID);
Integer studentID = request.getStudentID();
System.out.println("学号"+studentID);
return courseService.selectCourse(courseID, studentID);
}
@PostMapping("/myCourses")
public List<CourseDTO> getAllMyCourses(@RequestBody Integer studentId) {
System.out.println("学号" + studentId);
return courseService.getAllMyCourses(studentId);
}
@PostMapping("/deleteCourses")
public boolean deleteCourse(@RequestBody Integer deleteCourseId ){
System.out.println("删除课程ID" + deleteCourseId);
return courseService.deleteCourse(deleteCourseId);
}
@PostMapping("/grade")
public List<GradeDTO> getGrade(@RequestBody Integer studentId){
System.out.println("学号" + studentId);
return courseService.getGrade(studentId);
}
}
图4.9分数统计图界面
图4.10 修改个人信息
4.2、教师功能
图4.12 教师课程管理
图4.13 教师开设课程管理
图4.16 教师查询学生成绩
4.3 管理员功能
图4.17 管理员修改老师密码
图4.17 管理员查询老师档案
图4.17 管理员排课功能