|
|
@@ -4318,9 +4318,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
List<QuestionImportV4> questionImportV = questionList2.subList(i, i + a);
|
|
|
//第一个是内容
|
|
|
QuestionImportV4 v4 = questionImportV.get(0);
|
|
|
- question.setContent(v4.getQuestionName());
|
|
|
+ question.setContent(questionImage(v4.getQuestionName()));
|
|
|
question.setType(1);
|
|
|
- question.setAnswerQuestion(v4.getDescribe());
|
|
|
+ question.setAnalysisContent(v4.getDescribe());
|
|
|
question.setCode(ServletUtils.getEncoded("TM"));
|
|
|
//正确选项
|
|
|
Integer index = 0;
|
|
|
@@ -4343,9 +4343,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
List<QuestionImportV4> questionImportV1 = questionList2.subList(i, i + a);
|
|
|
//第一个是内容
|
|
|
QuestionImportV4 v41 = questionImportV1.get(0);
|
|
|
- question.setContent(v41.getQuestionName());
|
|
|
+ question.setContent(questionImage(v41.getQuestionName()));
|
|
|
question.setType(2);
|
|
|
- question.setAnswerQuestion(v41.getDescribe());
|
|
|
+ question.setAnalysisContent(v41.getDescribe());
|
|
|
//正确选项
|
|
|
List<Integer> index1 = new ArrayList<>();
|
|
|
//转换单选选项
|
|
|
@@ -4367,9 +4367,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
List<QuestionImportV4> questionImportV2 = questionList2.subList(i, i + a);
|
|
|
//第一个是内容
|
|
|
QuestionImportV4 v42 = questionImportV2.get(0);
|
|
|
- question.setContent(v42.getQuestionName());
|
|
|
+ question.setContent(questionImage(v42.getQuestionName()));
|
|
|
question.setType(3);
|
|
|
- question.setAnswerQuestion(v42.getDescribe());
|
|
|
+ question.setAnalysisContent(v42.getDescribe());
|
|
|
//正确选项
|
|
|
Integer index2 = 0;
|
|
|
//转换单选选项
|
|
|
@@ -4385,9 +4385,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
List<QuestionImportV4> questionImportV3 = questionList2.subList(i, i + a);
|
|
|
//第一个是内容
|
|
|
QuestionImportV4 v42 = questionImportV3.get(0);
|
|
|
- question.setContent(v42.getQuestionName());
|
|
|
+ question.setContent(questionImage(v42.getQuestionName()));
|
|
|
question.setType(4);
|
|
|
- question.setAnswerQuestion(v42.getDescribe());
|
|
|
+ question.setAnalysisContent(v42.getDescribe());
|
|
|
//截取案例题小题
|
|
|
List<QuestionImportV4> vv = new ArrayList<>();
|
|
|
for (int i1 = i+1; i1 < questionList2.size(); i1++) {
|
|
|
@@ -4409,7 +4409,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
List<QuestionImportV4> questionImportV5 = vv.subList(i1, i1 + y);
|
|
|
QuestionImportV4 questionImportV42 = questionImportV5.get(0);
|
|
|
QuestionInfoVo questionInfoVo = new QuestionInfoVo();
|
|
|
- questionInfoVo.setContent(questionImportV42.getQuestionName());
|
|
|
+ questionInfoVo.setContent(questionImage(questionImportV42.getQuestionName()));
|
|
|
questionInfoVo.setType(1);
|
|
|
//正确选项
|
|
|
Integer index = 0;
|
|
|
@@ -4435,7 +4435,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
List<QuestionImportV4> questionImportV6 = vv.subList(i1, i1 + y);
|
|
|
QuestionImportV4 questionImportV42 = questionImportV6.get(0);
|
|
|
QuestionInfoVo questionInfoVo = new QuestionInfoVo();
|
|
|
- questionInfoVo.setContent(questionImportV42.getQuestionName());
|
|
|
+ questionInfoVo.setContent(questionImage(questionImportV42.getQuestionName()));
|
|
|
questionInfoVo.setType(2);
|
|
|
//正确选项
|
|
|
List<Integer> index = new ArrayList<>();
|
|
|
@@ -4461,7 +4461,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
List<QuestionImportV4> questionImportV7 = vv.subList(i1, i1 + y);
|
|
|
QuestionImportV4 questionImportV42 = questionImportV7.get(0);
|
|
|
QuestionInfoVo questionInfoVo = new QuestionInfoVo();
|
|
|
- questionInfoVo.setContent(questionImportV42.getQuestionName());
|
|
|
+ questionInfoVo.setContent(questionImage(questionImportV42.getQuestionName()));
|
|
|
questionInfoVo.setType(3);
|
|
|
//正确选项
|
|
|
Integer index2 = 0;
|
|
|
@@ -4510,6 +4510,43 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
return Collections.emptyMap();
|
|
|
}
|
|
|
|
|
|
+ private String questionImage(String question){
|
|
|
+ //图片转换
|
|
|
+ Pattern pattern = Pattern.compile("src='(.*?)'");
|
|
|
+ Matcher matcher = pattern.matcher(question);
|
|
|
+ if (matcher.find()) {
|
|
|
+ String imagePath = matcher.group(1);
|
|
|
+ //下载图片
|
|
|
+ String ossPath = "";
|
|
|
+ //上传oss图片
|
|
|
+ try {
|
|
|
+ URL url = new URL(imagePath);
|
|
|
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
+ connection.setRequestMethod("GET");
|
|
|
+ connection.setConnectTimeout(5000);
|
|
|
+ connection.setReadTimeout(5000);
|
|
|
+
|
|
|
+ // 检查响应码
|
|
|
+ int responseCode = connection.getResponseCode();
|
|
|
+ if (responseCode == HttpURLConnection.HTTP_OK) {
|
|
|
+ try (InputStream inputStream = connection.getInputStream()) {
|
|
|
+ String s = cosService.uploadInputStream(inputStream,6);
|
|
|
+ ossPath = cosHost + "/" + s;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ connection.disconnect();
|
|
|
+ if (StringUtils.isNotBlank(ossPath)){
|
|
|
+ String updatedHtml = question.replaceAll("src='.*?'", "src='" +ossPath+ "'");
|
|
|
+ return updatedHtml;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new CustomException("oss图片上传失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return question;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String, Object> importImage(List<QuestionImageVo> questionList2) {
|
|
|
if (CollectionUtils.isEmpty(questionList2)){
|