基于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)

考试流程:

用户前台注册成为学生

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

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

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

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

考试查看成绩

练习流程:

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

考生查看成绩,查看错题

        } else {

            answerQuestions = answerQuestionService.findByAnswerPaperId(answerPaper.getId());

            if(answerQuestions != null && answerQuestions.size() > 0) {

                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());

                    answerQuestion.setNumber(question.getNumber());

                    answerQuestion.setOptionA(question.getOptionA());

                    //初始化信息

                    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获取答卷失败");

            }


/**

 */

@RestController

@RequestMapping("/v1/students")

public class StudentController {

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

    @Autowired

    StudentService studentService;

    @Autowired

    UserService userService;

    @ApiOperation(value = "获取学生列表", notes = "")

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

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


    }

    @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) {

/**

 */

@RestController

@RequestMapping("/v1/students")

public class StudentController {

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

    @Autowired

    StudentService studentService;
            answerPaperQuestion = new AnswerPaperQuestion();

            answerPaperQuestion.setAnswerPaperId(answerPaper.getId());

            answerPaperQuestion.setAnswerQuestionId(answerQuestionId);

            //保存

            answerQuestionService.saveAnswerQuestion(answerQuestion);

            answerPaperQuestionService.saveAnswerPaperQuestion(answerPaperQuestion);

            return new ResponseEntity<Object>(answerPaper, HttpStatus.OK);

        } else {

            answerQuestions = answerQuestionService.findByAnswerPaperId(answerPaper.getId());

            if(answerQuestions != null && answerQuestions.size() > 0) {

                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();

                }

                //记录不存在

                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) {


    @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) {


/**

 */

@RestController

@RequestMapping("/v1/students")

public class StudentController {

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

    @Autowired

    StudentService studentService;

    @Autowired

    UserService userService;

    @ApiOperation(value = "获取学生列表", notes = "")

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

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

    public PageInfo<Student> getStudentList(@RequestBody DtoPage page) {
    @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) {

/**

 */

@RestController

@RequestMapping("/v1/students")

public class StudentController {

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

    @Autowired

    StudentService studentService;

    @Autowired

    UserService userService;

    @ApiOperation(value = "获取学生列表", notes = "")

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

        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 = "根据教师名字获取教师详细信息")

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

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

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

    public List<Teacher> getTeacherByName(@PathVariable String name) {

        return teacherService.getTeacherFuzzy(name);

    }

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

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


            return new ResponseEntity(HttpStatus.BAD_REQUEST);

        }

        return new ResponseEntity(HttpStatus.CREATED);

    }

    @ApiOperation(value = "根据名字获取教师信息", notes = "根据教师名字获取教师详细信息")

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

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

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

    public List<Teacher> getTeacherByName(@PathVariable String name) {

        return teacherService.getTeacherFuzzy(name);

    }

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

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

    @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获取班级详细信息")

        List<Student> students = studentService.getStudentList();

        PageInfo pageInfo = new PageInfo(students);

        return pageInfo;

    }

    @ApiOperation(value = "根据老师信息获取学生列表", notes = "根据老师信息获取学生列表")

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

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

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

    public PageInfo<Student> getStudentListByTeacher(@PathVariable String name,

                                                     @RequestParam(required = false) Integer pageIndex,

                                                     @RequestParam(required = false) Integer pageSize,

                                                     @RequestParam(required = false) Integer limit,

                                                     @RequestParam(required = false) Integer offset) {

        if(pageIndex != null && pageSize != null) {

            PageHelper.startPage(pageIndex, pageSize);

        }

        List<Student> students = studentService.findStudentListByTeacher(name);

        PageInfo pageInfo = new PageInfo(students);

        return pageInfo;

        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);

            teacherService.saveTeacher(teacher);

        }else {

            return new ResponseEntity(HttpStatus.BAD_REQUEST);

        }

        return new ResponseEntity(HttpStatus.CREATED);

    }

    @ApiOperation(value = "根据名字获取教师信息", notes = "根据教师名字获取教师详细信息")

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

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

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

    public List<Teacher> getTeacherByName(@PathVariable String name) {

        return teacherService.getTeacherFuzzy(name);

    }

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

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

    @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)
        if(page.getPageIndex() != null && page.getPageSize() != null) {

            PageHelper.startPage(page.getPageIndex(), page.getPageSize());

        }

        List<Student> students = studentService.getStudentList();

        PageInfo pageInfo = new PageInfo(students);

        return pageInfo;

    }

    @ApiOperation(value = "根据老师信息获取学生列表", notes = "根据老师信息获取学生列表")

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

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

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

    public PageInfo<Student> getStudentListByTeacher(@PathVariable String name,

                                                     @RequestParam(required = false) Integer pageIndex,

                                                     @RequestParam(required = false) Integer pageSize,

                                                     @RequestParam(required = false) Integer limit,

                                                     @RequestParam(required = false) Integer offset) {

        if(pageIndex != null && pageSize != null) {

            PageHelper.startPage(pageIndex, pageSize);

        }

        List<Student> students = studentService.findStudentListByTeacher(name);

        PageInfo pageInfo = new PageInfo(students);

        return pageInfo;

    }

    }

    @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) {


        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 {

    public List<Teacher> getTeacherByName(@PathVariable String name) {

        return teacherService.getTeacherFuzzy(name);

    }

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

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

    @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) {

请添加图片描述

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值