| | |
| | | package com.mindskip.xzs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.mindskip.xzs.base.RestResponse; |
| | | import com.mindskip.xzs.domain.QuestionSubject; |
| | | import com.mindskip.xzs.domain.other.KeyValue; |
| | | import com.mindskip.xzs.domain.Question; |
| | |
| | | import com.mindskip.xzs.domain.enums.QuestionTypeEnum; |
| | | import com.mindskip.xzs.domain.question.QuestionItemObject; |
| | | import com.mindskip.xzs.domain.question.QuestionObject; |
| | | import com.mindskip.xzs.domain.vo.QuestionContentVO; |
| | | import com.mindskip.xzs.domain.vo.QuestionVO; |
| | | import com.mindskip.xzs.repository.QuestionMapper; |
| | | import com.mindskip.xzs.repository.SubjectMapper; |
| | | import com.mindskip.xzs.service.QuestionService; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | ).collect(Collectors.toList()) |
| | | ); |
| | | } |
| | | |
| | | @Override |
| | | public RestResponse selectContentById(Integer id) { |
| | | QuestionVO vo = questionMapper.selectContentById(id); |
| | | jsonQuestion(vo); |
| | | return RestResponse.ok(vo); |
| | | } |
| | | |
| | | @Override |
| | | public RestResponse getAnswer(Integer id) { |
| | | String content = questionMapper.getAnswer(id); |
| | | if (StringUtils.hasText(content)) { |
| | | QuestionContentVO vo = JSON.parseObject(content, QuestionContentVO.class); |
| | | vo.setQuestionItemObjects(null); |
| | | vo.setTitleContent(null); |
| | | return RestResponse.ok(vo); |
| | | } |
| | | return RestResponse.ok(null); |
| | | } |
| | | |
| | | /** |
| | | * 处理题目内容JSON |
| | | * |
| | | * @param vo |
| | | */ |
| | | public void jsonQuestion(QuestionVO vo) { |
| | | if (StringUtils.hasText(vo.getContentJson())) { |
| | | QuestionContentVO questionContent = JSON.parseObject(vo.getContentJson(), QuestionContentVO.class); |
| | | vo.setContent(questionContent); |
| | | } |
| | | } |
| | | } |