Spring Boot——易班优课YOOC课群在线测试自动答题解决方案(二)答案储存

前文

JavaScript——易班优课YOOC课群在线测试自动答题解决方案(一)答案获取

问题分析

前端数据

Maven

        <!--Spring Boot Web-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!--Spring Mybatis-->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.1.1</version>
        </dependency>
        <!--MyBatis-Plus-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.3.1.tmp</version>
        </dependency>

解决方案 

数据库设计

主要代码 

/**
 * @Author ShenTuZhiGang
 * @Version 1.0.0
 * @Date 2020-04-26 08:26
 */
@Controller
@CrossOrigin
public class YOOCController {
    @Autowired
    IYOOCExamQuestionService iyoocExamQuestionService;
    @ResponseBody
    @RequestMapping(value = "/exam")
    public Object updateExams(@RequestBody ExamDTO examDTO){
        List<Question> questions  = new ArrayList<>();
        for (QuestionDTO questionDTO: examDTO.getQuestions()) {
            Question question =new Question(examDTO.getGroup(),
                    examDTO.getExam(),
                    questionDTO.getId().substring(9),
                    questionDTO.getQuestion());
            questions.add(question);
            System.out.println(question);

        }
        iyoocExamQuestionService.saveOrUpdateBatch(questions);
        return examDTO;
    }
}

运行结果

参考文章

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 1024 设计师:上身试试 返回首页