Spring Boot——易班优课YOOC课群在线测试自动答题解决方案(三)答案查询

前文

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

Spring Boot——易班优课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>

解决方案

    @ResponseBody
    @RequestMapping(value = "/group/{groupId}/exam/{examId}/answer",method = RequestMethod.GET)
    public Object getAnswerByQuestionId(@PathVariable("groupId")String groupId,
                                        @PathVariable("examId")String examId,
                                        @RequestParam("question") List<String> questions){
        List<QuestionDTO> questionDTOS  = new ArrayList<>();
        for (String question:questions) {
            Question questiona=iyoocExamQuestionService.getById(question);
            if(questiona==null){
                questionDTOS.add(QuestionDTO.getNullQuestionDTO(question));
            }else{
                questionDTOS.add(new QuestionDTO(questiona.getId(),questiona.getQuestion()));
            }
        }
        return questionDTOS;
    }

参考文章 

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