基于javaweb+mysql的springboot微服务springcloud在线考试系统(java+springboot+springcloud+mysql+maven)

基于javaweb+mysql的springboot微服务springcloud在线考试系统(java+springboot+springcloud+mysql+maven)

运行环境

Java≥8、MySQL≥5.7

开发工具

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

适用

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

功能说明

基于javaweb+mysql的SpringBoot微服务SpringCloud在线考试系统(java+springboot+springcloud+mysql+maven)

考试流程:

用户前台注册成为学生

管理员后台添加老师,系统将该用户角色上升为老师

老师登录,添加考试,添加题目,发布考试

考生登录前台参加考试,交卷

老师后台批改试卷,查看成绩

考试查看成绩

练习流程:

考生登录前台参加练习,练习完自动判分,记录错题

考生查看成绩,查看错题

    @RequestMapping(value = "/{id}", method = RequestMethod.GET)

    @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")

    public Teacher getTeacherById(@PathVariable String id) {

        return teacherService.getTeacherById(id);

    }

    @ApiOperation(value = "获取教师班级信息", notes = "根据教师name获取班级详细信息")

    @ApiImplicitParam(name = "name", value = "教师name", required = true, dataType = "String", paramType = "path")

    @RequestMapping(value = "/name/grade/{name}", method = RequestMethod.GET)

    @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")

    public List<Grade> getGradeByTeacher(@PathVariable String name) {

        return teacherService.findGradeByName(name);

    }

    @ApiOperation(value = "获取教师学生信息", notes = "根据教师name获取学生详细信息")

    @ApiImplicitParam(name = "name", value = "教师name", required = true, dataType = "String", paramType = "path")

    @RequestMapping(value = "/name/student/{name}", method = RequestMethod.GET)

    @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")

    public List<Student> getStudentByTeacher(@PathVariable String name) {


@RequestMapping(value = "/v1/subjects")

public class SubjectController {

    private static Logger logger = LoggerFactory.getLogger(SubjectController.class);

        return pageInfo;

    }

    @ApiOperation(value = "新增教师", notes = "新增教师")

    @ApiImplicitParam(name = "teacher", value = "教师实体teacher", required = true, dataType = "Teacher")

    @RequestMapping(value = "", method = RequestMethod.POST)

    @PreAuthorize("hasAuthority('" + Role.ROLE_ADMIN + "')")

    public ResponseEntity<?> postTeacher(@RequestBody Teacher teacher) {

        /**

         * 1.已经注册


    @ApiOperation(value = "获取题目信息", notes = "根据题目name获取题目详细信息")

    @ApiImplicitParam(name = "name", value = "试卷name", required = true, dataType = "String", paramType = "path")

    @RequestMapping(value = "/name/{name}", method = RequestMethod.GET)

    @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')")

    public List<Question> getQuestionByName(@PathVariable String name) {

        //模糊查询

        return questionService.getQuestionFuzzy(name);

    }

    @ApiOperation(value = "获取题目信息", notes = "根据试卷id获取所有题目")

    @ApiImplicitParam(name = "paperId", value = "试卷ID", required = true, dataType = "String", paramType = "path")

    @RequestMapping(value = "/papers/{paperId}/questions", method = RequestMethod.GET)

    @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')")

    public List<Question> getQuestionByPaperId(@PathVariable String paperId) {

        return questionService.getQuestionByPaperId(paperId);

    }

    @ApiOperation(value = "获取题目信息", notes = "根据试卷id获取所有题目,但不返回答案")

    @ApiImplicitParam(name = "paperId", value = "试卷ID", required = true, dataType = "String", paramType = "path")

    @RequestMapping(value = "/papers/{paperId}/ignore", method = RequestMethod.GET)

    @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')")

    public List<Question> getQuestionByPaperIdIgnoreAnswer(@PathVariable String paperId) {

        return questionService.getQuestionByPaperIdIgnoreAnswer(paperId);

    }

        return questionService.getQuestionByPaperIdIgnoreAnswer(paperId);

    }

    @ApiOperation(value = "更新题目信息", notes = "根据题目id更新题目信息")

    @ApiImplicitParam(name = "question", value = "题目实体", required = true, dataType = "Question")

    @RequestMapping(value = "", method = RequestMethod.PUT)

    @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")

    public ResponseEntity<?> putQuestion(@RequestBody Question question) {

        questionService.updateQuestion(question);

        return new ResponseEntity(HttpStatus.OK);

    }

    @ApiOperation(value = "删除题目", notes = "根据题目id删除试卷")

    })

    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)

    @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")

    public ResponseEntity<?> putTeacher(@PathVariable String id, @RequestBody Teacher teacher) {

        teacherService.updateTeacher(teacher);

        return new ResponseEntity(HttpStatus.OK);

    }

/**

 */

@RestController

@RequestMapping(value = "/v1/subjects")

public class SubjectController {

    private static Logger logger = LoggerFactory.getLogger(SubjectController.class);

        return pageInfo;

    }

    @ApiOperation(value = "新增教师", notes = "新增教师")

    @ApiImplicitParam(name = "teacher", value = "教师实体teacher", required = true, dataType = "Teacher")

    @RequestMapping(value = "", method = RequestMethod.POST)

    @PreAuthorize("hasAuthority('" + Role.ROLE_ADMIN + "')")

    public ResponseEntity<?> postTeacher(@RequestBody Teacher teacher) {

        /**

         * 1.已经注册

         * 2.不能重复添加

         * 3.分配权限

         */

        MapperUser user = userService.getUserByName(teacher.getTeacherName());
        return questionService.getQuestionByPaperIdIgnoreAnswer(paperId);

    }

    @ApiOperation(value = "更新题目信息", notes = "根据题目id更新题目信息")

    @ApiImplicitParam(name = "question", value = "题目实体", required = true, dataType = "Question")

    @RequestMapping(value = "", method = RequestMethod.PUT)

    @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")

    public ResponseEntity<?> putQuestion(@RequestBody Question question) {

        questionService.updateQuestion(question);

        return new ResponseEntity(HttpStatus.OK);

    }

    @ApiOperation(value = "删除题目", notes = "根据题目id删除试卷")

    })

    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)

    @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")

    public ResponseEntity<?> putTeacher(@PathVariable String id, @RequestBody Teacher teacher) {

        teacherService.updateTeacher(teacher);

        return new ResponseEntity(HttpStatus.OK);

    }

                if(count == 0) {

                    //新记录

                    answerQuestion = new AnswerQuestion();

                    answerPaperQuestion = new AnswerPaperQuestion();

                    answerQuestion = new AnswerQuestion();

                    //初始化信息

                    answerQuestion.setId(answerQuestionId);

                    answerQuestion.setTitle(question.getTitle());

                    answerQuestion.setType(question.getType());

                    answerQuestion.setNumber(question.getNumber());

                    answerQuestion.setOptionA(question.getOptionA());

                                                      @PathVariable Integer number,

                                                      @RequestParam(required = false) String answerPaperId) {

        PaperAnswerPaper paperAnswerPaper = null;

        //传入的是答卷Id

        if(answerPaperId != null) {

            paperAnswerPaper = paperAnswerPaperService.getByAnswerPaperId(answerPaperId);

            if(paperAnswerPaper != null) {

                return questionService.getQuestionByPaperIdAndQuestionNumber(paperAnswerPaper.getPaperId(), number);

                    answerQuestion.setOptionA(question.getOptionA());

                                                      @PathVariable Integer number,

                                                      @RequestParam(required = false) String answerPaperId) {

        PaperAnswerPaper paperAnswerPaper = null;

        //传入的是答卷Id

        if(answerPaperId != null) {

            paperAnswerPaper = paperAnswerPaperService.getByAnswerPaperId(answerPaperId);

            if(paperAnswerPaper != null) {

                return questionService.getQuestionByPaperIdAndQuestionNumber(paperAnswerPaper.getPaperId(), number);

            }else {

                logger.error("根据答卷id获取答卷失败");

            }

        }

        return questionService.getQuestionByPaperIdAndQuestionNumber(paperId, number);

    }

    @ApiOperation(value = "获取题目信息", notes = "根据题目name获取题目详细信息")

                        existAnswerQuestion = question1;//保存当前存在的记录

                    }

                }

                //记录不存在

                if(count == 0) {

                    //新记录

                    answerQuestion = new AnswerQuestion();

                    answerPaperQuestion = new AnswerPaperQuestion();

                    answerQuestion = new AnswerQuestion();

                    //初始化信息

                    answerQuestion.setId(answerQuestionId);

                    answerQuestion.setTitle(question.getTitle());

                    answerQuestion.setType(question.getType());

                    answerQuestion.setNumber(question.getNumber());

                    answerQuestion.setOptionA(question.getOptionA());

                                                      @PathVariable Integer number,

                                                      @RequestParam(required = false) String answerPaperId) {

        PaperAnswerPaper paperAnswerPaper = null;

        //传入的是答卷Id

        if(answerPaperId != null) {

            paperAnswerPaper = paperAnswerPaperService.getByAnswerPaperId(answerPaperId);

            if(paperAnswerPaper != null) {

                return questionService.getQuestionByPaperIdAndQuestionNumber(paperAnswerPaper.getPaperId(), number);

            }else {

                logger.error("根据答卷id获取答卷失败");

            }

        }

        return questionService.getQuestionByPaperIdAndQuestionNumber(paperId, number);

    }

    @ApiOperation(value = "获取题目信息", notes = "根据题目name获取题目详细信息")

    @ApiImplicitParam(name = "name", value = "试卷name", required = true, dataType = "String", paramType = "path")

    @RequestMapping(value = "/name/{name}", method = RequestMethod.GET)

    @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')")

    public List<Question> getQuestionByName(@PathVariable String name) {

        //模糊查询

        return questionService.getQuestionFuzzy(name);

    }


    @ApiOperation(value = "新增教师", notes = "新增教师")

    @ApiImplicitParam(name = "teacher", value = "教师实体teacher", required = true, dataType = "Teacher")

    @RequestMapping(value = "", method = RequestMethod.POST)

    @PreAuthorize("hasAuthority('" + Role.ROLE_ADMIN + "')")

    public ResponseEntity<?> postTeacher(@RequestBody Teacher teacher) {

        /**

         * 1.已经注册

         * 2.不能重复添加

         * 3.分配权限

         */

        MapperUser user = userService.getUserByName(teacher.getTeacherName());

        if(user != null && teacherService.getTeacherByName(teacher.getTeacherName()) == null) {

            //绑定id

            teacher.setId(user.getId());

            teacherService.saveTeacher(teacher);

        }else {

            return new ResponseEntity(HttpStatus.BAD_REQUEST);

        }

        return new ResponseEntity(HttpStatus.CREATED);

                int count = 0;

                AnswerQuestion existAnswerQuestion = null;

                for(AnswerQuestion question1 : answerQuestions) {

                    if (question1.getNumber().equals(question.getNumber())) {

                        count++;

                        existAnswerQuestion = question1;//保存当前存在的记录

                    }

                }

                //记录不存在

                if(count == 0) {

                    //新记录

                    answerQuestion = new AnswerQuestion();

                    answerPaperQuestion = new AnswerPaperQuestion();

                    answerQuestion = new AnswerQuestion();

                    //初始化信息

                    answerQuestion.setId(answerQuestionId);

                    answerQuestion.setTitle(question.getTitle());

                    answerQuestion.setType(question.getType());


                                                      @PathVariable Integer number,

                                                      @RequestParam(required = false) String answerPaperId) {

        PaperAnswerPaper paperAnswerPaper = null;

        //传入的是答卷Id

        if(answerPaperId != null) {

            paperAnswerPaper = paperAnswerPaperService.getByAnswerPaperId(answerPaperId);

            if(paperAnswerPaper != null) {

                return questionService.getQuestionByPaperIdAndQuestionNumber(paperAnswerPaper.getPaperId(), number);

            }else {

                logger.error("根据答卷id获取答卷失败");

            }

        }

        return questionService.getQuestionByPaperIdAndQuestionNumber(paperId, number);

    }

    @ApiOperation(value = "获取题目信息", notes = "根据题目name获取题目详细信息")

    @ApiImplicitParam(name = "name", value = "试卷name", required = true, dataType = "String", paramType = "path")

    @RequestMapping(value = "/name/{name}", method = RequestMethod.GET)


                    if (question1.getNumber().equals(question.getNumber())) {

                        count++;

                        existAnswerQuestion = question1;//保存当前存在的记录

                    }

                }

                //记录不存在

                if(count == 0) {

                    //新记录

                    answerQuestion = new AnswerQuestion();

                    answerPaperQuestion = new AnswerPaperQuestion();

                    answerQuestion = new AnswerQuestion();

                    //初始化信息

                    answerQuestion.setId(answerQuestionId);

                    answerQuestion.setTitle(question.getTitle());

                    answerQuestion.setType(question.getType());

                    answerQuestion.setNumber(question.getNumber());

                    answerQuestion.setOptionA(question.getOptionA());


        return pageInfo;

    }

    @ApiOperation(value = "新增教师", notes = "新增教师")

    @ApiImplicitParam(name = "teacher", value = "教师实体teacher", required = true, dataType = "Teacher")

    @RequestMapping(value = "", method = RequestMethod.POST)

    @PreAuthorize("hasAuthority('" + Role.ROLE_ADMIN + "')")

    public ResponseEntity<?> postTeacher(@RequestBody Teacher teacher) {

        /**

         * 1.已经注册

         * 2.不能重复添加

         * 3.分配权限

         */

        MapperUser user = userService.getUserByName(teacher.getTeacherName());

        if(user != null && teacherService.getTeacherByName(teacher.getTeacherName()) == null) {

            //绑定id

            teacher.setId(user.getId());

            teacherService.saveTeacher(teacher);

        }else {

            return new ResponseEntity(HttpStatus.BAD_REQUEST);

        }

        return new ResponseEntity(HttpStatus.CREATED);

    }

    @ApiOperation(value = "根据名字获取教师信息", notes = "根据教师名字获取教师详细信息")
                        existAnswerQuestion = question1;//保存当前存在的记录

                    }

                }

                //记录不存在

                if(count == 0) {

                    //新记录

                    answerQuestion = new AnswerQuestion();

                    answerPaperQuestion = new AnswerPaperQuestion();

                    answerQuestion = new AnswerQuestion();

                    //初始化信息

                    answerQuestion.setId(answerQuestionId);

                    answerQuestion.setTitle(question.getTitle());

                    answerQuestion.setType(question.getType());

                    answerQuestion.setNumber(question.getNumber());

                    answerQuestion.setOptionA(question.getOptionA());


    @ApiOperation(value = "更新题目信息", notes = "根据题目id更新题目信息")

    @ApiImplicitParam(name = "question", value = "题目实体", required = true, dataType = "Question")

    @RequestMapping(value = "", method = RequestMethod.PUT)

    @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")

    public ResponseEntity<?> putQuestion(@RequestBody Question question) {

        questionService.updateQuestion(question);

        return new ResponseEntity(HttpStatus.OK);

    }

    @ApiOperation(value = "删除题目", notes = "根据题目id删除试卷")

    })

    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)

    @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')")

    public ResponseEntity<?> putTeacher(@PathVariable String id, @RequestBody Teacher teacher) {

        teacherService.updateTeacher(teacher);

        return new ResponseEntity(HttpStatus.OK);

    }


        return pageInfo;

    }

    @ApiOperation(value = "新增教师", notes = "新增教师")

    @ApiImplicitParam(name = "teacher", value = "教师实体teacher", required = true, dataType = "Teacher")

    @RequestMapping(value = "", method = RequestMethod.POST)

    @PreAuthorize("hasAuthority('" + Role.ROLE_ADMIN + "')")

    public ResponseEntity<?> postTeacher(@RequestBody Teacher teacher) {

        /**

         * 1.已经注册

         * 2.不能重复添加

         * 3.分配权限

         */

        MapperUser user = userService.getUserByName(teacher.getTeacherName());

        if(user != null && teacherService.getTeacherByName(teacher.getTeacherName()) == null) {

            //绑定id

            teacher.setId(user.getId());

            teacherService.saveTeacher(teacher);

        }else {

            return new ResponseEntity(HttpStatus.BAD_REQUEST);

        }

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值