基于javaweb+mysql的springboot学生信息管理系统(java+springboot+maven+mybaits+html+easyui+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot学生信息管理系统(java+springboot+maven+mybaits+html+easyui+mysql)
项目介绍
Springboot学生信息管理系统主要分为管理员、教师、学生三种角色。 管理员角色主要功能如下: 学生信息管理:学生查询、新增、编辑、删除等; 班级信息管理:班级查询、新增、编辑、删除等; 教师信息管理:教师查询、新增、编辑、删除等; 课程信息管理:课程查询、新增、编辑、删除等; 选课信息管理:选课查询、新增、编辑、删除等; 考勤信息管理:考勤查询、新增、编辑、删除等; 请假信息管理:请假查询、新增、编辑、删除等; 成绩信息管理:成绩查询、新增、编辑、删除等; 成绩统计:区间统计图、平均统计图; 系统管理:修改密码;
教师主要功能如下: 学生信息管理:学生查询、新增、编辑、删除等; 班级信息管理:班级查询、新增、编辑、删除等; 教师信息管理:教师查询、新增、编辑、删除等; 课程信息管理:课程查询、新增、编辑、删除等; 选课信息管理:选课查询、新增、编辑、删除等; 考勤信息管理:考勤查询、新增、编辑、删除等; 请假信息管理:请假查询、新增、编辑、删除等; 成绩信息管理:成绩查询、新增、编辑、删除等; 教师用户仅可查看自己权限下的信息。
学生主要功能如下: 学生信息管理:学生查询、新增、编辑、删除等; 选课信息管理:选课查询、新增、编辑、删除等; 考勤信息管理:考勤查询、新增、编辑、删除等; 请假信息管理:请假查询、新增、编辑、删除等; 成绩信息管理:成绩查询、新增、编辑、删除等; 学生用户仅可查看自己的信息。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 4.数据库:MySql 5.7/8.0版本均可; 5.是否Maven项目:是;
技术栈
后端:SpringBoot+Mybaits
前端:Html+css+easyui+h-ui
使用说明
项目运行: 1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入地址:http://localhost:8080/ 管理员账号、密码:admin/123456 教师账号、密码:张三/111 学生账号、密码:张三纷/123456
/**
* @Classname SystemController
* @Description None
*/
@Controller
@RequestMapping("/system")
public class SystemController {
@Autowired
private AdminService adminService;
@Autowired
private StudentService studentService;
@Autowired
private TeacherService teacherService;
/**
* 跳转登录界面
* @return
*/
@GetMapping("/login")
public String login(){
return "/login";
}
/**
* 登录表单提交 校验
* @return
*/
@PostMapping("/login")
@ResponseBody
public AjaxResult submitlogin(String username, String password, String code, String type,
HttpSession session){
AjaxResult ajaxResult = new AjaxResult();
if(StringUtils.isEmpty(username)){
//file.delete();
}
}
}
int count = teacherService.deleteTeacher(data.getIds());
if(count > 0){
ajaxResult.setSuccess(true);
ajaxResult.setMessage("删除成功");
}else{
ajaxResult.setSuccess(false);
ajaxResult.setMessage("删除失败");
}
}catch (Exception e){
e.printStackTrace();
ajaxResult.setSuccess(false);
ajaxResult.setMessage("删除失败");
}
return ajaxResult;
}
/**
* 添加教师
* @param files
* @param teacher
* @return
* @throws IOException
*/
@RequestMapping("/addTeacher")
@ResponseBody
public AjaxResult addTeacher(@RequestParam("file") MultipartFile[] files, Teacher teacher) throws IOException {
AjaxResult ajaxResult = new AjaxResult();
teacher.setSn(SnGenerateUtil.generateTeacherSn(teacher.getClazzId()));
// 存放上传图片的文件夹
File fileDir = UploadUtil.getImgDirFile();
for(MultipartFile fileImg : files){
// 拿到文件名
String extName = fileImg.getOriginalFilename().substring(fileImg.getOriginalFilename().lastIndexOf("."));
String uuidName = UUID.randomUUID().toString();
try {
// 构建真实的文件路径
File newFile = new File(fileDir.getAbsolutePath() + File.separator +uuidName+ extName);
// 上传图片到 -》 “绝对路径”
fileImg.transferTo(newFile);
//true为已签到
ajaxResult.setSuccess(false);
ajaxResult.setMessage("已录入,请勿重复录入!");
}else{
int count = scoreService.addScore(score);
if(count > 0){
//签到成功
ajaxResult.setSuccess(true);
ajaxResult.setMessage("录入成功");
}else{
ajaxResult.setSuccess(false);
ajaxResult.setMessage("系统错误,请重新录入");
}
}
return ajaxResult;
}
/**
* 修改学生成绩
* @param score
* @return
*/
@PostMapping("/editScore")
@ResponseBody
public AjaxResult editScore(Score score){
AjaxResult ajaxResult = new AjaxResult();
try {
int count = scoreService.editScore(score);
if(count > 0){
//签到成功
ajaxResult.setSuccess(true);
ajaxResult.setMessage("修改成功");
}else{
ajaxResult.setSuccess(false);
ajaxResult.setMessage("系统错误,请重新修改");
}
} catch (Exception e) {
e.printStackTrace();
ajaxResult.setSuccess(false);
ajaxResult.setMessage("系统错误,请重新修改");
}
return ajaxResult;
}
/**
* 删除学生成绩
* @param id
* @return
/**
* @Classname ScoreController
* @Description 成绩控制器
*/
@Controller
@RequestMapping("/score")
public class ScoreController {
@Autowired
private ScoreService scoreService;
@Autowired
private StudentService studentService;
@Autowired
}
} catch (Exception e) {
e.printStackTrace();
ajaxResult.setSuccess(false);
ajaxResult.setMessage("系统错误,请重新修改");
}
return ajaxResult;
}
/**
* 删除学生成绩
* @param id
* @return
*/
@PostMapping("/deleteScore")
@ResponseBody
public AjaxResult deleteScore(Integer id){
AjaxResult ajaxResult = new AjaxResult();
try {
int count = scoreService.deleteScore(id);
if(count > 0){
ajaxResult.setSuccess(true);
ajaxResult.setMessage("删除成功");
}else{
ajaxResult.setSuccess(false);
ajaxResult.setMessage("系统错误,请重新删除");
}
} catch (Exception e) {
e.printStackTrace();
ajaxResult.setSuccess(false);
ajaxResult.setMessage("系统错误,请重新删除");
}
return ajaxResult;
}
/**
* 导入xlsx表 并存入数据库
* @param importScore
* @param response
*/
//第1列
cell = row.getCell(1);
if(cell == null){
errorMsg += "第" + rowNum + "行课程缺失!\n";
continue;
}
//第2列
cell = row.getCell(2);
if(cell == null){
errorMsg += "第" + rowNum + "行成绩缺失!\n";
continue;
}
double scoreValue = cell.getNumericCellValue();
//第3列
cell = row.getCell(3);
String remark = null;
if(cell != null){
remark = cell.getStringCellValue();
}
//将学生,课程转换为id,存入数据库
// 1)首先获取对应的id
int studentId = studentService.findByName(row.getCell(0).getStringCellValue());
int courseId = courseService.findByName(row.getCell(1).getStringCellValue());
// 2)判断是否已存在数据库中
Score score = new Score();
score.setStudentId(studentId);
score.setCourseId(courseId);
score.setScore(scoreValue);
score.setRemark(remark);
if(!scoreService.isScore(score)){
// 3)存入数据库
int i = scoreService.addScore(score);
if(i > 0){
count ++ ;
}
}else{
errorMsg += "第" + rowNum + "行已录入,不重复录入!\n";
}
}
errorMsg += "成功录入" + count + "条成绩信息!";
response.getWriter().write("<div id='message'>"+errorMsg+"</div>");
} catch (IOException e) {
e.printStackTrace();
try {
response.getWriter().write("<div id='message'>上传错误</div>");
} catch (IOException ex) {
}
return ajaxResult;
}
@PostMapping("/deleteCourse")
@ResponseBody
public AjaxResult deleteCourse(Data data){
AjaxResult ajaxResult = new AjaxResult();
try {
int count = courseService.deleteCourse(data.getIds());
if(count > 0){
ajaxResult.setSuccess(true);
ajaxResult.setMessage("删除成功");
}else{
ajaxResult.setSuccess(false);
ajaxResult.setMessage("删除失败");
}
}catch (Exception e){
e.printStackTrace();
ajaxResult.setSuccess(false);
ajaxResult.setMessage("删除失败,该班级存在老师或学生");
}
return ajaxResult;
}
}
/**
* @Classname LoginInterceptor
* @Description 登录拦截器
*/
public class LoginInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
Admin user = (Admin)request.getSession().getAttribute(Const.ADMIN);
Teacher teacher = (Teacher)request.getSession().getAttribute(Const.TEACHER);
Student student = (Student)request.getSession().getAttribute(Const.STUDENT);
if(!StringUtils.isEmpty(user) || !StringUtils.isEmpty(teacher) || !StringUtils.isEmpty(student)){
return true;
}
/**
* @Classname CourseController
* @Description None
*/
@Controller
@RequestMapping("/course")
public class CourseController {
@Autowired
private CourseService courseService;
@GetMapping("/course_list")
public String courseList(){
return "course/courseList";
}
/**
* 异步加载课程信息列表
* @param page
* @param rows
* @param name
* @param teacherid
* @param from
* @return
*/
@PostMapping("/getCourseList")
@ResponseBody
public Object getClazzList(@RequestParam(value = "page", defaultValue = "1")Integer page,
@RequestParam(value = "rows", defaultValue = "100")Integer rows,
String name,
@RequestParam(value = "teacherid", defaultValue = "0")String teacherid ,String from){
Map<String,Object> paramMap = new HashMap();
paramMap.put("pageno",page);
paramMap.put("pagesize",rows);
if(!StringUtils.isEmpty(name)) paramMap.put("name",name);
if(!teacherid.equals("0")) paramMap.put("teacherId",teacherid);
}
/**
* 删除考勤签到
* @param id
* @return
*/
@PostMapping("/deleteAttendance")
@ResponseBody
public AjaxResult deleteAttendance(Integer id){
AjaxResult ajaxResult = new AjaxResult();
try {
int count = attendanceService.deleteAttendance(id);
if(count > 0){
ajaxResult.setSuccess(true);
ajaxResult.setMessage("删除成功");
}else{
ajaxResult.setSuccess(false);
ajaxResult.setMessage("删除失败");
}
} catch (Exception e) {
ajaxResult.setSuccess(false);
ajaxResult.setMessage("系统异常,请重试");
e.printStackTrace();
}
return ajaxResult;
}
}
}
/**
* 导入xlsx表 并存入数据库
* @param importScore
* @param response
*/
@PostMapping("/importScore")
@ResponseBody
public void importScore(@RequestParam("importScore") MultipartFile importScore, HttpServletResponse response){
response.setCharacterEncoding("UTF-8");
try {
InputStream inputStream = importScore.getInputStream();
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(inputStream);
XSSFSheet sheetAt = xssfWorkbook.getSheetAt(0);
int count = 0;
String errorMsg = "";
for(int rowNum = 1; rowNum <= sheetAt.getLastRowNum(); rowNum++){
XSSFRow row = sheetAt.getRow(rowNum); // 获取第rowNum行
//第0列
XSSFCell cell = row.getCell(0); // 获取第rowNum行的第0列 即坐标(rowNum,0)
if(cell == null){
errorMsg += "第" + rowNum + "行学生缺失!\n";
continue;
}
//第1列
cell = row.getCell(1);
if(cell == null){
errorMsg += "第" + rowNum + "行课程缺失!\n";
continue;
}
//第2列
cell = row.getCell(2);
if(cell == null){
errorMsg += "第" + rowNum + "行成绩缺失!\n";
continue;
}
double scoreValue = cell.getNumericCellValue();
//第3列
cell = row.getCell(3);
String remark = null;
if(cell != null){
remark = cell.getStringCellValue();
}
ajaxResult.setSuccess(true);
ajaxResult.setMessage("保存成功");
}else{
ajaxResult.setSuccess(false);
ajaxResult.setMessage("保存失败");
}
}catch (Exception e){
e.printStackTrace();
ajaxResult.setSuccess(false);
ajaxResult.setMessage("保存失败");
}
ajaxResult.setSuccess(true);
return ajaxResult;
}
@PostMapping("/editTeacher")
@ResponseBody
public AjaxResult editTeacher(@RequestParam("file") MultipartFile[] files,Teacher teacher){
AjaxResult ajaxResult = new AjaxResult();
// 存放上传图片的文件夹
File fileDir = UploadUtil.getImgDirFile();
for(MultipartFile fileImg : files){
String name = fileImg.getOriginalFilename();
if(name.equals("")){
break;
}
// 拿到文件名
String extName = fileImg.getOriginalFilename().substring(fileImg.getOriginalFilename().lastIndexOf("."));
String uuidName = UUID.randomUUID().toString();
try {
// 构建真实的文件路径
File newFile = new File(fileDir.getAbsolutePath() + File.separator +uuidName+ extName);
// 上传图片到 -》 “绝对路径”
fileImg.transferTo(newFile);
Teacher byId = teacherService.findById(teacher.getId());
File file = new File(fileDir.getAbsolutePath() + File.separator + byId.getPhoto());
if(file != null){
//file.delete();
}
ajaxResult.setSuccess(false);
ajaxResult.setMessage("系统错误,请重新删除");
}
return ajaxResult;
}
/**
* 导入xlsx表 并存入数据库
* @param importScore
* @param response
*/
@PostMapping("/importScore")
@ResponseBody
public void importScore(@RequestParam("importScore") MultipartFile importScore, HttpServletResponse response){
response.setCharacterEncoding("UTF-8");
try {
InputStream inputStream = importScore.getInputStream();
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(inputStream);
XSSFSheet sheetAt = xssfWorkbook.getSheetAt(0);
int count = 0;
String errorMsg = "";
for(int rowNum = 1; rowNum <= sheetAt.getLastRowNum(); rowNum++){
XSSFRow row = sheetAt.getRow(rowNum); // 获取第rowNum行
//第0列
XSSFCell cell = row.getCell(0); // 获取第rowNum行的第0列 即坐标(rowNum,0)
if(cell == null){
errorMsg += "第" + rowNum + "行学生缺失!\n";
continue;
}
//第1列
cell = row.getCell(1);
if(cell == null){
errorMsg += "第" + rowNum + "行课程缺失!\n";
continue;
}
//第2列
cell = row.getCell(2);
if(cell == null){
errorMsg += "第" + rowNum + "行成绩缺失!\n";
continue;
}
double scoreValue = cell.getNumericCellValue();
//第3列
cell = row.getCell(3);
String remark = null;
if(cell != null){
remark = cell.getStringCellValue();
ajaxResult.setSuccess(false);
ajaxResult.setMessage("已录入,请勿重复录入!");
}else{
int count = scoreService.addScore(score);
if(count > 0){
//签到成功
ajaxResult.setSuccess(true);
ajaxResult.setMessage("录入成功");
}else{
ajaxResult.setSuccess(false);
ajaxResult.setMessage("系统错误,请重新录入");
}
}
return ajaxResult;
}
/**
* 修改学生成绩
* @param score
* @return
*/
@PostMapping("/editScore")
@ResponseBody
public AjaxResult editScore(Score score){
AjaxResult ajaxResult = new AjaxResult();
try {
int count = scoreService.editScore(score);
if(count > 0){
//签到成功
ajaxResult.setSuccess(true);
ajaxResult.setMessage("修改成功");
}else{
ajaxResult.setSuccess(false);
ajaxResult.setMessage("系统错误,请重新修改");
}
} catch (Exception e) {
e.printStackTrace();
ajaxResult.setSuccess(false);
ajaxResult.setMessage("系统错误,请重新修改");
}
return ajaxResult;
}
/**
ajaxResult.setSuccess(false);
ajaxResult.setMessage("删除失败,该班级存在老师或学生");
}
return ajaxResult;
}
}
/**
* @Classname LoginInterceptor
* @Description 登录拦截器
*/
public class LoginInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
Admin user = (Admin)request.getSession().getAttribute(Const.ADMIN);
Teacher teacher = (Teacher)request.getSession().getAttribute(Const.TEACHER);
Student student = (Student)request.getSession().getAttribute(Const.STUDENT);
if(!StringUtils.isEmpty(user) || !StringUtils.isEmpty(teacher) || !StringUtils.isEmpty(student)){
return true;
}
response.sendRedirect(request.getContextPath() + "/system/login");
return false;
}
}
/**
* @Classname UserController
* @Description None
numberList.set(4, numberList.get(4)+1);
continue;
}
}
Map<String, Object> retMap = new HashMap<String, Object>();
retMap.put("courseName", courseName);
retMap.put("numberList", numberList);
retMap.put("rangeList", rangeStringList);
retMap.put("type", "success");
return retMap;
}
}
/**
* @Classname SystemController
* @Description None
*/
@Controller
@RequestMapping("/system")
public class SystemController {
@Autowired
private AdminService adminService;
@Autowired
private StudentService studentService;
student.setPhoto(uuidName+extName);
}
try{
int count = studentService.editStudent(student);
if(count > 0){
ajaxResult.setSuccess(true);
ajaxResult.setMessage("修改成功");
}else{
ajaxResult.setSuccess(false);
ajaxResult.setMessage("修改失败");
}
}catch(Exception e){
e.printStackTrace();
ajaxResult.setSuccess(false);
ajaxResult.setMessage("修改失败");
}
return ajaxResult;
}
}
/**
* @Classname TeacherController
* @Description None
*/
@Controller
@RequestMapping("/teacher")
public class TeacherController {
@Autowired
private TeacherService teacherService;
if(StringUtils.isEmpty(ad)){
ajaxResult.setSuccess(false);
ajaxResult.setMessage("用户名或密码错误");
return ajaxResult;
}
ajaxResult.setSuccess(true);
session.setAttribute(Const.ADMIN,ad);
session.setAttribute(Const.USERTYPE,"1");
break;
}
case "2":{
Student student = new Student();
student.setPassword(password);
student.setUsername(username);
Student st = studentService.findByStudent(student);
if(StringUtils.isEmpty(st)){
ajaxResult.setSuccess(false);
ajaxResult.setMessage("用户名或密码错误");
return ajaxResult;
}
ajaxResult.setSuccess(true);
session.setAttribute(Const.STUDENT,st);
session.setAttribute(Const.USERTYPE,"2");
break;
}
case "3":{
Teacher teacher = new Teacher();
teacher.setPassword(password);
teacher.setUsername(username);
Teacher tr = teacherService.findByTeacher(teacher);
if(StringUtils.isEmpty(tr)){
ajaxResult.setSuccess(false);
ajaxResult.setMessage("用户名或密码错误");
return ajaxResult;
}
ajaxResult.setSuccess(true);
session.setAttribute(Const.TEACHER,tr);
session.setAttribute(Const.USERTYPE,"3");
break;
}
}
return ajaxResult;
}
/**
* 显示 验证码
* @param request
* @param response
* @param vl
* @param w
* @param h
*/