• Java项目:ssm学生学籍管理系统


    作者主页:源码空间站2022

     简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文末获取源码

    项目介绍

    SSM项目-学生学籍管理系统。该项目分管理员、老师、学生三种用户角色。每种角色分别对应不同的菜单;

    以下分别介绍各个角色对应的功能模块:

    管理员角色:

    - 用户登录和退出
    - 权限控制
    - 系统管理
    - 专业管理
    - 班级管理
    - 学生管理
    - 老师管理
    - 课程管理
    - 开课管理
    - 用户管理

    老师角色:

    - 老师管理
    - 成绩管理
    - 学生查询

    学生角色:

    - 学生管理
    - 选课管理

    - 成绩查询

    技术路线

    - 开发工具:IDEA 2020.1

    - 技术框架:Spring、SpringMVC、MyBatis
    - Web容器:Tomcat 8.5.7
    - 数据库:MySQL 5.7
    - 前端UI框架:LayUI

    - 项目管理:Maven 3.6.3

    使用说明

    1. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

    若为maven项目,导入成功后请执行maven clean;maven install命令,下载所需jar包;

    2. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
    3. 将项目中application.yml配置文件中的数据库配置改为自己的配置
    4. 配置tomcat,然后运行项目,输入localhost:8080 登录

    运行截图

    相关代码 

    CourseController

    1. package com.yanzhen.controller;
    2. import com.yanzhen.entity.Course;
    3. import com.yanzhen.service.CourseService;
    4. import com.yanzhen.utils.MapControl;
    5. import org.springframework.beans.factory.annotation.Autowired;
    6. import org.springframework.stereotype.Controller;
    7. import org.springframework.ui.ModelMap;
    8. import org.springframework.web.bind.annotation.*;
    9. import java.util.List;
    10. import java.util.Map;
    11. @Controller
    12. @RequestMapping("/course")
    13. public class CourseController {
    14. private static final String LIST = "course/list";
    15. private static final String ADD = "course/add";
    16. private static final String UPDATE = "course/update";
    17. @Autowired
    18. private CourseService courseService;
    19. //跳转添加页面
    20. @GetMapping("/add")
    21. public String create() {
    22. return ADD;
    23. }
    24. //添加操作
    25. @PostMapping("/create")
    26. @ResponseBody
    27. public Map create(@RequestBody Course course) {
    28. int result = courseService.create(course);
    29. if (result <= 0) {
    30. return MapControl.getInstance().error().getMap();
    31. }
    32. return MapControl.getInstance().success().getMap();
    33. }
    34. //根据id删除
    35. @PostMapping("/delete/{id}")
    36. @ResponseBody
    37. public Map delete(@PathVariable("id") Integer id) {
    38. int result = courseService.delete(id);
    39. if (result <= 0) {
    40. return MapControl.getInstance().error().getMap();
    41. }
    42. return MapControl.getInstance().success().getMap();
    43. }
    44. //批量删除
    45. @PostMapping("/delete")
    46. @ResponseBody
    47. public Map delete(String ids) {
    48. int result = courseService.delete(ids);
    49. if (result <= 0) {
    50. return MapControl.getInstance().error().getMap();
    51. }
    52. return MapControl.getInstance().success().getMap();
    53. }
    54. //修改操作
    55. @PostMapping("/update")
    56. @ResponseBody
    57. public Map update(@RequestBody Course course) {
    58. int result = courseService.update(course);
    59. if (result <= 0) {
    60. return MapControl.getInstance().error().getMap();
    61. }
    62. return MapControl.getInstance().success().getMap();
    63. }
    64. //根据id删除,跳转修改页面
    65. @GetMapping("/detail/{id}")
    66. public String detail(@PathVariable("id") Integer id, ModelMap modelMap) {
    67. //查询出要修改的课程信息,存储到request域
    68. Course course = courseService.detail(id);
    69. modelMap.addAttribute("course", course);
    70. return UPDATE;
    71. }
    72. //查询所有
    73. @PostMapping("/query")
    74. @ResponseBody
    75. public Map query(@RequestBody Course course) {
    76. List list = courseService.query(course);
    77. //查询总记录条数
    78. Integer count = courseService.count(course);
    79. return MapControl.getInstance().success().page(list, count).getMap();
    80. }
    81. //跳转列表页面
    82. @GetMapping("/list")
    83. public String list() {
    84. return LIST;
    85. }
    86. }

    IndexController

    1. package com.yanzhen.controller;
    2. import com.yanzhen.entity.*;
    3. import com.yanzhen.service.*;
    4. import com.yanzhen.utils.MD5Utils;
    5. import com.yanzhen.utils.MapControl;
    6. import org.springframework.beans.factory.annotation.Autowired;
    7. import org.springframework.stereotype.Controller;
    8. import org.springframework.ui.ModelMap;
    9. import org.springframework.web.bind.annotation.GetMapping;
    10. import org.springframework.web.bind.annotation.PostMapping;
    11. import org.springframework.web.bind.annotation.ResponseBody;
    12. import java.util.ArrayList;
    13. import java.util.HashMap;
    14. import java.util.List;
    15. import java.util.Map;
    16. @Controller
    17. public class IndexController {
    18. @Autowired
    19. UserService userService;
    20. @Autowired
    21. TeacherService teacherService;
    22. @Autowired
    23. StudentService studentService;
    24. @Autowired
    25. ClazzService clazzService;
    26. @Autowired
    27. SubjectService subjectService;
    28. @Autowired
    29. CourseService courseService;
    30. @Autowired
    31. SectionService sectionService;
    32. @Autowired
    33. ScoreService scoreService;
    34. //跳转系统主页
    35. @GetMapping("/index")
    36. public String login() {
    37. return "index";
    38. }
    39. //跳转用户基本信息页面
    40. @GetMapping("/info")
    41. public String info() {
    42. return "info";
    43. }
    44. //跳转修改密码页面
    45. @GetMapping("/pwd")
    46. public String pwd() {
    47. return "pwd";
    48. }
    49. //修改密码 根据旧密码来修改密码
    50. @PostMapping("/pwd")
    51. @ResponseBody
    52. public Map pwd(String sourcePwd,String newPwd,String type,Integer id) {
    53. //先判断类型
    54. if("1".equals(type)) {
    55. User user = userService.detail(id);
    56. //比较原密码是否相同 注意:原密码也要加密后再进行比较,因为数据库中存储的是加密后的密码
    57. if(user.getUserPwd().equals(MD5Utils.getMD5(sourcePwd))) {
    58. User entity = new User();
    59. entity.setId(id);
    60. entity.setUserPwd(MD5Utils.getMD5(newPwd)); //主要要加密
    61. int result = userService.update(entity);
    62. if(result <= 0) {
    63. return MapControl.getInstance().error().getMap();
    64. } else {
    65. return MapControl.getInstance().success().getMap();
    66. }
    67. } else {
    68. return MapControl.getInstance().error("原密码错误").getMap();
    69. }
    70. }
    71. if("2".equals(type)) {
    72. Teacher teacher = teacherService.detail(id);
    73. //比较原密码
    74. if(teacher.getTeacherPwd().equals(MD5Utils.getMD5(sourcePwd))) {
    75. Teacher entity = new Teacher();
    76. entity.setId(id);
    77. entity.setTeacherPwd(MD5Utils.getMD5(newPwd));
    78. int result = teacherService.update(entity);
    79. if(result <= 0) {
    80. return MapControl.getInstance().error().getMap();
    81. } else {
    82. return MapControl.getInstance().success().getMap();
    83. }
    84. } else {
    85. return MapControl.getInstance().error("原密码错误").getMap();
    86. }
    87. }
    88. if("3".equals(type)) {
    89. Student student = studentService.detail(id);
    90. //比较原密码
    91. if(student.getStuPwd().equals(MD5Utils.getMD5(sourcePwd))) {
    92. Student entity = new Student();
    93. entity.setId(id);
    94. entity.setStuPwd(MD5Utils.getMD5(newPwd));
    95. int result = studentService.update(entity);
    96. if(result <= 0) {
    97. return MapControl.getInstance().error().getMap();
    98. } else {
    99. return MapControl.getInstance().success().getMap();
    100. }
    101. } else {
    102. return MapControl.getInstance().error("原密码错误").getMap();
    103. }
    104. }
    105. return MapControl.getInstance().error().getMap();
    106. }
    107. //跳转系统主页(数据概览)
    108. @GetMapping("/main")
    109. public String main(ModelMap modelMap) {
    110. //1.系统数据概览
    111. List clazzes = clazzService.query(null);
    112. List subjects = subjectService.query(null);
    113. List teachers = teacherService.query(null);
    114. List courses = courseService.query(null);
    115. List
      sections = sectionService.query(null);
    116. List students = studentService.query(null);
    117. modelMap.addAttribute("clazzCnt",clazzes.size());
    118. modelMap.addAttribute("subjectCnt",subjects.size());
    119. modelMap.addAttribute("teacherCnt",teachers.size());
    120. modelMap.addAttribute("courseCnt",courses.size());
    121. modelMap.addAttribute("studentCnt",students.size());
    122. modelMap.addAttribute("sectionCnt",sections.size());
    123. //2.班级学生数量
    124. List> mapList = new ArrayList<>();
    125. for(Clazz clazz : clazzes) {
    126. Map map = new HashMap<>();
    127. map.put("name",clazz.getClazzName()); //设置班级名称
    128. int cnt = 0;
    129. //统计学生数量
    130. for(Student student : students) {
    131. if(student.getClazzId() == clazz.getId()) {
    132. cnt++;
    133. }
    134. }
    135. map.put("cnt",cnt); //设置学生数量
    136. mapList.add(map);
    137. }
    138. modelMap.addAttribute("mapList",mapList);
    139. //3.查询各科平均成绩(根据专业查询各科平均成绩)
    140. List mapList2 = scoreService.queryAvgScoreBySection();
    141. modelMap.addAttribute("mapList2",mapList2);
    142. return "main";
    143. }
    144. }

    ScoreController

    1. package com.yanzhen.controller;
    2. import com.yanzhen.entity.Course;
    3. import com.yanzhen.entity.Score;
    4. import com.yanzhen.entity.Section;
    5. import com.yanzhen.entity.Student;
    6. import com.yanzhen.service.CourseService;
    7. import com.yanzhen.service.ScoreService;
    8. import com.yanzhen.service.SectionService;
    9. import com.yanzhen.utils.MapControl;
    10. import org.springframework.beans.factory.annotation.Autowired;
    11. import org.springframework.stereotype.Controller;
    12. import org.springframework.web.bind.annotation.*;
    13. import javax.servlet.http.HttpSession;
    14. import java.util.List;
    15. import java.util.Map;
    16. @Controller
    17. @RequestMapping("/score")
    18. public class ScoreController {
    19. @Autowired
    20. private ScoreService scoreService;
    21. @Autowired
    22. private CourseService courseService;
    23. @Autowired
    24. private SectionService sectionService;
    25. //添加操作
    26. @PostMapping("/create")
    27. @ResponseBody
    28. public Map create(String sectionIds, String courseIds, HttpSession session) {
    29. Student student = (Student) session.getAttribute("user");
    30. int result = scoreService.create(sectionIds, courseIds, student.getId());
    31. if (result <= 0) {
    32. return MapControl.getInstance().error().getMap();
    33. }
    34. return MapControl.getInstance().success().getMap();
    35. }
    36. //修改操作
    37. @PostMapping("/update")
    38. @ResponseBody
    39. public Map update(Score score) {
    40. int result = scoreService.update(score);
    41. if (result <= 0) {
    42. return MapControl.getInstance().error().getMap();
    43. }
    44. return MapControl.getInstance().success().getMap();
    45. }
    46. //根据id查询
    47. @PostMapping("/detail/{id}")
    48. @ResponseBody
    49. public Map detail(@PathVariable("id") Integer id) {
    50. Score score = scoreService.detail(id);
    51. if (score == null) {
    52. return MapControl.getInstance().nodata().getMap();
    53. }
    54. return MapControl.getInstance().success().put("data", score).getMap();
    55. }
    56. //查询所有
    57. @PostMapping("/query")
    58. @ResponseBody
    59. public Map query(Score score) {
    60. List list = scoreService.query(score);
    61. return MapControl.getInstance().success().put("data", list).getMap();
    62. }
    63. //跳转查询成绩页面
    64. @GetMapping("/student_score")
    65. public String student_score() {
    66. return "score/student_score";
    67. }
    68. //查询学生成绩
    69. @PostMapping("/query_student_score")
    70. @ResponseBody
    71. public Map query_student_score(HttpSession session) {
    72. //从session中获取
    73. Student student = (Student) session.getAttribute("user");
    74. Score score = new Score();
    75. score.setStuId(student.getId());
    76. //查询成绩
    77. List scores = scoreService.query(score);
    78. //查询课程信息
    79. List courses = courseService.query(null);
    80. //查询开课信息
    81. List
      sections = sectionService.query(null);
    82. scores.forEach(entity -> {
    83. courses.forEach(course -> {
    84. //判断该成绩表中的courseId与课程表的id是否一致
    85. if (entity.getCourseId() == course.getId()) {
    86. entity.setCourse(course);
    87. }
    88. });
    89. sections.forEach(section -> {
    90. //判断该成绩的开课id是否与开课的id一致
    91. if (entity.getSectionId() == section.getId()) {
    92. entity.setSection(section);
    93. }
    94. });
    95. entity.setStudent(student);
    96. });
    97. return MapControl.getInstance().success().put("data", scores).getMap();
    98. }
    99. }

    StudentController

    1. package com.yanzhen.controller;
    2. import com.yanzhen.entity.Clazz;
    3. import com.yanzhen.entity.Student;
    4. import com.yanzhen.entity.Subject;
    5. import com.yanzhen.entity.Teacher;
    6. import com.yanzhen.service.ClazzService;
    7. import com.yanzhen.service.StudentService;
    8. import com.yanzhen.service.SubjectService;
    9. import com.yanzhen.utils.MapControl;
    10. import org.springframework.beans.factory.annotation.Autowired;
    11. import org.springframework.stereotype.Controller;
    12. import org.springframework.ui.ModelMap;
    13. import org.springframework.web.bind.annotation.*;
    14. import javax.servlet.http.HttpSession;
    15. import java.util.List;
    16. import java.util.Map;
    17. @Controller
    18. @RequestMapping("/student")
    19. public class StudentController {
    20. private static final String LIST = "student/list";
    21. private static final String ADD = "student/add";
    22. private static final String UPDATE = "student/update";
    23. @Autowired
    24. private StudentService studentService;
    25. @Autowired
    26. private SubjectService subjectService;
    27. @Autowired
    28. private ClazzService clazzService;
    29. //跳转添加页面
    30. @GetMapping("/add")
    31. public String create(ModelMap modelMap) {
    32. //查询所有的专业,存储到request域
    33. List subjects = subjectService.query(null);
    34. modelMap.addAttribute("subjects", subjects);
    35. return ADD;
    36. }
    37. //添加操作
    38. @PostMapping("/create")
    39. @ResponseBody
    40. public Map create(@RequestBody Student student) {
    41. //设置学生的状态
    42. student.setStatus(Student.StatusType.type_1);
    43. int result = studentService.create(student);
    44. if (result <= 0) {
    45. return MapControl.getInstance().error().getMap();
    46. }
    47. return MapControl.getInstance().success().getMap();
    48. }
    49. //根据id查询
    50. @PostMapping("/delete/{id}")
    51. @ResponseBody
    52. public Map delete(@PathVariable("id") Integer id) {
    53. int result = studentService.delete(id);
    54. if (result <= 0) {
    55. return MapControl.getInstance().error().getMap();
    56. }
    57. return MapControl.getInstance().success().getMap();
    58. }
    59. //删除操作
    60. @PostMapping("/delete")
    61. @ResponseBody
    62. public Map delete(String ids) {
    63. int result = studentService.delete(ids);
    64. if (result <= 0) {
    65. return MapControl.getInstance().error().getMap();
    66. }
    67. return MapControl.getInstance().success().getMap();
    68. }
    69. //修改操作
    70. @PostMapping("/update")
    71. @ResponseBody
    72. public Map update(@RequestBody Student student) {
    73. int result = studentService.update(student);
    74. if (result <= 0) {
    75. return MapControl.getInstance().error().getMap();
    76. }
    77. return MapControl.getInstance().success().getMap();
    78. }
    79. //根据id查询,跳转修改页面
    80. @GetMapping("/detail/{id}")
    81. public String detail(@PathVariable("id") Integer id, ModelMap modelMap) {
    82. //查询出要修改的学生的信息
    83. Student student = studentService.detail(id);
    84. //查询所有的专业
    85. List subjects = subjectService.query(null);
    86. //将查询出来的数据存储到request域,实现表单回显
    87. modelMap.addAttribute("student", student);
    88. modelMap.addAttribute("subjects", subjects);
    89. return UPDATE;
    90. }
    91. //查询所有
    92. @PostMapping("/query")
    93. @ResponseBody
    94. public Map query(@RequestBody Student student) {
    95. //查询所有的学生信息
    96. List list = studentService.query(student);
    97. //查询所有的专业
    98. List subjects = subjectService.query(null);
    99. //查询所有的班级
    100. List clazzes = clazzService.query(null);
    101. //设置关联
    102. list.forEach(entity -> {
    103. subjects.forEach(subject -> {
    104. //判断学生表中的subjectId和专业表的id是否一致
    105. if (subject.getId() == entity.getSubjectId()) {
    106. entity.setSubject(subject);
    107. }
    108. });
    109. clazzes.forEach(clazz -> {
    110. //判断学生表中的clazzId和班级表的id是否一致
    111. if (clazz.getId() == entity.getClazzId()) {
    112. entity.setClazz(clazz);
    113. }
    114. });
    115. });
    116. //查询总记录条数
    117. Integer count = studentService.count(student);
    118. return MapControl.getInstance().success().page(list, count).getMap();
    119. }
    120. //跳转列表页面
    121. @GetMapping("/list")
    122. public String list() {
    123. return LIST;
    124. }
    125. //跳转查询学生页面
    126. @GetMapping("/teacher_student")
    127. public String teacher_student(ModelMap modelMap, HttpSession session) {
    128. //查询所有的专业
    129. List subjects = subjectService.query(null);
    130. //查询所有的班级
    131. List clazzes = clazzService.query(null);
    132. Teacher teacher = (Teacher) session.getAttribute("user");
    133. modelMap.addAttribute("subjects", subjects);
    134. modelMap.addAttribute("clazzes", clazzes);
    135. modelMap.addAttribute("teacher", teacher);
    136. return "student/teacher_student";
    137. }
    138. //老师查询学生
    139. @PostMapping("/teacher_student")
    140. @ResponseBody
    141. public Map teacher_student(Integer clazzId, Integer subjectId, ModelMap modelMap, HttpSession session) {
    142. Teacher teacher = (Teacher) session.getAttribute("user");
    143. List students = studentService.queryStudentByTeacher(teacher.getId(), clazzId, subjectId);
    144. List subjects = subjectService.query(null);
    145. List clazzes = clazzService.query(null);
    146. //设置关联
    147. students.forEach(entity -> {
    148. subjects.forEach(subject -> {
    149. //判断学生表的subjectId和专业表的id是否一致
    150. if (subject.getId() == entity.getSubjectId()) {
    151. entity.setSubject(subject);
    152. }
    153. });
    154. clazzes.forEach(clazz -> {
    155. //判断学生表的clazzId和班级表的id是否一致
    156. if (clazz.getId() == entity.getClazzId()) {
    157. entity.setClazz(clazz);
    158. }
    159. });
    160. });
    161. return MapControl.getInstance().success().add("data", students).getMap();
    162. }
    163. }

    如果也想学习本系统,下面领取。关注并回复:014ssm 

     

  • 相关阅读:
    Filter快速入门、Filter执行流程、Filter使用细节、Listener概念、分类、ServletContextListener使用
    Java工厂设计模式
    夺旗赛 CTF 六大方向基础工具简介集合
    【黑马-SpringCloud技术栈】【08】Docker_安装_自定义镜像_DockerCompose_搭建私有镜像仓库
    mysql 定时执行 查询动态表名插入汇总表的sql
    10月1日作业
    代码随想录算法训练营第五十七天丨 动态规划part17
    【Ubuntu】虚拟机安装系统与初始化配置
    清除el-form表单验证
    欧拉路径!
  • 原文地址:https://blog.csdn.net/m0_74967853/article/details/128100968