瀏覽代碼

解决冲突

gaodm 6 年之前
父節點
當前提交
27fbf1fb55
共有 1 個文件被更改,包括 68 次插入0 次删除
  1. 68 0
      icssman-service/src/main/java/com/diagbot/facade/QuestionFacade.java

+ 68 - 0
icssman-service/src/main/java/com/diagbot/facade/QuestionFacade.java

@@ -87,6 +87,8 @@ public class QuestionFacade extends QuestionInfoServiceImpl {
     DeptVitalFacade deptVitalFacade;
     @Autowired
     KnowledgemanServiceClient knowledgemanServiceClient;
+    @Autowired
+    CacheFacade cacheFacade;
 
     /**
      * 标签保存
@@ -117,6 +119,38 @@ public class QuestionFacade extends QuestionInfoServiceImpl {
             default:
                 throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "请选择标签显示类型");
         }
+
+        // 删除标签缓存信息
+        if (param.getInsertOrUpdate() == InsertOrUpdateEnum.Update.getKey()) {
+            clearAllCacheByIds(questionWrapper.getId());
+        }
+    }
+
+
+    /**
+     * 删除关联的id信息
+     *
+     * @param ids
+     */
+    public void clearAllCacheByIds(List<Long> ids) {
+        if (ListUtil.isNotEmpty(ids)) {
+            for (Long id : ids) {
+                cacheFacade.clearCache(id);
+            }
+        }
+    }
+
+
+    /**
+     * 删除关联的id信息
+     *
+     * @param id
+     */
+    public void clearAllCacheByIds(Long id) {
+        if (id != null) {
+            List<Long> ids = getDeleteId(id);
+            clearAllCacheByIds(ids);
+        }
     }
 
 
@@ -424,6 +458,9 @@ public class QuestionFacade extends QuestionInfoServiceImpl {
         Date now = DateUtil.now();
         String person = UserUtils.getCurrentPrincipleID();
         for (String id : idList) {
+            //删除缓存中的关联的标签信息
+            clearAllCacheByIds(Long.parseLong(id));
+
             Map paramMap = new HashMap<>();
             paramMap.put("delete", IsDeleteEnum.Y.getKey());
             paramMap.put("ids", Arrays.asList(ids.split(",")));
@@ -631,4 +668,35 @@ public class QuestionFacade extends QuestionInfoServiceImpl {
         }
         return data;
     }
+
+    /**
+     * 获取所有需要删除的缓存id列表
+     *
+     * @param id
+     * @return
+     */
+    public List<Long> getDeleteId(Long id) {
+        List<Long> list = new ArrayList<>();
+        list.add(id); //添加自身id
+        getParent(id, list); //添加父级
+        return list;
+    }
+
+
+    public void getParent(Long id, List<Long> list) {
+        List<QuestionMapping> questionMappingList = questionMappingFacade.list(
+                new QueryWrapper<QuestionMapping>()
+                        .eq("is_deleted", IsDeleteEnum.N.getKey())
+                        .eq("son_question", id)
+        );
+        if (ListUtil.isNotEmpty(questionMappingList)) {
+            for (QuestionMapping questionMapping : questionMappingList) {
+                Long parentId = questionMapping.getParentQuestion();
+                if (!list.contains(parentId)) {
+                    list.add(parentId);
+                    getParent(parentId, list);
+                }
+            }
+        }
+    }
 }