Commit 065915ed authored by 黎博's avatar 黎博

优化下清除缓存接口

parent 64e32721
...@@ -6,6 +6,7 @@ import cn.qg.holmes.service.effect.ClearCacheService; ...@@ -6,6 +6,7 @@ import cn.qg.holmes.service.effect.ClearCacheService;
import cn.qg.holmes.utils.HttpClientUtils; import cn.qg.holmes.utils.HttpClientUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -41,10 +42,15 @@ public class EffectController { ...@@ -41,10 +42,15 @@ public class EffectController {
@GetMapping("/clearcache") @GetMapping("/clearcache")
public JsonResult clearCache(Integer id, String namespace) { public JsonResult clearCache(Integer id, String namespace) {
ClearCache clearCache = clearCacheService.getById(id); ClearCache clearCache = clearCacheService.getById(id);
log.info("开始清除{}环境的{}缓存", namespace, clearCache.getName());
String url = clearCache.getUrl(); String url = clearCache.getUrl();
String result = HttpClientUtils.doGet(url.replace("{NAMESPACE}", namespace)); if (url.contains("{NAMESPACE}")) {
log.info("{}环境的{}缓存清除结果为:{}", namespace, clearCache.getName(), result); if (StringUtils.isEmpty(namespace)) {
return JsonResult.buildErrorStateResult("请先选择环境!", false);
} else {
url = url.replace("{NAMESPACE}", namespace);
}
}
String result = HttpClientUtils.doGet(url);
return JsonResult.buildSuccessResult(JSON.parseObject(result, Map.class)); return JsonResult.buildSuccessResult(JSON.parseObject(result, Map.class));
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment