当前位置:   article > 正文

Java项目:考试在线报名管理系统(java+SSM+HTML+JS+jsp+mysql)_搭建报名系统 csdn

搭建报名系统 csdn

源码获取:俺的博客首页 "资源" 里下载!

项目介绍

考务管理员角色包含以下功能:
考务管理员登录,教务办公室管理,考场管理,考试管理,考场分配管理,报名管理等功能。

管理员角色包含以下功能:
管理员登录,学院管理,班级管理,学生管理,考务管理员管理,管理员管理等功能。

学生角色包含以下功能:
学生登录,查看我的报名,报名考试,密码修改,缴费等功能。

环境需要

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/ 登录

 

 

 

 

 

学生考试信息管理控制层:

  1. @Controller
  2. public class StudentExamInfoHandler {
  3. @Autowired
  4. private StudentExamInfoService studentExamInfoService;
  5. @Autowired
  6. private ClassInfoService classInfoService;
  7. @Autowired
  8. private StudentInfoService studentInfoService;
  9. @Autowired
  10. private Gson gson;
  11. private Logger logger = Logger.getLogger(StudentExamInfoHandler.class);
  12. /**
  13. * 所有学生考试信息 图表 Json 字符串生成
  14. *
  15. * @param teacherId
  16. * @param response
  17. * @throws IOException
  18. */
  19. @RequestMapping("/examCount")
  20. public void getStudentExamCount(@RequestParam("tid") Integer teacherId, HttpServletResponse response)
  21. throws IOException {
  22. if (teacherId == null) {
  23. response.getWriter().print("TID-NULL");
  24. } else {
  25. // 获取当前班主任对应的班级
  26. ClassInfo classInfo = classInfoService.getClassByTeacherId(teacherId);
  27. // 获取学生考试信息
  28. List<StudentExamInfo> stuExamInfos = studentExamInfoService
  29. .getStudentExamCountByClassId(classInfo.getClassId());
  30. response.getWriter().print(StudentExamInfoCharts.createExamCountBarJson(stuExamInfos));
  31. }
  32. }
  33. /**
  34. * 获取班级中的所有学生
  35. *
  36. * @param teacherId
  37. * @param response
  38. * @throws IOException
  39. */
  40. @RequestMapping("/stus")
  41. public void getStudentsByClassId(@RequestParam("tid") Integer teacherId, HttpServletResponse response)
  42. throws IOException {
  43. if (teacherId == null) {
  44. response.getWriter().print("TID-NULL");
  45. } else {
  46. // 获取当前班主任对应的班级
  47. ClassInfo classInfo = classInfoService.getClassByTeacherId(teacherId);
  48. // 获取所有学生信息
  49. List<StudentInfo> stus = studentInfoService.getStudentsByClassId(classInfo.getClassId());
  50. response.getWriter().print(gson.toJson(stus));
  51. }
  52. }
  53. /**
  54. * 班级下所有学生考试平均分等信息 图表 Json 生成
  55. *
  56. * @param teacherId
  57. * @param response
  58. * @throws IOException
  59. */
  60. @RequestMapping("/avgcounts")
  61. public void getAllStudentAvgScoreCount(@RequestParam("tid") Integer teacherId, HttpServletResponse response)
  62. throws IOException {
  63. if (teacherId == null) {
  64. response.getWriter().print("TID-NULL");
  65. } else {
  66. // 获取当前班主任对应的班级
  67. ClassInfo classInfo = classInfoService.getClassByTeacherId(teacherId);
  68. // 获取所有学生信息 平局分等信息
  69. List<StudentExamInfo> stuExamInfos = studentExamInfoService
  70. .getAllStudentAvgScoreCount(classInfo.getClassId());
  71. response.getWriter().print(StudentExamInfoCharts.createAvgCountLineJson(stuExamInfos));
  72. }
  73. }
  74. @RequestMapping("/stuexam")
  75. public void getStudentExamInfoById(@RequestParam("stuId") Integer studentId, HttpServletResponse response)
  76. throws IOException {
  77. // 获取学生考试信息
  78. List<StudentExamInfo> stuExamInfos = studentExamInfoService.getStudentExamInfo(studentId);
  79. response.getWriter().print(StudentExamInfoCharts.createStudentExamLineJson(stuExamInfos));
  80. }
  81. }

班级管理控制层:

  1. @Controller
  2. @SuppressWarnings("all")
  3. public class ClassInfoHandler {
  4. @Autowired
  5. private ClassInfoService classInfoService;
  6. @Autowired
  7. private GradeInfoService gradeInfoService;
  8. @Autowired
  9. private TeacherInfoService teacherInfoService;
  10. @Autowired
  11. private TeacherInfo teacher;
  12. @Autowired
  13. private ClassInfo classInfo;
  14. @Autowired
  15. private Gson gson;
  16. private Logger logger = Logger.getLogger(ClassInfoHandler.class);
  17. /**
  18. * 获取所有班级
  19. *
  20. * @param gradeId
  21. * 系部编号
  22. * @param className
  23. * 班级名称 可用于模糊查询
  24. * @param classId
  25. * 班级编号
  26. * @return
  27. */
  28. @RequestMapping(value = "/classes", method = RequestMethod.GET)
  29. public ModelAndView getClasses(@RequestParam(value = "gradeId", required = false) Integer gradeId,
  30. @RequestParam(value = "className", required = false) String className,
  31. @RequestParam(value = "classId", required = false) Integer classId) {
  32. ModelAndView model = new ModelAndView();
  33. ClassInfo classInfo = new ClassInfo();
  34. /* 处理查询条件 */
  35. if (gradeId != null) {
  36. GradeInfo gradeInfo = new GradeInfo();
  37. gradeInfo.setGradeId(gradeId);
  38. classInfo.setGrade(gradeInfo);
  39. }
  40. if (classId != null)
  41. classInfo.setClassId(classId);
  42. if (className != null) {
  43. if (className.trim() != "")
  44. classInfo.setClassName(className);
  45. }
  46. List<ClassInfo> classes = classInfoService.getClasses(classInfo);
  47. model.setViewName("admin/clazz/classes");
  48. model.addObject("classes", classes);
  49. return model;
  50. }
  51. /**
  52. * 预添加班级处理
  53. *
  54. * @return
  55. */
  56. @RequestMapping("/preAddClass")
  57. public ModelAndView preAddClass(@RequestParam(name = "gid",required = false,defaultValue = "")Integer gid) {
  58. ModelAndView model = new ModelAndView();
  59. // 获取系部信息
  60. List<GradeInfo> grades = gradeInfoService.getGrades();
  61. model.setViewName("admin/clazz/classedit");
  62. model.addObject("grades", grades);
  63. // 获取不是班主任的教师
  64. teacher.setIsWork(0);
  65. Map<String, Object> map = new HashMap<String, Object>();
  66. map.put("startIndex", null);
  67. map.put("pageShow", null);
  68. map.put("teacher", teacher);
  69. List<TeacherInfo> teachers = teacherInfoService.getTeachers(map);
  70. model.addObject("teachers", teachers);
  71. model.addObject("editClass", new ClassInfo());
  72. model.addObject("gid",gid);
  73. return model;
  74. }
  75. /**
  76. * 添加班级
  77. *
  78. * @param classInfo
  79. * 班级信息
  80. * @param request
  81. * @return
  82. */
  83. @RequestMapping(value = "/class", method = RequestMethod.POST)
  84. public String isAddClass(ClassInfo classInfo, HttpServletRequest request) {
  85. //判断班级名是否存在
  86. ClassInfo byClassName = classInfoService.findByClassName(classInfo.getClassName());
  87. if(byClassName!=null){
  88. request.setAttribute("error", "该班级名称已存在!");
  89. return "error";
  90. }
  91. // 修改教师班主任状态
  92. String returnMsg = isChangeTeacherWork(1, classInfo.getTeacher().getTeacherId());
  93. if (returnMsg != null) {
  94. request.setAttribute("error", "修改教师班主任状态 对应教师编号有误");
  95. return "error";
  96. }
  97. // 添加
  98. int row = classInfoService.isAddClass(classInfo);
  99. if (row < 1) {
  100. request.setAttribute("error", "班级 " + classInfo.getClassName() + " 添加失败,请稍后再试!");
  101. return "error";
  102. }
  103. return "redirect:/classes";
  104. }
  105. /**
  106. * 删除班级
  107. *
  108. * @param classId
  109. * 班级编号
  110. * @param request
  111. * @return
  112. */
  113. @RequestMapping(value = "/del/class/{classId}", method = RequestMethod.DELETE)
  114. public String isDelClass(@PathVariable("classId") Integer classId, HttpServletRequest request) {
  115. logger.info("删除班级 " + classId);
  116. // 将删除班级对于之前班主任改为 非班主任状态
  117. // 需要在删除班级之前修改,如果先删除了班级,再根据班级获取教师编号,就不能获取
  118. ClassInfo delClass = classInfoService.getClassById(classId);
  119. String returnMsg = isChangeTeacherWork(0, delClass.getTeacher().getTeacherId());
  120. if (returnMsg != null) {
  121. request.setAttribute("error", "修改教师班主任状态 对应教师编号有误");
  122. return "error";
  123. }
  124. // 删除
  125. int row = classInfoService.isDelClass(classId);
  126. if (row < 1) {
  127. logger.error("班级 " + classId + " 删除失败");
  128. request.setAttribute("error", "班级删除失败,请稍后再试!");
  129. return "../error";
  130. }
  131. return "redirect:/classes";
  132. }
  133. /**
  134. * 预修改班级处理
  135. *
  136. * @param classId
  137. * 班级编号
  138. * @return
  139. */
  140. @RequestMapping(value = "edit/class/{classId}", method = RequestMethod.GET)
  141. public ModelAndView preUpdateClass(@PathVariable("classId") Integer classId) {
  142. logger.info("预修改班级处理");
  143. ModelAndView model = new ModelAndView();
  144. // 获取要修改班级
  145. ClassInfo classInfo = classInfoService.getClassById(classId);
  146. model.setViewName("/admin/clazz/classedit");
  147. model.addObject("editClass", classInfo);
  148. List<GradeInfo> grades = gradeInfoService.getGrades();
  149. // 获取不是班主任的教师
  150. teacher.setIsWork(0);
  151. Map<String, Object> map = new HashMap<String, Object>();
  152. map.put("startIndex", null);
  153. map.put("pageShow", null);
  154. map.put("teacher", teacher);
  155. List<TeacherInfo> teachers = teacherInfoService.getTeachers(map);
  156. // 如果没有可用班主任
  157. if (teachers.size() == 0 || teachers == null) {
  158. teacher.setTeacherId(classInfo.getTeacher().getTeacherId());
  159. teacher.setTeacherName("暂无剩余教师");
  160. teachers.add(teacher);
  161. }
  162. model.addObject("teachers", teachers);
  163. model.addObject("grades", grades);
  164. return model;
  165. }
  166. /**
  167. * 修改班级信息
  168. *
  169. * @param classInfo
  170. * 班级信息
  171. * @param request
  172. * @param lastTeacherId
  173. * 上一个班主任编号,修改其 班主任状态
  174. * @return
  175. */
  176. @RequestMapping(value = "edit/class/class", method = RequestMethod.POST)
  177. public String isUpdateClass(ClassInfo classInfo, HttpServletRequest request,
  178. @RequestParam(value = "lastTeacher", required = false) Integer lastTeacherId) {
  179. ClassInfo byClassName = classInfoService.findByClassName(classInfo.getClassName());
  180. if(byClassName!=null){
  181. if(!byClassName.getClassId().equals(classInfo.getClassId())){
  182. request.setAttribute("error", "该班级名称已存在!");
  183. return "../../error";
  184. }
  185. }
  186. // 修改上一教师不为班主任状态
  187. if (lastTeacherId != null) {
  188. String returnMsg = isChangeTeacherWork(0, lastTeacherId);
  189. if (returnMsg != null) {
  190. request.setAttribute("error", "修改教师班主任状态 对应教师编号有误");
  191. return "../error";
  192. }
  193. }
  194. // 修改当前教师为班主任状态
  195. String returnMsg = isChangeTeacherWork(1, classInfo.getTeacher().getTeacherId());
  196. if (returnMsg != null) {
  197. request.setAttribute("error", "修改教师班主任状态 对应教师编号有误");
  198. return "../error";
  199. }
  200. int row = classInfoService.isUpdateClass(classInfo);
  201. if (row < 1) {
  202. logger.error("班级 " + classInfo + " 修改失败");
  203. request.setAttribute("error", "班级修改失败,请稍后再试!");
  204. return "../error";
  205. }
  206. return "redirect:/classes";
  207. }
  208. /**
  209. * 获取指定系部下的班级
  210. *
  211. * @param gradeId
  212. * 系部编号
  213. * @param response
  214. * @throws IOException
  215. */
  216. @RequestMapping(value = "/gradeclass/{gradeId}", method = RequestMethod.GET)
  217. public void getClassesByGradeId(@PathVariable("gradeId") Integer gradeId, HttpServletResponse response)
  218. throws IOException {
  219. List<ClassInfo> classes = classInfoService.getClassByGradeId(gradeId);
  220. String json = gson.toJson(classes);
  221. response.getWriter().print(json);
  222. }
  223. /**
  224. * 修改教师(班主任)工作状态
  225. *
  226. * @param status
  227. * 是否为班主任标识
  228. * @param teacherId
  229. * 教师编号
  230. */
  231. private String isChangeTeacherWork(int status, Integer teacherId) {
  232. teacher.setIsWork(status);
  233. if (teacherId == null) {
  234. logger.error("修改教师班主任状态 对应教师编号有误");
  235. return "修改教师班主任状态 对应教师编号有误";
  236. }
  237. teacher.setTeacherId(teacherId);
  238. int row = teacherInfoService.updateTeacherIsWork(teacher);
  239. return null;
  240. }
  241. @RequestMapping("/stuCount")
  242. public void getStudentCountForClass(@RequestParam(value = "gradeId", required = false) Integer gradeId,
  243. HttpServletResponse response) throws IOException {
  244. Map<String, Object> map = classInfoService.getStudentCountForClass(gradeId);
  245. String json = StudentCount.createBarJson(map);
  246. response.getWriter().print(json);
  247. }
  248. /**
  249. * 预添加班级处理
  250. *
  251. * @return
  252. */
  253. @RequestMapping("/preStudentCount")
  254. public ModelAndView preStudentCount() {
  255. ModelAndView model = new ModelAndView();
  256. // 获取系部信息
  257. List<GradeInfo> grades = gradeInfoService.getGrades();
  258. model.setViewName("admin/charts/studentCount");
  259. model.addObject("grades", grades);
  260. return model;
  261. }
  262. }

