基于javaweb的SSH课程资源管理+在线考试平台(java+ssh+mysql+tomcat)

基于javaweb的SSH课程资源管理+在线考试平台(java+ssh+mysql+tomcat)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

20220519001024

20220519001025

20220519001026

20220519001027

20220519001028

基于javaweb+ssh的课程资源管理在线考试平台(java+SSH+mysql+maven+tomcat)

一、项目简述

功能包括: 管理员可以增删改查教材、教材商、入库教材、用户(用 户包括学生和教师)可以对教材商、教材进行。xcel的导入 导出操作。教师可以领取入库的教材,可以退还教材。学 生只能在对应的教师那里领取教材,并且可以退还教材、 查询自己已经领取的教材。并且对已领教材付款等等。

二、项目运行

环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)

项目技术: JSP +Struts+Spring+Hibernate + html+ css + JavaScript + JQuery + Ajax等等。

登录控制层:

@RestController

public class LoginController {

@Resource(name = “loginService”)

private ILoginService loginService;

/**

  • 用户登录调用 在登陆成功生成两个token 同时返回各自首页

    • 学生 student/student
    • 老师 teacher/teacher
    • 管理员 admin/admin

*/

@RequestMapping(value = “/login/login”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

public Result login(HttpRequest request) {

return loginService.login(request.getString(“login_name”), request.getString(“pwd”));

/**

  • 登录检查

*/

@RequestMapping(value = “/login/check”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

public Result check() {

return new Result<>();

/**

  • token 续约

*/

@RequestMapping(value = “/login/refresh”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

public Result refresh(HttpRequest request) {

String refreshToken = request.getString(“refresh_token”);

String urlId = request.getString(“url_id”);

Token token = TokenCache.getInstance().get(urlId);

if(token == null){

ExceptionHelper.error(ErrorCode.ERROR_CODE_0003);

try {

Claims claims = TokenUtils.parseToken(refreshToken);

if (StringUtils.isNotEmpty((String.valueOf(claims.getOrDefault(“student_id”, “”))))) {

claims.put(“student_id”, SessionContext.get(“student_id”));

if (StringUtils.isNotEmpty((String.valueOf(claims.getOrDefault(“teacher_id”, “”))))) {

claims.put(“teacher_id”, SessionContext.get(“teacher_id”));

if (StringUtils.isNotEmpty((String.valueOf(claims.getOrDefault(“login_name”, “”))))) {

claims.put(“login_name”, SessionContext.get(“login_name”));

claims.put(“name”, claims.get(“name”));

token.setToken(TokenUtils.createToken(claims, TokenUtils.expireTime));

token.setRefreshToken(TokenUtils.createToken(claims, TokenUtils.long_expireTime));

TokenCache.getInstance().add(token);

} catch (Exception e) {

ExceptionHelper.error(ErrorCode.ERROR_CODE_0003);

return new Result<>(token);

/**

  • 退出系统

*/

@RequestMapping(value = “/login/exit”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

public Result exit(HttpRequest request) {

String urlId = request.getString(“url_id”);

if (StringUtils.isNotEmpty(urlId)) {

TokenCache.getInstance().remove(urlId);

return new Result<>();

考试管理控制器:

/**

  • 考试管理控制器

*/

@RestController

public class ExamInfoController {

@Resource(name = “examInfoService”)

private IExamInfoService examInfoService;

/**

  • 教师 查询考试列表

*/

@RequestMapping(value = “/examinfo/qryPage”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

@RoleAnnotation(types = {RoleEnum.teacher})

public ListResult exam(HttpRequest request) {

Map<String, Object> param = new HashMap<>();

int pageNo = request.containsKey(“page_no”) ? request.getInteger(“page_no”) : 1;

int pageSize = request.containsKey(“page_size”) ? request.getInteger(“page_size”) : 20;

return examInfoService.qryPage(param, pageNo, pageSize);

/**

  • 教师 添加新的考试信息

*/

@RequestMapping(value = “/examinfo/add”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

@RoleAnnotation(types = {RoleEnum.teacher})

public Result insert(HttpRequest request) {

ExamInfo exam = new ExamInfo();

exam.setTestPaperId(request.getInteger(“test_paper_id”));

exam.setClassId(request.getString(“class_id”));

exam.setState(1);

exam.setTime(request.getInteger(“time”));

exam.setEffTime(DateUtils.toDate(request.getString(“eff_time”), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));

exam.setExpTime(DateUtils.toDate(request.getString(“exp_time”), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));

exam.setUpdateTime(new Date());

return examInfoService.insert(exam);

/**

  • 教师 更新考试信息

*/

@RequestMapping(value = “/examinfo/update”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

@RoleAnnotation(types = {RoleEnum.teacher})

public Result update(HttpRequest request) {

ExamInfo exam = new ExamInfo();

exam.setExamId(request.getInteger(“exam_id”));

exam.setTestPaperId(request.getInteger(“test_paper_id”));

exam.setClassId(request.getString(“class_id”));

exam.setState(1);

exam.setTime(request.getInteger(“time”));

exam.setEffTime(DateUtils.toDate(request.getString(“eff_time”), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));

exam.setExpTime(DateUtils.toDate(request.getString(“exp_time”), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI));

exam.setUpdateTime(new Date());

exam.setUpdateTime(new Date());

return examInfoService.update(exam);

/**

  • 教师 新建状态的考试信息可以删除

*/

@RequestMapping(value = “/examinfo/del”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

@RoleAnnotation(types = {RoleEnum.teacher})

public Result del(HttpRequest request) {

List examIdList = new ArrayList<>();

JSONArray array = request.getJSONArray(“exam_id_list”);

for (int i = 0; i < array.size(); i++) {

examIdList.add(array.getInteger(i));

return examInfoService.del(examIdList);

/**

  • 教师 发布考试信息

*/

@RequestMapping(value = “/examinfo/release”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

@RoleAnnotation(types = {RoleEnum.teacher})

public Result updateState(HttpRequest request) {

return examInfoService.release(request.getInteger(“exam_id”));

/**

  • 学生 查询考试试题分组列表

*/

@RequestMapping(value = “/examinfo/qryExamQueGroupList”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

@RoleAnnotation(types = {RoleEnum.student, RoleEnum.teacher})

public Result qryExamQueGroupList(HttpRequest request) {

return examInfoService.qryExamQueGroupList(request.getInteger(“exam_id”));

/**

  • 学生 查询考试试题列表

*/

@RequestMapping(value = “/examinfo/qryExamQuestionList”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

@RoleAnnotation(types = {RoleEnum.student})

public Result qryExamQuestionList(HttpRequest request) {

return examInfoService.qryExamQuestionList(request.getInteger(“exam_id”), request.getString(“student_id”), request.getInteger(“question_group_id”));

/**

  • 教师 判卷查询试题列表

*/

@RequestMapping(value = “/examinfo/qryMarkQueList”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

@RoleAnnotation(types = {RoleEnum.teacher})

public Result qryMarkQueList(HttpRequest request) {

return examInfoService.qryMarkQueList(request.getInteger(“exam_id”), request.getString(“student_id”), request.getInteger(“question_group_id”));

/**

  • 教师 记录学生考试分数 complete

*/

@RequestMapping(value = “/examinfo/updateQueScore”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

@RoleAnnotation(types = {RoleEnum.teacher})

public Result updateQueScore(HttpRequest request) {

StudentExamQuestionRecord record = new StudentExamQuestionRecord();

record.setExamId(request.getInteger(“exam_id”));

record.setStudentId(request.getString(“student_id”));

record.setQuestionGroupId(request.getInteger(“question_group_id”));

record.setQuestionId(request.getLong(“question_id”));

record.setScore(request.getFloat(“score”));

record.setCorrect(request.getBoolean(“correct”));

return examInfoService.updateQueScore(record);

/**

  • 教师 完成评分

*/

@RequestMapping(value = “/examinfo/complete”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

@RoleAnnotation(types = {RoleEnum.teacher})

public Result complete(HttpRequest request) {

return examInfoService.complete(request.getInteger(“exam_id”),

request.getString(“student_id”));

院系管理控制器:

/**

  • 院系管理控制器

*/

@RestController

public class DepartmentController {

@Resource(name = “departmentService”)

private IDepartmentService departmentService;

/**

  • 查询所有院系

*/

@RequestMapping(value = “/department/qryAllList”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

@RoleAnnotation(types = {RoleEnum.admin})

public ListResult qryAllList() {

return departmentService.qryAllList();

/**

  • 管理员 查询院系列表

*/

@RequestMapping(value = “/department/qryPage”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

@RoleAnnotation(types = {RoleEnum.admin})

public ListResult qryPage(HttpRequest request) {

Map<String, Object> param = new HashMap<>();

int pageNo = request.containsKey(“page_no”) ? request.getInteger(“page_no”) : 1;

int pageSize = request.containsKey(“page_size”) ? request.getInteger(“page_size”) : 20;

if (request.containsKey(“department_id”)) {

param.put(“department_id”, request.getString(“department_id”));

if (request.containsKey(“department_name”)) {

param.put(“department_name”, request.getString(“department_name”));

return departmentService.qryPage(param, pageNo, pageSize);

/**

  • 管理员 添加院系

*/

@RequestMapping(value = “/department/add”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

@RoleAnnotation(types = {RoleEnum.admin})

public Result insert(HttpRequest request) {

Department department = new Department();

department.setDepartmentId(request.getString(“department_id”));

department.setDepartmentName(request.getString(“department_name”));

department.setUpdateTime(new Date());

return departmentService.insert(department);

/**

  • 管理员 更新院系

*/

@RequestMapping(value = “/department/update”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

@RoleAnnotation(types = {RoleEnum.admin})

public Result update(HttpRequest request) {

Department department = new Department();

department.setDepartmentId(request.getString(“department_id”));

department.setDepartmentName(request.getString(“department_name”));

department.setUpdateTime(new Date());

return departmentService.update(department);

/**

  • 管理员 删除院系

*/

@RequestMapping(value = “/department/del”, method = RequestMethod.POST, produces = {“application/json;charset=UTF-8”})

@RoleAnnotation(types = {RoleEnum.admin})

public Result del(HttpRequest request) {

List departmentIdList = new ArrayList<>();

JSONArray array = request.getJSONArray(“department_id_list”);

for (int i = 0; i < array.size(); i++) {

departmentIdList.add(array.getString(i));

return departmentService.del(departmentIdList);


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值