From 93af1c6ffb9ae0e894689ad3a37b548e57d54cff Mon Sep 17 00:00:00 2001 From: linzhijie <19970921lzj> Date: 星期四, 11 三月 2021 19:10:07 +0800 Subject: [PATCH] 有注释的测评系统业务代码 --- src/main/java/com/ots/project/exam/service/impl/TQuestionServiceImpl.java | 335 +++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 239 insertions(+), 96 deletions(-) diff --git a/src/main/java/com/ots/project/exam/service/impl/TQuestionServiceImpl.java b/src/main/java/com/ots/project/exam/service/impl/TQuestionServiceImpl.java index 8aab9d8..90f33c8 100644 --- a/src/main/java/com/ots/project/exam/service/impl/TQuestionServiceImpl.java +++ b/src/main/java/com/ots/project/exam/service/impl/TQuestionServiceImpl.java @@ -1,4 +1,5 @@ package com.ots.project.exam.service.impl; + import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.ots.common.enums.QuestionTypeEnum; @@ -28,54 +29,89 @@ import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; + import static com.ots.common.enums.ExamPaperQuestion.permanentIdDuplicate; +/** + * 棰樼洰鍒楄〃Service涓氬姟灞傚鐞� + * + * @author Shawn + * @date 2019-11-20 + */ @Service("examQuestion") public class TQuestionServiceImpl implements ITQuestionService { @Autowired private TQuestionMapper tQuestionMapper; + @Autowired private TTextContentMapper tTextContentMapper; + @Autowired private ITTextContentService textContentService; + @Autowired private IDictDataService dictDataService; + @Autowired private DictService dictService; + protected final static ModelMapper modelMapper = ModelMapperSingle.Instance(); - + + /** + * 鏌ヨ棰樼洰鍒楄〃 + * + * @param id 棰樼洰鍒楄〃ID + * @return 棰樼洰鍒楄〃 + */ @Override public TQuestion selectTQuestionById(Long id) { return tQuestionMapper.selectTQuestionById(id); } - + + /** + * 鏌ヨ棰樼洰鍒楄〃 + * + * @param id 棰樼洰鍒楄〃ID + * @return 棰樼洰鍒楄〃 + */ @Override public List<TQuestion> selectTQuestionByIds(List<Long> ids) { return tQuestionMapper.selectTQuestionByIds(ids); } + @Override public List<TQuestion> selectTQuestionByPermanentIds(List<String> permanentIds) { return tQuestionMapper.selectTQuestionByPermanentIds(permanentIds); } - + + /** + * 鏌ヨ棰樼洰鍒楄〃鍒楄〃 + * + * @param tQuestion 棰樼洰鍒楄〃 + * @return 棰樼洰鍒楄〃 + */ @Override public List<TQuestion> selectTQuestionList(TQuestion tQuestion) { List<TQuestion> tQuestionList = tQuestionMapper.selectTQuestionList(tQuestion); List<TQuestion> tQuestionResultList = new ArrayList<>(); - + // 鍥介檯鍖栫殑閫夋嫨鐨勫璇█绫诲瀷 String localLangType = dictService.getLangType(LocaleContextHolder.getLocale().toString()); for (TQuestion question : tQuestionList) { String content = question.getContent(); QuestionObject questionObject = JSONObject.parseObject(content, QuestionObject.class); + setChioceAndSelectInput(question, questionObject); + question.setTitle(questionObject.getTitleContent()); - + + // 閬嶅巻鍑哄悇绉嶈瑷� Map<String, String> titleMap = JsonUtil.toJsonObject(question.getTitle(), HashMap.class); if (Objects.isNull(titleMap)) { TQuestion questionResult = new TQuestion(); @@ -83,26 +119,26 @@ questionResult.setLangType("Chinese"); tQuestionResultList.add(questionResult); } else { - + // 澶栧眰 if (Objects.isNull(tQuestion.getUuid())) { - + // 濡傛灉鏄畨鏉′欢鏌ヨ if (StringUtils.isNotEmpty(tQuestion.getLangType())) { - + // 鏈夎繖绉嶈瑷� if (StringUtils.isNotEmpty(titleMap.get(tQuestion.getLangType()))) { - + // 鏈夊厛灞曠ず鍥介檯鍖� if (StringUtils.isNotEmpty(titleMap.get(localLangType))) { addQuestionResult(tQuestionResultList, question, localLangType, titleMap.get(localLangType)); } else { addQuestionResult(tQuestionResultList, question, tQuestion.getLangType(), titleMap.get(tQuestion.getLangType())); } } - } else if (StringUtils.isNotEmpty(titleMap.get(localLangType))) { + } else if (StringUtils.isNotEmpty(titleMap.get(localLangType))) { // 涓嶆槸瀹夋潯浠舵煡璇� addQuestionResult(tQuestionResultList, question, localLangType, titleMap.get(localLangType)); - } else { + } else { // 鏃犺濡備綍閮借闅忎究灞曠ず涓�绉嶈瑷� addQuestionResult(tQuestionResultList, question, titleMap.keySet().stream().findFirst().get(), titleMap.values().stream().findFirst().get()); } } else { - + // 澶氳瑷�鐨勯偅灞� if (StringUtils.isNotEmpty(tQuestion.getLangType())) { addQuestionResult(tQuestionResultList, question, tQuestion.getLangType(), titleMap.get(tQuestion.getLangType())); } else { @@ -113,47 +149,64 @@ } } } + tQuestionList.clear(); tQuestionList.addAll(tQuestionResultList); return tQuestionList; } + private void setChioceAndSelectInput(TQuestion question, QuestionObject questionObject) { if (ExamUtil.isListEmpty(questionObject.getQuestionItemObjects())) { return; } - + + //閫夐」A銆丅銆丆銆丏 List<String> choiceInputList = questionObject.getQuestionItemObjects().stream().map(i -> { return i.getPrefix(); }).collect(Collectors.toList()); question.setChoiceInput(choiceInputList); - + + //閫夐」鍐呭 List<String> stemList = questionObject.getQuestionItemObjects().stream().map(i -> { return ExamUtil.getLangString(question.getLangType(), i.getContent()); }).collect(Collectors.toList()); question.setSelectInput(stemList); } + private void addQuestionResult(List<TQuestion> tQuestionResultList, TQuestion question, String key, String value) { TQuestion questionResult = new TQuestion(); BeanUtils.copyProperties(question, questionResult); - + + // 璇█绫诲瀷 questionResult.setLangType(key); - + + // 璇█绫诲瀷瀵瑰簲鐨勯鐩� questionResult.setTitle(value); - + + // 閫氳繃闂嵎鐨勫ぇ棰樻病鏈夐�夐」 if (ExamUtil.isListNotEmpty(question.getChoiceInput())) { setLanSelectInput(question, key); } + tQuestionResultList.add(questionResult); } + private void setLanSelectInput(TQuestion question, String key) { - + // 璇█瀵瑰簲鐨勯�夐」 List<String> selectInputList = question.getSelectInput(); - + + // 鏇存柊 for (String selectInput : selectInputList) { selectInput = ExamUtil.getStringByLang(key, selectInput);; } } - + + /** + * 褰撳湪product 鐨刟dd_question.html鐨勬椂鍊欒皟鐢� + * + * @param tQuestion 棰樼洰鍒楄〃 + * @return 棰樼洰鍒楄〃 + */ @Override public List<TQuestion> selectTQuestionsForProductAddQuestion(TQuestion tQuestion) { List<TQuestion> tQuestionList = tQuestionMapper.selectTQuestionsForProductAddQuestion(tQuestion); @@ -162,17 +215,25 @@ QuestionObject questionObject = JSONObject.parseObject(content, QuestionObject.class); question.setLangType(tQuestion.getLangType()); setChioceAndSelectInput(question, questionObject); - + // 澶氳瑷� Map<String, String> titleMap = JsonUtil.toJsonObject(questionObject.getTitleContent(), HashMap.class); + if (Objects.isNull(titleMap)) { question.setTitle(questionObject.getTitleContent()); } else { question.setTitle(ExamUtil.getLangString(tQuestion.getLangType(), questionObject.getTitleContent())); } } + return tQuestionList; } - + + /** + * 鏂板棰樼洰鍒楄〃 + * + * @param tQuestion 棰樼洰鍒楄〃 + * @return 缁撴灉 + */ @Override @Transactional public int insertTQuestion(TQuestion tQuestion) { @@ -182,26 +243,31 @@ return permanentIdDuplicate.ordinal(); } } - + //鎷艰t_text_content锛宼Question鍙傛暟鐨勫睘鎬т篃鏄細鍦ㄦ鏂规硶鍐呴儴淇敼 TTextContent textContent = getQuestionTextContent(tQuestion); - + + //鍏ュ簱t_text_content tTextContentMapper.insertTTextContent(textContent); - + + //鎶妕_text_content鐨刬d璧嬪�肩粰t_question鐨刬nfo_text_content_id tQuestion.setInfoTextContentId(textContent.getId()); return tQuestionMapper.insertTQuestion(tQuestion); } + private TTextContent getQuestionTextContent(TQuestion tQuestion) { - + //bgin 绛旀閫夐」灏佽,鍘熷洜鏄柟渚垮悗闈㈣浆鎹㈡垚json List<QuestionEditItem> questionEditItems = new ArrayList<QuestionEditItem>(); List<QuestionEditItem> itemObjects = null; - + + // 澶ч鐩笉闇�瑕侀�夐」 if (ExamUtil.isListNotEmpty(tQuestion.getChoiceInput())) { itemObjects = getQuestionEditItems(tQuestion, questionEditItems); } + QuestionObject questionObject = new QuestionObject(); questionObject.setQuestionItemObjects(itemObjects); questionObject.setAnalyze(tQuestion.getAnalyze()); - + // 澶氳瑷� if (StringUtils.isNotEmpty(tQuestion.getMultilingual())) { questionObject.setTitleContent(tQuestion.getTitle()); } else { @@ -212,24 +278,26 @@ TTextContent textContent = new TTextContent(); textContent.setCreateTime(DateUtils.getNowDate()); textContent.setContent(JSON.toJSONString(questionObject)); - + //end 绛旀閫夐」灏佽,鍘熷洜鏄柟渚垮悗闈㈣浆鎹㈡垚json return textContent; } + private List<QuestionEditItem> getQuestionEditItems(TQuestion tQuestion, List<QuestionEditItem> questionEditItems) { for (int i = 0; i < tQuestion.getChoiceInput().size(); i++) { QuestionEditItem questionEditItem = new QuestionEditItem(); questionEditItem.setPrefix(tQuestion.getChoiceInput().get(i)); - - if (StringUtils.isNotEmpty(tQuestion.getMultilingual())) { + // 澶氳瑷� + if (StringUtils.isNotEmpty(tQuestion.getMultilingual())) { // 鎵归噺瀵煎叆鐨勬椂鍊欏凡缁忔嫾濂藉悇绉嶈瑷� questionEditItem.setContent(tQuestion.getSelectInput().get(i)); } else { questionEditItem.setContent(ExamUtil.getStringMapJson(tQuestion.getLangType(), tQuestion.getSelectInput().get(i), new HashMap<>())); } - - questionEditItem.setScore(Objects.isNull(tQuestion.getScore()) ? 0 : tQuestion.getScore().intValue()); + // 棰樼洰鐨勫垎鏁� + questionEditItem.setScore(Objects.isNull(tQuestion.getScore()) ? 0 : tQuestion.getScore().intValue());//鐩墠鐢ㄤ笉涓婅繖涓垎鏁帮紝鍏堣涓�0 questionEditItems.add(questionEditItem); } - + + //閬嶅巻姣忎竴涓�夐」 return questionEditItems.stream().map(i -> { QuestionEditItem item = modelMapper.map(i, QuestionEditItem.class); @@ -238,72 +306,96 @@ } ).collect(Collectors.toList()); } - + + /** + * 淇敼棰樼洰鍒楄〃 + * + * @param tQuestion 棰樼洰鍒楄〃 + * @return 缁撴灉 + */ @Override public int updateTQuestion(TQuestion tQuestion) { - + + // 澶氳瑷�鐨勬洿鏂� if (tQuestion.getUuid() != null) { TQuestion questionOld = tQuestionMapper.selectTQuestionById(tQuestion.getId()); - + // 鍚堝苟绗簩涓緭鍏ユ閫夐」鐨勫唴瀹� updateQuestionLangContent(tQuestion, questionOld); return tQuestionMapper.updateTQuestion(tQuestion); } - + + + // 鎸夌収permanateid 鏇存柊璇█ List<TQuestion> questionOldlist = tQuestionMapper.selectTQuestionByPermanentId(tQuestion.getPermanentId()); if (ExamUtil.isListNotEmpty(questionOldlist)) { - + // 鍚堝苟绗簩涓緭鍏ユ閫夐」鐨勫唴瀹� for (TQuestion tQuestionUpdate : questionOldlist) { - + // 鍏煎鏃х増鏈紝 鏃х増鏈病鏈塼emplateid锛屾柊鐗堟湰鏈� if (StringUtils.isNotEmpty(tQuestion.getTemplate()) && StringUtils.isEmpty(tQuestionUpdate.getTemplate())) { tQuestionUpdate.setTemplate(tQuestion.getTemplate()); } updateQuestionLangContent(tQuestion, tQuestionUpdate); } + return 1; } + TQuestion questionOld = null; - + + //淇敼鎺夋棫鐨勪骇鍝佸寘 if (!Objects.isNull(tQuestion.getId())) { - + // 鍦ㄩ鐩垪琛ㄤ慨鏀圭殑鏃跺�欎細杩涘叆姝ら�昏緫锛屽叾浠栭�昏緫鏄壒閲忓鍏� questionOld = tQuestionMapper.selectTQuestionById(tQuestion.getId()); questionOld.setDeleted(2L); questionOld.setUpdateTime(DateUtils.getNowDate()); tQuestionMapper.updateTQuestion(questionOld); } - + + // 鏇存敼棰樼洰鐨勫唴瀹规暟鎹� setInsertQuestion(tQuestion); - + + //鎻掑叆鏂扮殑t_question return tQuestionMapper.insertTQuestion(tQuestion); } + private void setInsertQuestion(TQuestion tQuestion) { - + //鏂扮殑question鐢ㄦ彃鍏ユ柊璁板綍鐨勬柟寮� tQuestion.setUpdateTime(DateUtils.getNowDate()); - + + //鎷艰t_text_content锛宼Question鍙傛暟鐨勫睘鎬т篃鏄細鍦ㄦ鏂规硶鍐呴儴淇敼 TTextContent textContent = getQuestionTextContent(tQuestion); textContent.setId(null); - + + //鍏ュ簱t_text_content tTextContentMapper.insertTTextContent(textContent); - + + //鎶妕_text_content鐨刬d璧嬪�肩粰t_question鐨刬nfo_text_content_id tQuestion.setInfoTextContentId(textContent.getId()); + tQuestion.setDeleted(1L); - + + // 璁板綍浠庨偅涓鐩慨鏀硅繃鏉ョ殑id tQuestion.setLastId(tQuestion.getId()); } - + + // 澶氳瑷�鏇存柊棰樼洰鐨勫唴瀹癸紝淇敼鍗曚釜鐨勬椂鍊欎娇鐢� private int updateQuestionContent(TQuestion tQuestion, TQuestion questionOld) { if (Objects.isNull(tQuestion.getId()) || tQuestion.getId() == 0) { tQuestion.setId(questionOld.getId()); } - + // 棰樼洰鐨勪粠content QuestionObject questionObject = JSONObject.parseObject(questionOld.getContent(), QuestionObject.class); - + + //鏂扮殑question鐢ㄦ彃鍏ユ柊璁板綍鐨勬柟寮� tQuestion.setUpdateTime(DateUtils.getNowDate()); - - + + // 鏈�澶嶆潅锛屽悎骞跺悇璇█鐗堟湰 + // 棰樼洰鍚堝苟 Map<String, String> titleMap = JsonUtil.toJsonObject(questionObject.getTitleContent(), HashMap.class); titleMap.put(tQuestion.getLangType(), tQuestion.getTitle()); questionObject.setTitleContent(JsonUtil.toJsonStr(titleMap)); - + + // 閫夐」鐨勫唴瀹瑰悎骞� List<String> selectInput = tQuestion.getSelectInput(); int selectInputNum = 0; List<QuestionEditItem> questionItemObjects = questionObject.getQuestionItemObjects(); @@ -312,57 +404,70 @@ contentMap.put(tQuestion.getLangType(), selectInput.get(selectInputNum++)); questionItemObject.setContent(JsonUtil.toJsonStr(contentMap)); } + TTextContent questionTextContent = tTextContentMapper.selectTTextContentById(questionOld.getInfoTextContentId()); questionTextContent.setUpdateTime(DateUtils.getNowDate()); questionTextContent.setContent(JsonUtil.toJsonStr(questionObject)); - + + //鍏ュ簱t_text_content return tTextContentMapper.updateTTextContent(questionTextContent); } - + + // 瀵煎叆鐨勬椂鍊欎娇鐢� private int updateQuestionLangContent(TQuestion tQuestion, TQuestion questionOld) { if (Objects.isNull(tQuestion.getId()) || tQuestion.getId() == 0) { tQuestion.setId(questionOld.getId()); } - + // 棰樼洰鐨勪粠content QuestionObject questionObject = JSONObject.parseObject(questionOld.getContent(), QuestionObject.class); - + + //鏂扮殑question鐢ㄦ彃鍏ユ柊璁板綍鐨勬柟寮� tQuestion.setUpdateTime(DateUtils.getNowDate()); - - + + // 鏈�澶嶆潅锛屽悎骞跺悇璇█鐗堟湰 + // 棰樼洰鍚堝苟锛屽鏋滄槸鎵归噺瀵煎叆鐨勮瘽娌℃湁uuid String langType = tQuestion.getLangType(); if (Objects.isNull(tQuestion.getUuid())) { langType = "ALL"; } questionObject.setTitleContent(ExamUtil.getStringMapJson(langType, tQuestion.getTitle(), questionObject.getTitleContent())); - + + // 閫夐」鐨勫唴瀹瑰悎骞� updateQuestionEditItem(tQuestion, questionObject); + TTextContent questionTextContent = tTextContentMapper.selectTTextContentById(questionOld.getInfoTextContentId()); questionTextContent.setUpdateTime(DateUtils.getNowDate()); questionTextContent.setContent(JsonUtil.toJsonStr(questionObject)); - - + + // 鏇存柊涓�涓嬩骇鍝佸寘鐨勫唴瀹� + + //鍏ュ簱t_text_content tQuestionMapper.updateTQuestion(questionOld); return tTextContentMapper.updateTTextContent(questionTextContent); } + private void updateQuestionEditItem(TQuestion tQuestion, QuestionObject questionObject) { - + // 濡傛灉鏈夊ぇ棰橈紝灏变笉闇�瑕� if (ExamUtil.isListEmpty(tQuestion.getChoiceInput())) { return; } List<String> selectInput = tQuestion.getSelectInput(); int selectInputNum = 0; List<QuestionEditItem> questionItemObjects = questionObject.getQuestionItemObjects(); - + + // 棰樼洰鍚堝苟锛屽鏋滄槸鎵归噺瀵煎叆鐨勮瘽娌℃湁uuid String langType = tQuestion.getLangType(); if (Objects.isNull(tQuestion.getUuid())) { langType = "ALL"; } + for (QuestionEditItem questionItemObject : questionItemObjects) { if (selectInputNum < selectInput.size()) { questionItemObject.setContent(ExamUtil.getStringMapJson(langType, selectInput.get(selectInputNum++), questionItemObject.getContent())); } } - + + // 娣诲姞鏂扮殑閫夐」 if (selectInput.size() > questionItemObjects.size()) { QuestionEditItem questionItemObject = new QuestionEditItem(); String prefix = tQuestion.getChoiceInput().get(tQuestion.getChoiceInput().size() - 1); @@ -371,25 +476,31 @@ questionItemObject.setScore(0); questionItemObjects.add(questionItemObject); } - + + // 鍒犻櫎閫夐」鐨勯�夐」 if (selectInput.size() < questionItemObjects.size()) { for (int i = questionItemObjects.size() - 1; i > selectInput.size() - 1; i--) { questionItemObjects.remove(i); } } } - + + + // 澶氳瑷�鏇存柊棰樼洰鐨勫唴瀹� public int deleteQuestionContent(TQuestion tQuestion) { TQuestion questionOld = tQuestionMapper.selectTQuestionById(tQuestion.getId()); - + // 鍘熸潵棰樼洰鐨刢ontent QuestionObject questionObject = JSONObject.parseObject(questionOld.getContent(), QuestionObject.class); - + + // 鏂扮殑question鐢ㄦ彃鍏ユ柊璁板綍鐨勬柟寮� tQuestion.setUpdateTime(DateUtils.getNowDate()); - + + // 鍒犻櫎鏌愪竴绉嶈瑷� Map<String, String> titleMap = JsonUtil.toJsonObject(questionObject.getTitleContent(), HashMap.class); titleMap.remove(tQuestion.getLangType()); questionObject.setTitleContent(JsonUtil.toJsonStr(titleMap)); - + + // 閫夐」鐨勫唴瀹瑰悎骞� List<QuestionEditItem> questionItemObjects = questionObject.getQuestionItemObjects(); if (ExamUtil.isListNotEmpty(questionItemObjects)) { for (QuestionEditItem questionItemObject : questionItemObjects) { @@ -398,29 +509,45 @@ questionItemObject.setContent(JsonUtil.toJsonStr(contentMap)); } } + TTextContent questionTextContent = tTextContentMapper.selectTTextContentById(questionOld.getInfoTextContentId()); questionTextContent.setUpdateTime(DateUtils.getNowDate()); questionTextContent.setContent(JsonUtil.toJsonStr(questionObject)); - + + //鍏ュ簱t_text_content return tTextContentMapper.updateTTextContent(questionTextContent); } - + + /** + * 鍒犻櫎棰樼洰鍒楄〃瀵硅薄 + * + * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁ID + * @return 缁撴灉 + */ @Override public int deleteTQuestionByIds(String ids) { return tQuestionMapper.updateQuetionByDelete(Convert.toStrArray(ids)); } - + + /** + * 鍒犻櫎棰樼洰鍒楄〃淇℃伅 + * + * @param id 棰樼洰鍒楄〃ID + * @return 缁撴灉 + */ public int deleteTQuestionById(Long id) { return tQuestionMapper.deleteTQuestionById(id); } + @Override public QuestionEditRequestVM getQuestionEditRequestVM(TQuestion question) { - + //棰樼洰鏄犲皠 TTextContent questionInfoTextContent = textContentService.selectTTextContentById(question.getInfoTextContentId().longValue()); QuestionObject questionObject = JsonUtil.toJsonObject(questionInfoTextContent.getContent(), QuestionObject.class); QuestionEditRequestVM questionEditRequestVM = modelMapper.map(question, QuestionEditRequestVM.class); questionEditRequestVM.setTitle(questionObject.getTitleContent()); - + + //绛旀 QuestionTypeEnum questionTypeEnum = QuestionTypeEnum.fromCode(question.getQuestionType().intValue()); switch (questionTypeEnum) { case SingleChoice: @@ -442,7 +569,9 @@ } questionEditRequestVM.setScore(ExamUtil.scoreToVM(0)); questionEditRequestVM.setAnalyze(questionObject.getAnalyze()); - + + + //棰樼洰椤规槧灏� 濡傛灉閫夐」涓虹┖锛岄偅涔堝氨缁欎竴涓粯璁ゅ�硷紝鍚﹀垯鏅哄姏棰樹細鎶ラ敊 if (Objects.nonNull(questionObject.getQuestionItemObjects())) { List<QuestionEditItemVM> editItems = questionObject.getQuestionItemObjects().stream().map(o -> { QuestionEditItemVM questionEditItemVM = modelMapper.map(o, QuestionEditItemVM.class); @@ -463,42 +592,50 @@ } return questionEditRequestVM; } + @Override public String insertImportQuestion(List<Map<Integer, String>> excelList) { - - + // 1銆丣AQ棰樼洰姘镐箙缂栧彿 缁村害 棰樼洰鎬诲垎 棰樼洰 璇█绫诲瀷 姝g‘绛旀 + + // 2銆佸垱寤篵ean TQuestion tQuestion = new TQuestion(); - + + + // 3銆佸彇鍑洪�夐」 Map<Integer, String> headerMap = excelList.get(0); List<String> prefixList = new ArrayList<>(); for (int i = 6; i < headerMap.size(); i++) { prefixList.add(headerMap.get(i)); } - + + // 4銆佸鍏ョ殑娑堟伅 StringBuilder successMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder(); - + + // 5銆侀亶鍘嗗嚭杈撳叆鐨勯鐩叆搴� for (int i = 1; i < excelList.size(); i++) { + Map<Integer, String> excelDataMap = excelList.get(i); try { - + // JAQ棰樼洰姘镐箙缂栧彿 tQuestion.setPermanentId(excelDataMap.get(0)); - + //缁村害闇�瑕佽浆鎹�,浠e紑鍙� tQuestion.setSubjectId(Long.valueOf(excelDataMap.get(1))); - + // 棰樼洰鎬诲垎 tQuestion.setScore(Long.valueOf(excelDataMap.get(2))); - + // 棰樼洰 tQuestion.setTitle(excelDataMap.get(3)); - + // 璇█绫诲瀷 tQuestion.setLangType(excelDataMap.get(4)); - + // 姝g‘绛旀 tQuestion.setCorrect(excelDataMap.get(5)); - + // 閫夐」 int prefixNum = 0; tQuestion.setChoiceInput(new ArrayList<>()); - List<String> choiceInput = tQuestion.getChoiceInput(); + List<String> choiceInput = tQuestion.getChoiceInput(); // A,B,C,D tQuestion.setSelectInput(new ArrayList<>()); - List<String> selectInput = tQuestion.getSelectInput(); + + List<String> selectInput = tQuestion.getSelectInput(); // A,B,C,D鐨勫唴瀹� for (int j = 6; j < excelDataMap.size(); j++) { choiceInput.add(prefixList.get(prefixNum++)); selectInput.add(excelDataMap.get(j)); @@ -512,6 +649,7 @@ StringBuilder meg = failureMsg.append(successMsg); return meg.toString(); } + public void setQuestionInfoFromVM(TextContent infoTextContent, QuestionEditRequestVM model) { List<QuestionEditItem> itemObjects = model.getItems().stream().map(i -> { @@ -527,11 +665,14 @@ questionObject.setCorrect(model.getCorrect()); infoTextContent.setContent(JsonUtil.toJsonStr(questionObject)); } - + + // 濡傛灉鏈鐩凡缁忔湁浜嗚绉嶈瑷�锛屽氨涓嶈灞曠ず锛宔dit-*.html浣跨敤 public List<DictData> getType(Long id) { - + + // 鏌ヨ瀛楀吀鍏� List<DictData> dictDataList = dictDataService.selectDictDataByType("lang_type"); - + + // 鏌ョ湅宸茬粡瀛樺湪鐨勯鐩� if (Objects.nonNull(id)) { TQuestion question = selectTQuestionById(id); String content = question.getContent(); @@ -548,7 +689,9 @@ return dictDataList; } } + public List<TQuestion> selectTQuestionByPermanentId(String permanentId) { return tQuestionMapper.selectTQuestionByPermanentId(permanentId); } + } -- Gitblit v1.9.1