vue+java实现添加单选题多选题到题库功能

做个备份

数据库表:
vue+java实现添加单选题多选题到题库功能_第1张图片vue+java实现添加单选题多选题到题库功能_第2张图片后台接口

@DeleteMapping("deleteQuestion")
    @ApiOperation(value = "删除问题")
    public ServerResponse deleteQuestion(Integer id){
        sysQuestionMapper.deleteByPrimaryKey(id);
        sysQuestionAnswerMapper.deleteByQUestionId(id);
        return ServerResponse.createBySuccess("删除成功");
    }

    @GetMapping("getQuestionList")
    @ApiOperation(value = "获得问题列表")
    public ServerResponse getQuestionList(){
        List list = sysQuestionMapper.selectAllQuestion();
        return ServerResponse.createBySuccess(list);
    }

    @GetMapping("getQuestionAnswerList")
    @ApiOperation(value = "获得问题选项列表")
    public ServerResponse getQuestionAnswerList(Integer question_id){
        List list = sysQuestionAnswerMapper.selectByQuestionId(question_id);
        return ServerResponse.createBySuccess(list);
    }

    @PostMapping("addQuestion")
    @ApiOperation(value = "添加问题")
    public ServerResponse addQuestion(String question,String[] answerList,Integer[] answer){
        Integer type = 1;
        if (answer.length != 1) {
            type = 2;
        }
        String stringAnswer = "";
        List list = Arrays.asList(answer);
        SysQuestion sysQuestion = new SysQuestion();
        sysQuestion.setQuestionName(question);
        sysQuestion.setCreateTime(new Date());
        sysQuestion.setType(type);
        sysQuestionMapper.insert(sysQuestion);
        Integer question_id = sysQuestionMapper.selectLastQuestionId();
        for (int i=0;i list = Arrays.asList(answer);
        sysQuestionAnswerMapper.deleteByQUestionId(question_id);
        for (int i=0;i

代码中涉及的sql语句


  

  


  

  
    delete from sys_question_answer where question_id=#{question_id}
  

vue页面











实现效果
vue+java实现添加单选题多选题到题库功能_第3张图片
vue+java实现添加单选题多选题到题库功能_第4张图片

你可能感兴趣的:(vue+java实现添加单选题多选题到题库功能)