源码获取:俺的博客首页 "资源" 里下载!
项目介绍
考务管理员角色包含以下功能:
考务管理员登录,教务办公室管理,考场管理,考试管理,考场分配管理,报名管理等功能。
管理员角色包含以下功能:
管理员登录,学院管理,班级管理,学生管理,考务管理员管理,管理员管理等功能。
学生角色包含以下功能:
学生登录,查看我的报名,报名考试,密码修改,缴费等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 5.7版本;
技术栈
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:HTML+CSS+JavaScript+jsp
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ 登录
学生考试信息管理控制层:
@Controllerpublic class StudentExamInfoHandler {@Autowiredprivate StudentExamInfoService studentExamInfoService;@Autowiredprivate ClassInfoService classInfoService;@Autowiredprivate StudentInfoService studentInfoService;@Autowiredprivate Gson gson;private Logger logger = Logger.getLogger(StudentExamInfoHandler.class);/*** 所有学生考试信息 图表 Json 字符串生成* * @param teacherId* @param response* @throws IOException*/@RequestMapping("/examCount")public void getStudentExamCount(@RequestParam("tid") Integer teacherId, HttpServletResponse response)throws IOException {if (teacherId == null) {response.getWriter().print("TID-NULL");} else {// 获取当前班主任对应的班级ClassInfo classInfo = classInfoService.getClassByTeacherId(teacherId);// 获取学生考试信息List<StudentExamInfo> stuExamInfos = studentExamInfoService.getStudentExamCountByClassId(classInfo.getClassId());response.getWriter().print(StudentExamInfoCharts.createExamCountBarJson(stuExamInfos));}}/*** 获取班级中的所有学生* * @param teacherId* @param response* @throws IOException*/@RequestMapping("/stus")public void getStudentsByClassId(@RequestParam("tid") Integer teacherId, HttpServletResponse response)throws IOException {if (teacherId == null) {response.getWriter().print("TID-NULL");} else {// 获取当前班主任对应的班级ClassInfo classInfo = classInfoService.getClassByTeacherId(teacherId);// 获取所有学生信息List<StudentInfo> stus = studentInfoService.getStudentsByClassId(classInfo.getClassId());response.getWriter().print(gson.toJson(stus));}}/*** 班级下所有学生考试平均分等信息 图表 Json 生成* * @param teacherId* @param response* @throws IOException*/@RequestMapping("/avgcounts")public void getAllStudentAvgScoreCount(@RequestParam("tid") Integer teacherId, HttpServletResponse response)throws IOException {if (teacherId == null) {response.getWriter().print("TID-NULL");} else {// 获取当前班主任对应的班级ClassInfo classInfo = classInfoService.getClassByTeacherId(teacherId);// 获取所有学生信息 平局分等信息List<StudentExamInfo> stuExamInfos = studentExamInfoService.getAllStudentAvgScoreCount(classInfo.getClassId());response.getWriter().print(StudentExamInfoCharts.createAvgCountLineJson(stuExamInfos));}}@RequestMapping("/stuexam")public void getStudentExamInfoById(@RequestParam("stuId") Integer studentId, HttpServletResponse response)throws IOException {// 获取学生考试信息List<StudentExamInfo> stuExamInfos = studentExamInfoService.getStudentExamInfo(studentId);response.getWriter().print(StudentExamInfoCharts.createStudentExamLineJson(stuExamInfos));}}
班级管理控制层:
@Controller@SuppressWarnings("all")public class ClassInfoHandler {@Autowiredprivate ClassInfoService classInfoService;@Autowiredprivate GradeInfoService gradeInfoService;@Autowiredprivate TeacherInfoService teacherInfoService;@Autowiredprivate TeacherInfo teacher;@Autowiredprivate ClassInfo classInfo;@Autowiredprivate Gson gson;private Logger logger = Logger.getLogger(ClassInfoHandler.class);/*** 获取所有班级* * @param gradeId* 系部编号* @param className* 班级名称 可用于模糊查询* @param classId* 班级编号* @return*/@RequestMapping(value = "/classes", method = RequestMethod.GET)public ModelAndView getClasses(@RequestParam(value = "gradeId", required = false) Integer gradeId,@RequestParam(value = "className", required = false) String className,@RequestParam(value = "classId", required = false) Integer classId) {ModelAndView model = new ModelAndView();ClassInfo classInfo = new ClassInfo();/* 处理查询条件 */if (gradeId != null) {GradeInfo gradeInfo = new GradeInfo();gradeInfo.setGradeId(gradeId);classInfo.setGrade(gradeInfo);}if (classId != null)classInfo.setClassId(classId);if (className != null) {if (className.trim() != "")classInfo.setClassName(className);}List<ClassInfo> classes = classInfoService.getClasses(classInfo);model.setViewName("admin/clazz/classes");model.addObject("classes", classes);return model;}/*** 预添加班级处理* * @return*/@RequestMapping("/preAddClass")public ModelAndView preAddClass(@RequestParam(name = "gid",required = false,defaultValue = "")Integer gid) {ModelAndView model = new ModelAndView();// 获取系部信息List<GradeInfo> grades = gradeInfoService.getGrades();model.setViewName("admin/clazz/classedit");model.addObject("grades", grades);// 获取不是班主任的教师teacher.setIsWork(0);Map<String, Object> map = new HashMap<String, Object>();map.put("startIndex", null);map.put("pageShow", null);map.put("teacher", teacher);List<TeacherInfo> teachers = teacherInfoService.getTeachers(map);model.addObject("teachers", teachers);model.addObject("editClass", new ClassInfo());model.addObject("gid",gid);return model;}/*** 添加班级* * @param classInfo* 班级信息* @param request* @return*/@RequestMapping(value = "/class", method = RequestMethod.POST)public String isAddClass(ClassInfo classInfo, HttpServletRequest request) {//判断班级名是否存在ClassInfo byClassName = classInfoService.findByClassName(classInfo.getClassName());if(byClassName!=null){request.setAttribute("error", "该班级名称已存在!");return "error";}// 修改教师班主任状态String returnMsg = isChangeTeacherWork(1, classInfo.getTeacher().getTeacherId());if (returnMsg != null) {request.setAttribute("error", "修改教师班主任状态 对应教师编号有误");return "error";}// 添加int row = classInfoService.isAddClass(classInfo);if (row < 1) {request.setAttribute("error", "班级 " + classInfo.getClassName() + " 添加失败,请稍后再试!");return "error";}return "redirect:/classes";}/*** 删除班级* * @param classId* 班级编号* @param request* @return*/@RequestMapping(value = "/del/class/{classId}", method = RequestMethod.DELETE)public String isDelClass(@PathVariable("classId") Integer classId, HttpServletRequest request) {logger.info("删除班级 " + classId);// 将删除班级对于之前班主任改为 非班主任状态// 需要在删除班级之前修改,如果先删除了班级,再根据班级获取教师编号,就不能获取ClassInfo delClass = classInfoService.getClassById(classId);String returnMsg = isChangeTeacherWork(0, delClass.getTeacher().getTeacherId());if (returnMsg != null) {request.setAttribute("error", "修改教师班主任状态 对应教师编号有误");return "error";}// 删除int row = classInfoService.isDelClass(classId);if (row < 1) {logger.error("班级 " + classId + " 删除失败");request.setAttribute("error", "班级删除失败,请稍后再试!");return "../error";}return "redirect:/classes";}/*** 预修改班级处理* * @param classId* 班级编号* @return*/@RequestMapping(value = "edit/class/{classId}", method = RequestMethod.GET)public ModelAndView preUpdateClass(@PathVariable("classId") Integer classId) {logger.info("预修改班级处理");ModelAndView model = new ModelAndView();// 获取要修改班级ClassInfo classInfo = classInfoService.getClassById(classId);model.setViewName("/admin/clazz/classedit");model.addObject("editClass", classInfo);List<GradeInfo> grades = gradeInfoService.getGrades();// 获取不是班主任的教师teacher.setIsWork(0);Map<String, Object> map = new HashMap<String, Object>();map.put("startIndex", null);map.put("pageShow", null);map.put("teacher", teacher);List<TeacherInfo> teachers = teacherInfoService.getTeachers(map);// 如果没有可用班主任if (teachers.size() == 0 || teachers == null) {teacher.setTeacherId(classInfo.getTeacher().getTeacherId());teacher.setTeacherName("暂无剩余教师");teachers.add(teacher);}model.addObject("teachers", teachers);model.addObject("grades", grades);return model;}/*** 修改班级信息* * @param classInfo* 班级信息* @param request* @param lastTeacherId* 上一个班主任编号,修改其 班主任状态* @return*/@RequestMapping(value = "edit/class/class", method = RequestMethod.POST)public String isUpdateClass(ClassInfo classInfo, HttpServletRequest request,@RequestParam(value = "lastTeacher", required = false) Integer lastTeacherId) {ClassInfo byClassName = classInfoService.findByClassName(classInfo.getClassName());if(byClassName!=null){if(!byClassName.getClassId().equals(classInfo.getClassId())){request.setAttribute("error", "该班级名称已存在!");return "../../error";}}// 修改上一教师不为班主任状态if (lastTeacherId != null) {String returnMsg = isChangeTeacherWork(0, lastTeacherId);if (returnMsg != null) {request.setAttribute("error", "修改教师班主任状态 对应教师编号有误");return "../error";}}// 修改当前教师为班主任状态String returnMsg = isChangeTeacherWork(1, classInfo.getTeacher().getTeacherId());if (returnMsg != null) {request.setAttribute("error", "修改教师班主任状态 对应教师编号有误");return "../error";}int row = classInfoService.isUpdateClass(classInfo);if (row < 1) {logger.error("班级 " + classInfo + " 修改失败");request.setAttribute("error", "班级修改失败,请稍后再试!");return "../error";}return "redirect:/classes";}/*** 获取指定系部下的班级* * @param gradeId* 系部编号* @param response* @throws IOException*/@RequestMapping(value = "/gradeclass/{gradeId}", method = RequestMethod.GET)public void getClassesByGradeId(@PathVariable("gradeId") Integer gradeId, HttpServletResponse response)throws IOException {List<ClassInfo> classes = classInfoService.getClassByGradeId(gradeId);String json = gson.toJson(classes);response.getWriter().print(json);}/*** 修改教师(班主任)工作状态* * @param status* 是否为班主任标识* @param teacherId* 教师编号*/private String isChangeTeacherWork(int status, Integer teacherId) {teacher.setIsWork(status);if (teacherId == null) {logger.error("修改教师班主任状态 对应教师编号有误");return "修改教师班主任状态 对应教师编号有误";}teacher.setTeacherId(teacherId);int row = teacherInfoService.updateTeacherIsWork(teacher);return null;}@RequestMapping("/stuCount")public void getStudentCountForClass(@RequestParam(value = "gradeId", required = false) Integer gradeId,HttpServletResponse response) throws IOException {Map<String, Object> map = classInfoService.getStudentCountForClass(gradeId);String json = StudentCount.createBarJson(map);response.getWriter().print(json);}/*** 预添加班级处理* * @return*/@RequestMapping("/preStudentCount")public ModelAndView preStudentCount() {ModelAndView model = new ModelAndView();// 获取系部信息List<GradeInfo> grades = gradeInfoService.getGrades();model.setViewName("admin/charts/studentCount");model.addObject("grades", grades);return model;}}
科目管理控制层:
@Controller@SuppressWarnings("all")public class CourseInfoHandler {@Autowiredprivate CourseInfoService courseInfoService;@Autowiredprivate GradeInfoService gradeInfoService;private Logger logger = Logger.getLogger(CourseInfoHandler.class);/*** 获取科目信息* * @param gradeId* 系部编号* @param division* 分科情况* @return*/@RequestMapping("/courses")public ModelAndView getCourses(@RequestParam(value = "gradeId", required = false) Integer gradeId,@RequestParam(value = "division", required = false) Integer division) {ModelAndView model = new ModelAndView();model.setViewName("/admin/course/courses");CourseInfo course = new CourseInfo();if (gradeId != null)course.getGrade().setGradeId(gradeId);if (division != null)course.setDivision(division);List<CourseInfo> courses = courseInfoService.getCourses(course);model.addObject("courses", courses);return model;}/*** 根据科目编号获取学科信息* * @param courseId* 科目编号* @return*/@RequestMapping("/course/{courseId}")public ModelAndView getCourseById(@PathVariable("courseId") Integer courseId) {ModelAndView model = new ModelAndView();model.setViewName("/admin/course/courseedit");CourseInfo course = courseInfoService.getCourseById(courseId);model.addObject("course", course);/** 获取所有系部列表 */List<GradeInfo> grades = gradeInfoService.getGrades();model.addObject("grades", grades);return model;}/*** 添加/修改科目信息* * @param courseId* 科目编号* @param isUpdate* 标识是否为修改操作* @param courseName* 科目名称* @param division* 分科情况* @param gradeId* 系部编号* @return*/@RequestMapping(value = "/course/course", method = RequestMethod.POST)public String isUpdateOrAddCourse(@RequestParam(value = "courseId", required = false) Integer courseId,@RequestParam(value = "isupdate", required = false) Integer isUpdate,@RequestParam("courseName") String courseName, @RequestParam("division") Integer division,@RequestParam("gradeId") Integer gradeId) {CourseInfo course = new CourseInfo();course.setCourseId(courseId);course.setCourseName(courseName);course.setDivision(division);GradeInfo grade = new GradeInfo();grade.setGradeId(gradeId);course.setGrade(grade);// 修改if (isUpdate != null) {int row = courseInfoService.isUpdateCourse(course);}// 添加else {int row = courseInfoService.isAddCourse(course);}return "redirect:/courses";}/*** 删除科目* * @param courseId* 待删除科目编号* @return*/@RequestMapping(value = "/course/{courseId}", method = RequestMethod.DELETE)public String isDelTeacher(@PathVariable("courseId") Integer courseId) {int row = courseInfoService.isDelCourse(courseId);return "redirect:/courses";}/*** 预添加科目信息* * @return*/@RequestMapping("/preAddCourse")public ModelAndView preAddCourse() {ModelAndView model = new ModelAndView();model.setViewName("/admin/course/courseedit");/** 获取系部集合 */List<GradeInfo> grades = gradeInfoService.getGrades();model.addObject("grades", grades);return model;}}
源码获取:俺的博客首页 "资源" 里下载!