瀏覽代碼

代码优化

gaodm 5 年之前
父節點
當前提交
aaf3273a22
共有 1 個文件被更改,包括 16 次插入12 次删除
  1. 16 12
      icssman-service/src/main/java/com/diagbot/facade/ModuleDetailFacade.java

+ 16 - 12
icssman-service/src/main/java/com/diagbot/facade/ModuleDetailFacade.java

@@ -34,8 +34,6 @@ import java.util.stream.Collectors;
 @Component
 public class ModuleDetailFacade extends ModuleDetailServiceImpl {
 
-    @Autowired
-    private ModuleInfoFacade moduleInfoFacade;
     @Autowired
     @Qualifier("moduleDetailServiceImpl")
     private ModuleDetailService moduleDetailService;
@@ -90,17 +88,23 @@ public class ModuleDetailFacade extends ModuleDetailServiceImpl {
                 textList.add(addModuleDetailVO.getText());
             }
         }
-        QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
-        questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
-                .eq("tag_type", TagTypeEnum.T8.getKey())
-                .eq("type", addModuleInfoVO.getTextType())
-                .in("name", textList);
-        List<QuestionInfo> questionInfoList = questionFacade.list(questionInfoQueryWrapper);
+
         //将标签id放入map
         Map<String, Long> questionIdMap = new HashMap<>();
-        for (AddModuleDetailVO addModuleDetailVO : addModuleInfoVO.getModelDetils()) {
-            if (StringUtil.isNotEmpty(addModuleDetailVO.getText())) {
-                questionIdMap = questionInfoList.stream().collect(Collectors.toMap(QuestionInfo::getTagName, questionInfo -> questionInfo.getId()));
+        if (ListUtil.isNotEmpty(textList)){
+            QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
+            questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .eq("tag_type", TagTypeEnum.T8.getKey())
+                    .eq("type", addModuleInfoVO.getTextType())
+                    .in("name", textList);
+            List<QuestionInfo> questionInfoList = questionFacade.list(questionInfoQueryWrapper);
+
+            for (AddModuleDetailVO addModuleDetailVO : addModuleInfoVO.getModelDetils()) {
+                if (StringUtil.isNotEmpty(addModuleDetailVO.getText())) {
+                    questionIdMap = questionInfoList.stream()
+                            .collect(Collectors.toMap(QuestionInfo::getTagName,
+                                    questionInfo -> questionInfo.getId()));
+                }
             }
         }
         QuestionInfo addquestionInfo = null;
@@ -132,7 +136,7 @@ public class ModuleDetailFacade extends ModuleDetailServiceImpl {
         questionInfoService.saveBatch(addQuestionInfoList);
         //查询自定义标签的id
         QueryWrapper<QuestionInfo> questionInfoQueryWrapper1 = new QueryWrapper<>();
-        questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+        questionInfoQueryWrapper1.eq("is_deleted", IsDeleteEnum.N.getKey())
                 .eq("type", addModuleInfoVO.getTextType())
                 .eq("tag_type", TagTypeEnum.T8.getKey());
         List<QuestionInfo> questionInfoList1 = questionFacade.list(questionInfoQueryWrapper1);