基于javaweb+mysql的springboot学生成绩管理系统(java+springboot+maven+vue+elementui+redis+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot学生成绩管理系统(java+springboot+maven+vue+elementui+redis+mysql)
项目介绍
角色:管理员、教师、学生 角色权限管理RBAC、学院管理、专业管理、班级管理、教师管理、学生管理、学期管理、考试管理、课程管理、留言管理、教学安排、成绩管理、成绩图表分析、统计分析、成绩打印等
环境需要
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+mybatisplus+redis
前端:Vue+Ant Design Vue
使用说明
项目运行: 1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
登录页面展示:
系统主页展示:
统计信息展示:
计划成绩分析统计展示:
教学安排展示:
数学成绩分析展示:
考试计划成绩分析:
考试计划页面展示:
int messageCount = iMessageService.findCountByTeacherIdList(teacherIdList);
if (messageCount > 0) {
throw new FebsException("留言关联着老师,不能删除");
}
this.iTeacherService.deleteTeachers(ids);
} catch (Exception e) {
message = "删除教师失败";
log.error(message, e);
throw new FebsException(message);
}
}
/**
* 导出
*
* @param request
* @param teacher
* @param response
* @throws FebsException
*/
@PostMapping("excel")
@RequiresPermissions("people:teacher:export")
public void export(QueryRequest request, Teacher teacher, HttpServletResponse response) throws FebsException {
try {
List<Teacher> teachers = this.iTeacherService.findTeachers(request, teacher).getRecords();
ExcelKit.$Export(Teacher.class, response).downXlsx(teachers, false);
} catch (Exception e) {
message = "导出Excel失败";
log.error(message, e);
throw new FebsException(message);
}
}
/**
* 根据教师分析课程教学情况
*
* @param teacherId
*/
@GetMapping("/analysis/{teacherId}")
@RequiresPermissions("people:teacher:analysis")
public Map<String, Object> analysis(@PathVariable Long teacherId) {
/**
* 新增学院
*
* @param college
* @throws FebsException
*/
@Log("新增学院")
@PostMapping
@RequiresPermissions("organization:college:add")
public void addCollege(@RequestBody @Valid College college) throws FebsException {
try {
this.iCollegeService.insert(college);
} catch (Exception e) {
message = "新增学院失败";
log.error(message, e);
throw new FebsException(message);
}
}
/**
* 修改学院
*
* @param college
* @throws FebsException
*/
@Log("修改学院")
@PutMapping
@RequiresPermissions("organization:college:update")
public void updateCollege(@RequestBody @Valid College college) throws FebsException {
try {
this.iCollegeService.modify(college);
} catch (Exception e) {
message = "修改学院失败";
log.error(message, e);
throw new FebsException(message);
}
}
/**
* 删除学院
*
* @param collegeIds
* @throws FebsException
*/
@Log("删除学院")
/**
* 返回全部的学期信息
*
* @return
*/
@GetMapping("/all")
@RequiresUser
public List<Semester> allSemesterList() {
return iSemesterService.list();
}
/**
* 学期列表
*
* @param request
* @param semester
* @return
*/
@GetMapping
@RequiresPermissions("education:semester:view")
public Map<String, Object> semesterList(QueryRequest request, Semester semester) {
return getDataTable(this.iSemesterService.findSemesters(request, semester));
}
/**
* 新增学期
*
* @param semester
* @throws FebsException
*/
@Log("新增学期")
@PostMapping
@RequiresPermissions("education:semester:add")
public void addSemester(@RequestBody @Valid Semester semester) throws FebsException {
try {
this.iSemesterService.insert(semester);
} catch (Exception e) {
message = "新增学期失败";
log.error(message, e);
return new FebsResponse().addCodeMessage(Code.C200.getCode(),"认证成功",Code.C200.getDesc(),userInfo);
}
@GetMapping("index/{username}")
public FebsResponse index(@NotBlank(message = "{required}") @PathVariable String username) {
Map<String, Object> data = new HashMap<>();
// 获取系统访问记录
Long totalVisitCount = loginLogMapper.findTotalVisitCount();
data.put("totalVisitCount", totalVisitCount);
Long todayVisitCount = loginLogMapper.findTodayVisitCount();
data.put("todayVisitCount", todayVisitCount);
Long todayIp = loginLogMapper.findTodayIp();
data.put("todayIp", todayIp);
// 获取近期系统访问记录
List<Map<String, Object>> lastSevenVisitCount = loginLogMapper.findLastSevenDaysVisitCount(null);
data.put("lastSevenVisitCount", lastSevenVisitCount);
User param = new User();
param.setUsername(username);
List<Map<String, Object>> lastSevenUserVisitCount = loginLogMapper.findLastSevenDaysVisitCount(param);
data.put("lastSevenUserVisitCount", lastSevenUserVisitCount);
data.put("firstCount", iStudentScoreService.findDegreeCount(ScoreType.ONE.getCode()));
data.put("secondCount", iStudentScoreService.findDegreeCount(ScoreType.SECOND.getCode()));
data.put("thirdCount", iStudentScoreService.findDegreeCount(ScoreType.THIRD.getCode()));
data.put("fourCount", iStudentScoreService.findDegreeCount(ScoreType.FOUR.getCode()));
data.put("fiveCount", iStudentScoreService.findDegreeCount(ScoreType.FIVE.getCode()));
data.put("examCount", iStudentScoreService.count());
data.put("teacherCount", iTeacherService.count());
data.put("studentCount", iStudentService.count());
return new FebsResponse().data(data);
}
@RequiresPermissions("user:online")
@GetMapping("online")
public FebsResponse userOnline(String username) throws Exception {
String now = DateUtil.formatFullTime(LocalDateTime.now());
Set<String> userOnlineStringSet = redisService.zrangeByScore(FebsConstant.ACTIVE_USERS_ZSET_PREFIX, now, "+inf");
List<ActiveUser> activeUsers = new ArrayList<>();
for (String userOnlineString : userOnlineStringSet) {
ActiveUser activeUser = mapper.readValue(userOnlineString, ActiveUser.class);
activeUser.setToken(null);
if (StringUtils.isNotBlank(username)) {
if (StringUtils.equalsIgnoreCase(username, activeUser.getUsername())){
activeUsers.add(activeUser);
}
} else {
activeUsers.add(activeUser);
}
}
return new FebsResponse().data(activeUsers);
}
@DeleteMapping("kickout/{id}")
@RequiresPermissions("user:kickout")
public void addStudent(@RequestBody @Valid Student student) throws FebsException {
try {
User user = getCurrentUser();
student.setDeptId(user.getDeptId());
this.iStudentService.insert(student);
} catch (Exception e) {
message = "新增学生失败";
log.error(message, e);
throw new FebsException(message);
}
}
/**
* 修改学生
*
* @param student
* @throws FebsException
*/
@Log("修改学生")
@PutMapping
@RequiresPermissions("people:student:update")
public void updateStudent(@RequestBody @Valid Student student) throws FebsException {
try {
User user = getCurrentUser();
student.setDeptId(user.getDeptId());
this.iStudentService.modify(student);
} catch (Exception e) {
message = "修改学生失败";
log.error(message, e);
throw new FebsException(message);
}
}
/**
* 删除学生
*
* @param studentIds
* @throws FebsException
*/
@Log("删除学生")
@DeleteMapping("/{studentIds}")
@RequiresPermissions("people:student:delete")
public void deleteStudent(@NotBlank(message = "{required}") @PathVariable String studentIds) throws FebsException {
try {
String[] ids = studentIds.split(StringPool.COMMA);
@RestController
@RequestMapping("people/teacher")
public class TeacherController extends BaseController {
private String message;
@Autowired
private ITeacherService iTeacherService;
@Autowired
private IExamPlanService iExamPlanService;
@Autowired
private ITeachingArrangeService iTeachingArrangeService;
@Autowired
private IClazzService iClazzService;
@Autowired
private IMessageService iMessageService;
/**
* 返回全部的教师信息
*
* @return
*/
@GetMapping("/all")
@RequiresUser
public List<Teacher> allTeacherList() {
if (isStudent()) {
Set<Long> finalTeacherIdList = new HashSet<>();
Student student = getStudent();
Clazz clazz = iClazzService.getById(student.getClazzId());
finalTeacherIdList.add(clazz.getManagerId());
List<Long> teacherIdList = iTeachingArrangeService.findTeachIdListByClazzId(clazz.getClazzId());
if (CollectionUtils.isNotEmpty(teacherIdList)) {
finalTeacherIdList.addAll(teacherIdList);
}
return new ArrayList<>(iTeacherService.listByIds(teacherIdList));
}
return iTeacherService.list();
}
/**
* 教师列表
*
* @param request
* @param teacher
* @return
*/
@GetMapping
* @param response
* @throws FebsException
*/
@PostMapping("excel")
@RequiresPermissions("people:teacher:export")
public void export(QueryRequest request, Teacher teacher, HttpServletResponse response) throws FebsException {
try {
List<Teacher> teachers = this.iTeacherService.findTeachers(request, teacher).getRecords();
ExcelKit.$Export(Teacher.class, response).downXlsx(teachers, false);
} catch (Exception e) {
message = "导出Excel失败";
log.error(message, e);
throw new FebsException(message);
}
}
/**
* 根据教师分析课程教学情况
*
* @param teacherId
*/
@GetMapping("/analysis/{teacherId}")
@RequiresPermissions("people:teacher:analysis")
public Map<String, Object> analysis(@PathVariable Long teacherId) {
return iTeacherService.findTeacherAnalysisDetail(teacherId);
}
/**
* 根据登录用户是教师查询考试情况
*/
@GetMapping("/examInfo")
public Map<String, Object> examInfo(@RequestParam(required = false) Long teacherId) {
if (isTeacher()) {
Teacher teacher = getTeacher();
return iTeacherService.findTeacherDegreeCountMap(teacher.getTeacherId());
}
return iTeacherService.findTeacherDegreeCountMap(teacherId);
}
}
String[] ids = courseIds.split(StringPool.COMMA);
List<Long> courseIdList = Arrays.stream(ids).map(Long::valueOf).collect(Collectors.toList());
Integer teachingArrangeCount = iTeachingArrangeService.findCountByCourseIdList(courseIdList);
if (teachingArrangeCount > 0) {
throw new FebsException("教学安排关联了课程,不能删除");
}
Integer examPlanCount = iExamPlanService.findCountByCourseIdList(courseIdList);
if (examPlanCount > 0) {
throw new FebsException("考试计划关联了课程,不能删除");
}
this.iCourseService.deleteCourses(ids);
} catch (Exception e) {
message = "删除课程失败";
log.error(message, e);
throw new FebsException(message);
}
}
/**
* 导出
*
* @param request
* @param course
* @param response
* @throws FebsException
*/
@PostMapping("excel")
@RequiresPermissions("education:course:export")
public void export(QueryRequest request, Course course, HttpServletResponse response) throws FebsException {
try {
List<Course> courses = this.iCourseService.findCourses(request, course).getRecords();
ExcelKit.$Export(Course.class, response).downXlsx(courses, false);
} catch (Exception e) {
message = "导出Excel失败";
log.error(message, e);
throw new FebsException(message);
}
}
/**
* 新增考试计划
*
* @param examPlan
* @throws FebsException
*/
@Log("新增考试计划")
@PostMapping
@RequiresPermissions("education:examPlan:add")
public void addExamPlan(@RequestBody @Valid ExamPlan examPlan) throws Exception {
try {
this.iExamPlanService.insert(examPlan);
} catch (Exception e) {
if (e instanceof FebsException) {
throw e;
}
message = "新增考试计划失败";
log.error(message, e);
throw new FebsException(message);
}
}
/**
* 修改考试计划
*
* @param examPlan
* @throws FebsException
*/
@Log("修改考试计划")
@PutMapping
@RequiresPermissions("education:examPlan:update")
public void updateExamPlan(@RequestBody @Valid ExamPlan examPlan) throws Exception {
try {
this.iExamPlanService.modify(examPlan);
} catch (Exception e) {
if (e instanceof FebsException) {
throw e;
}
message = "修改考试计划失败";
log.error(message, e);
throw new FebsException(message);
}
}
/**
* 删除考试计划
*
* @param examPlanIds
* @throws FebsException
*/
@Log("删除考试计划")
@GetMapping("pause/{jobId}")
@RequiresPermissions("job:pause")
public void pauseJob(@NotBlank(message = "{required}") @PathVariable String jobId) throws FebsException {
try {
this.jobService.pause(jobId);
} catch (Exception e) {
message = "暂停定时任务失败";
log.error(message, e);
throw new FebsException(message);
}
}
@Log("恢复定时任务")
@GetMapping("resume/{jobId}")
@RequiresPermissions("job:resume")
public void resumeJob(@NotBlank(message = "{required}") @PathVariable String jobId) throws FebsException {
try {
this.jobService.resume(jobId);
} catch (Exception e) {
message = "恢复定时任务失败";
log.error(message, e);
throw new FebsException(message);
}
}
@PostMapping("excel")
@RequiresPermissions("job:export")
public void export(QueryRequest request, Job job, HttpServletResponse response) throws FebsException {
try {
List<Job> jobs = this.jobService.findJobs(request, job).getRecords();
ExcelKit.$Export(Job.class, response).downXlsx(jobs, false);
} catch (Exception e) {
message = "导出Excel失败";
log.error(message, e);
throw new FebsException(message);
}
}
}
@GetMapping
@RequiresPermissions("education:course:view")
public Map<String, Object> courseList(QueryRequest request, Course course) {
IPage<Course> iPage = this.iCourseService.findCourses(request, course);
List<Course> courseList = iPage.getRecords();
if (CollectionUtils.isNotEmpty(courseList)) {
courseList.forEach(obj -> {
Integer teachingArrangeCount = iTeachingArrangeService.findCountByCourseId(obj.getCourseId());
if (teachingArrangeCount != null) {
obj.setTeachingArrangeCount(teachingArrangeCount);
}
List<Long> userIdList = iTeachingArrangeService.findTeachIdListByCourseId(obj.getCourseId());
if (CollectionUtils.isNotEmpty(userIdList)) {
obj.setTeacherCount(userIdList.size());
}
});
}
return getDataTable(iPage);
}
/**
* 新增课程
*
* @param course
* @throws FebsException
*/
@Log("新增课程")
@PostMapping
@RequiresPermissions("education:course:add")
public void addCourse(@RequestBody @Valid Course course) throws FebsException {
try {
this.iCourseService.insert(course);
} catch (Exception e) {
message = "新增课程失败";
log.error(message, e);
throw new FebsException(message);
}
}
/**
* 修改课程
*
* @param course
* @throws FebsException
/**
*/
@Slf4j
@Validated
@RestController
public class LoginController {
@Autowired
private RedisService redisService;
@Autowired
private UserManager userManager;
@Autowired
private UserService userService;
@Autowired
private LoginLogService loginLogService;
@Autowired
private LoginLogMapper loginLogMapper;
@Autowired
private FebsProperties properties;
@Autowired
private ObjectMapper mapper;
@Slf4j
@Validated
@RestController
@RequestMapping("role")
public class RoleController extends BaseController {
@Autowired
private RoleService roleService;
@Autowired
private RoleMenuServie roleMenuServie;
private String message;
@GetMapping
@RequiresPermissions("role:view")
public Map<String, Object> roleList(QueryRequest queryRequest, Role role) {
return getDataTable(roleService.findRoles(role, queryRequest));
}
@GetMapping("check/{roleName}")
public boolean checkRoleName(@NotBlank(message = "{required}") @PathVariable String roleName) {
Role result = this.roleService.findByName(roleName);
return result == null;
}
@GetMapping("menu/{roleId}")
public List<String> getRoleMenus(@NotBlank(message = "{required}") @PathVariable String roleId) {
List<RoleMenu> list = this.roleMenuServie.getRoleMenusByRoleId(roleId);
return list.stream().map(roleMenu -> String.valueOf(roleMenu.getMenuId())).collect(Collectors.toList());
}
@Log("新增角色")
@PostMapping
@RequiresPermissions("role:add")
public FebsResponse addRole(@RequestBody @Valid Role role) throws FebsException {
try {
this.roleService.createRole(role);
return new FebsResponse().code("200").message("新增角色成功").status("success");
} catch (Exception e) {
message = "新增角色失败";
log.error(message, e);
throw new FebsException(message);
@Log("执行定时任务")
@GetMapping("run/{jobId}")
@RequiresPermissions("job:run")
public void runJob(@NotBlank(message = "{required}") @PathVariable String jobId) throws FebsException {
try {
this.jobService.run(jobId);
} catch (Exception e) {
message = "执行定时任务失败";
log.error(message, e);
throw new FebsException(message);
}
}
@Log("暂停定时任务")
@GetMapping("pause/{jobId}")
@RequiresPermissions("job:pause")
public void pauseJob(@NotBlank(message = "{required}") @PathVariable String jobId) throws FebsException {
try {
this.jobService.pause(jobId);
} catch (Exception e) {
message = "暂停定时任务失败";
log.error(message, e);
throw new FebsException(message);
}
}
@Log("恢复定时任务")
@GetMapping("resume/{jobId}")
@RequiresPermissions("job:resume")
public void resumeJob(@NotBlank(message = "{required}") @PathVariable String jobId) throws FebsException {
try {
this.jobService.resume(jobId);
} catch (Exception e) {
message = "恢复定时任务失败";
log.error(message, e);
throw new FebsException(message);
}
}
@PostMapping("excel")
@RequiresPermissions("job:export")
* @param clazz
* @param response
* @throws FebsException
*/
@PostMapping("excel")
@RequiresPermissions("organization:clazz:export")
public void export(QueryRequest request, Clazz clazz, HttpServletResponse response) throws FebsException {
try {
List<Clazz> clazzList = this.iClazzService.findClazzPage(request, clazz).getRecords();
ExcelKit.$Export(Clazz.class, response).downXlsx(clazzList, false);
} catch (Exception e) {
message = "导出Excel失败";
log.error(message, e);
throw new FebsException(message);
}
}
/**
* 构造年级和学院树
*
* @return
*/
@GetMapping("/tree")
@RequiresUser
public List<SchoolTree> organizationTreeList() {
return iClazzService.buildOrganizationTreeList(true);
}
/**
* 根据班级分析课程教学情况
*
* @param clazzId
*/
@GetMapping("/analysis/{clazzId}")
@RequiresPermissions("organization:clazz:analysis")
public Map<String, Object> analysis(@PathVariable Long clazzId) {
return iClazzService.findClazzAnalysisDetail(clazzId);
}
}
/**
*/
@Slf4j
@Validated
@RestController
@RequestMapping("education/course")
public class CourseController extends BaseController {
return new FebsResponse().code("200").message("删除城市成功").status("success");
} catch (Exception e) {
message = "删除城市失败";
log.error(message, e);
throw new FebsException(message);
}
}
@Log("修改城市")
@PutMapping
@RequiresPermissions("city:update")
public FebsResponse updateDict(@RequestBody @Valid City city) throws FebsException {
try {
this.cityService.updateCity(city);
return new FebsResponse().code("200").message("修改城市成功").status("success");
} catch (Exception e) {
message = "修改城市失败";
log.error(message, e);
throw new FebsException(message);
}
}
@PostMapping("excel")
@RequiresPermissions("city:export")
public void export(QueryRequest request,String cityIds,@RequestBody City city, HttpServletResponse response) throws FebsException {
try {
List<City> citys;
if(StringUtils.isNotBlank(cityIds)){
String [] idsArrs=cityIds.split(",");
List list=new ArrayList();
for (String string : idsArrs) {
list.add(string);
}
citys = this.cityService.selectListByIds(list);
}else{
citys = this.cityService.findCityList(request, city);
}
ExcelKit.$Export(City.class, response).downXlsx(citys, false);
} catch (Exception e) {
message = "导出Excel失败";
log.error(message, e);
throw new FebsException(message);
return getDataTable(this.iExamService.findExams(request, exam));
}
/**
* 新增考试
*
* @param exam
* @throws FebsException
*/
@Log("新增考试")
@PostMapping
@RequiresPermissions("education:exam:add")
public void addExam(@RequestBody @Valid Exam exam) throws FebsException {
try {
int count = iExamService.findCountExamByDefault();
if (count > 0 && exam.getExamType().equals("1")) {
throw new FebsException("默认的考试只能设置一个");
}
this.iExamService.insert(exam);
} catch (Exception e) {
message = "新增考试失败";
log.error(message, e);
throw new FebsException(message);
}
}
/**
* 修改考试
*
* @param exam
* @throws FebsException
*/
@Log("修改考试")
@PutMapping
@RequiresPermissions("education:exam:update")
public void updateExam(@RequestBody @Valid Exam exam) throws FebsException {
try {
int count = iExamService.findCountExamByDefaultUnless(exam.getExamId());
if (count > 0 && exam.getExamType().equals("1")) {
throw new FebsException("默认的考试只能设置一个");