科目管理控制层: 

  1. @Controller
  2. @SuppressWarnings("all")
  3. public class CourseInfoHandler {
  4. @Autowired
  5. private CourseInfoService courseInfoService;
  6. @Autowired
  7. private GradeInfoService gradeInfoService;
  8. private Logger logger = Logger.getLogger(CourseInfoHandler.class);
  9. /**
  10. * 获取科目信息
  11. *
  12. * @param gradeId
  13. * 系部编号
  14. * @param division
  15. * 分科情况
  16. * @return
  17. */
  18. @RequestMapping("/courses")
  19. public ModelAndView getCourses(@RequestParam(value = "gradeId", required = false) Integer gradeId,
  20. @RequestParam(value = "division", required = false) Integer division) {
  21. ModelAndView model = new ModelAndView();
  22. model.setViewName("/admin/course/courses");
  23. CourseInfo course = new CourseInfo();
  24. if (gradeId != null)
  25. course.getGrade().setGradeId(gradeId);
  26. if (division != null)
  27. course.setDivision(division);
  28. List<CourseInfo> courses = courseInfoService.getCourses(course);
  29. model.addObject("courses", courses);
  30. return model;
  31. }
  32. /**
  33. * 根据科目编号获取学科信息
  34. *
  35. * @param courseId
  36. * 科目编号
  37. * @return
  38. */
  39. @RequestMapping("/course/{courseId}")
  40. public ModelAndView getCourseById(@PathVariable("courseId") Integer courseId) {
  41. ModelAndView model = new ModelAndView();
  42. model.setViewName("/admin/course/courseedit");
  43. CourseInfo course = courseInfoService.getCourseById(courseId);
  44. model.addObject("course", course);
  45. /** 获取所有系部列表 */
  46. List<GradeInfo> grades = gradeInfoService.getGrades();
  47. model.addObject("grades", grades);
  48. return model;
  49. }
  50. /**
  51. * 添加/修改科目信息
  52. *
  53. * @param courseId
  54. * 科目编号
  55. * @param isUpdate
  56. * 标识是否为修改操作
  57. * @param courseName
  58. * 科目名称
  59. * @param division
  60. * 分科情况
  61. * @param gradeId
  62. * 系部编号
  63. * @return
  64. */
  65. @RequestMapping(value = "/course/course", method = RequestMethod.POST)
  66. public String isUpdateOrAddCourse(@RequestParam(value = "courseId", required = false) Integer courseId,
  67. @RequestParam(value = "isupdate", required = false) Integer isUpdate,
  68. @RequestParam("courseName") String courseName, @RequestParam("division") Integer division,
  69. @RequestParam("gradeId") Integer gradeId) {
  70. CourseInfo course = new CourseInfo();
  71. course.setCourseId(courseId);
  72. course.setCourseName(courseName);
  73. course.setDivision(division);
  74. GradeInfo grade = new GradeInfo();
  75. grade.setGradeId(gradeId);
  76. course.setGrade(grade);
  77. // 修改
  78. if (isUpdate != null) {
  79. int row = courseInfoService.isUpdateCourse(course);
  80. }
  81. // 添加
  82. else {
  83. int row = courseInfoService.isAddCourse(course);
  84. }
  85. return "redirect:/courses";
  86. }
  87. /**
  88. * 删除科目
  89. *
  90. * @param courseId
  91. * 待删除科目编号
  92. * @return
  93. */
  94. @RequestMapping(value = "/course/{courseId}", method = RequestMethod.DELETE)
  95. public String isDelTeacher(@PathVariable("courseId") Integer courseId) {
  96. int row = courseInfoService.isDelCourse(courseId);
  97. return "redirect:/courses";
  98. }
  99. /**
  100. * 预添加科目信息
  101. *
  102. * @return
  103. */
  104. @RequestMapping("/preAddCourse")
  105. public ModelAndView preAddCourse() {
  106. ModelAndView model = new ModelAndView();
  107. model.setViewName("/admin/course/courseedit");
  108. /** 获取系部集合 */
  109. List<GradeInfo> grades = gradeInfoService.getGrades();
  110. model.addObject("grades", grades);
  111. return model;
  112. }
  113. }

 源码获取:俺的博客首页 "资源" 里下载!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/485853
推荐阅读
相关标签
  

闽ICP备14008679号