Browse Source

清除规则缓存

wangfeng 4 years ago
parent
commit
84ea79c5f3

+ 3 - 0
src/main/java/com/diagbot/client/CdssCoreClient.java

@@ -201,4 +201,7 @@ public interface CdssCoreClient {
 
     @PostMapping("/klDisease/searchConcept")
     RespDTO<List<GetAllForRelationDTO>> searchConcept(@Valid @RequestBody SearchConceptVO searchConceptVO);
+
+    @PostMapping("/cache/clearRuleInfoAll")
+    RespDTO<Boolean> clearRuleAll();
 }

+ 6 - 0
src/main/java/com/diagbot/client/hystrix/CdssCoreHystrix.java

@@ -263,4 +263,10 @@ public class CdssCoreHystrix implements CdssCoreClient {
         log.error("【hystrix】调用{}异常", "searchConcept");
         return null;
     }
+
+    @Override
+    public RespDTO<Boolean> clearRuleAll() {
+        log.error("【hystrix】调用{}异常", "clearRuleAll");
+        return null;
+    }
 }

+ 1 - 0
src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -170,6 +170,7 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/klRule/disableRuleInfo").permitAll()
                 .antMatchers("/klRule/startRuleInfo").permitAll()
                 .antMatchers("/klDisease/searchConcept").permitAll()
+                .antMatchers("/cache/clearRuleAll").permitAll()
                 .antMatchers("/**").authenticated();
         //                .antMatchers("/**").permitAll();
     }

+ 1 - 0
src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java

@@ -212,6 +212,7 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/klRule/disableRuleInfo", request)
                 || matchers("/klRule/startRuleInfo", request)
                 || matchers("/klDisease/searchConcept", request)
+                || matchers("/cache/clearRuleAll", request)
                 || matchers("/", request)) {
             return true;
         }

+ 24 - 0
src/main/java/com/diagbot/facade/CacheFacade.java

@@ -0,0 +1,24 @@
+package com.diagbot.facade;
+
+import com.diagbot.client.CdssCoreClient;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.util.RespDTOUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2021-03-11 11:16
+ */
+@Component
+public class CacheFacade {
+    @Autowired
+    CdssCoreClient cdssCoreClient;
+
+    public boolean clearRuleInfoAll() {
+        RespDTO<Boolean> resData =  cdssCoreClient.clearRuleAll();
+        RespDTOUtil.respNGDeal(resData, "加载数据失败!");
+        return  resData.data;
+    }
+}

+ 38 - 0
src/main/java/com/diagbot/web/CacheController.java

@@ -0,0 +1,38 @@
+package com.diagbot.web;
+
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.CacheFacade;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * 缓存 前端控制器
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2018-12-25
+ */
+@RequestMapping("/cache")
+@RestController
+@SuppressWarnings("unchecked")
+@Api(value = "缓存API", tags = { "缓存API" })
+public class CacheController {
+
+    @Autowired
+    CacheFacade cacheFacade;
+
+    @ApiOperation(value = "清除规则缓存[by:wangfeng]",
+            notes = "")
+    @PostMapping("/clearRuleAll")
+    @SysLogger("clearRuleAll")
+    public RespDTO<Boolean> clearRuleInfoAlls() {
+        cacheFacade.clearRuleInfoAll();
+        return RespDTO.onSuc(true);
+    }
+}