👉文末查看项目功能视频演示+获取源码+sql脚本+视频导入教程视频
1 、功能描述
基于springboot的学生选课管理系统11拥有三种角色
管理员:学生教师管理、课程管理、成绩查询、选课管理、作业查询、公告管理等
教师:发布课程、审核选课、登记成绩、发布作业等
学生:选课、查看成绩和课程、提交作业等
1.1 背景描述
学生选课管理系统是为了解决学校在学生选课过程中存在的信息管理困难和选课流程繁琐的问题而设计的一种软件系统。传统的选课方式往往依赖学生手工填表和教务人员人工处理,容易出现选课冲突、信息错误以及选课结果难以跟踪等问题。而选课管理系统的出现能够有效地解决这些问题。该系统提供了课程管理、学生管理、选课管理、成绩管理等功能,可以实时记录和管理学生的选课情况,方便学校工作人员进行教务安排和学生查询。同时,系统还能够帮助学校进行课程资源管理和成绩统计,提高了学校教务办公效率。采用选课管理系统可以提供更好的选课体验,简化选课流程,为学生提供更便捷、高效的选课服务,优化学校的教务管理。
2、项目技术
后端框架:springboot、Mybatis
前端技术:VUE、html
2.1 springboot
Spring Boot是由Pivotal团队提供的基于Spring的框架,该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。Spring Boot集成了绝大部分目前流行的开发框架,就像Maven集成了所有的JAR包一样,Spring Boot集成了几乎所有的框架,使得开发者能快速搭建Spring项目。
2.2 mysql
MySQL是一款Relational Database Management System,直译过来的意思就是关系型数据库管理系统,MySQL有着它独特的特点,这些特点使他成为目前最流行的RDBMS之一,MySQL想比与其他数据库如ORACLE、DB2等,它属于一款体积小、速度快的数据库,重点是它符合本次毕业设计的真实租赁环境,拥有成本低,开发源码这些特点,这也是选择它的主要原因。
3、开发环境
- JAVA版本:JDK1.8(最佳)
- IDE类型:IDEA、Eclipse都可运行
- 数据库类型:MySql(5.7、8.x版本都可)
- tomcat版本:Tomcat 7-10版本均可
- maven版本:无限制
- 硬件环境:Windows
4、功能截图+视频演示+文档目录
4.1 登录
4.2 管理员模块
4.3 学生模块
4.4 教师模块
5 、核心代码实现
5.1 配置代码
server:
tomcat:
uri-encoding: UTF-8
port: 8080
servlet:
context-path: /springbootwxjjv
spring:
datasource:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/springbootwxjjv?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
username: root
password: root
servlet:
multipart:
max-file-size: 300MB
max-request-size: 300MB
resources:
static-locations: classpath:static/,file:static/
mybatis-plus:
mapper-locations: classpath*:mapper/*.xml
typeAliasesPackage: com.entity
global-config:
id-type: 1
field-strategy: 1
db-column-underline: true
refresh-mapper: true
logic-delete-value: -1
logic-not-delete-value: 0
sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
5.2 其它核心代码
package com.interceptor;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.http.HttpStatus;
import com.annotation.IgnoreAuth;
import com.entity.EIException;
import com.entity.TokenEntity;
import com.service.TokenService;
import com.utils.R;
/**
* 权限(Token)验证
*/
@Component
public class AuthorizationInterceptor implements HandlerInterceptor {
public static final String LOGIN_TOKEN_KEY = "Token";
@Autowired
private TokenService tokenService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//支持跨域请求
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Headers", "x-requested-with,request-source,Token, Origin,imgType, Content-Type, cache-control,postman-token,Cookie, Accept,authorization");
response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
// 跨域时会首先发送一个OPTIONS请求,这里我们给OPTIONS请求直接返回正常状态
if (request.getMethod().equals(RequestMethod.OPTIONS.name())) {
response.setStatus(HttpStatus.OK.value());
return false;
}
IgnoreAuth annotation;
if (handler instanceof HandlerMethod) {
annotation = ((HandlerMethod) handler).getMethodAnnotation(IgnoreAuth.class);
} else {
return true;
}
//从header中获取token
String token = request.getHeader(LOGIN_TOKEN_KEY);
/**
* 不需要验证权限的方法直接放过
*/
if(annotation!=null) {
return true;
}
TokenEntity tokenEntity = null;
if(StringUtils.isNotBlank(token)) {
tokenEntity = tokenService.getTokenEntity(token);
}
if(tokenEntity != null) {
request.getSession().setAttribute("userId", tokenEntity.getUserid());
request.getSession().setAttribute("role", tokenEntity.getRole());
request.getSession().setAttribute("tableName", tokenEntity.getTablename());
request.getSession().setAttribute("username", tokenEntity.getUsername());
return true;
}
PrintWriter writer = null;
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json; charset=utf-8");
try {
writer = response.getWriter();
writer.print(JSONObject.toJSONString(R.error(401, "请先登录")));
} finally {
if(writer != null){
writer.close();
}
}
// throw new EIException("请先登录", 401);
return false;
}
}