opt:优化日志查询

This commit is contained in:
zhangzq
2025-03-03 21:26:24 +08:00
parent 70f19e9ce5
commit 4357e8eff6
6 changed files with 50 additions and 24 deletions

View File

@@ -24,21 +24,17 @@ import org.springframework.web.bind.annotation.*;
public class EsLogController {
private final EsLogService esLogService;
@GetMapping("/labels/{type}")
public ResponseEntity<Object> labelsValues(@PathVariable String type) {
return new ResponseEntity<>(esLogService.getLabelsValues(type), HttpStatus.OK);
}
@PostMapping("/query")
public ResponseEntity<Object> queryAll(@RequestBody LogQuery query) {
return new ResponseEntity<>(esLogService.query(query), HttpStatus.OK);
}
@DeleteMapping("/clearLogs")
public ResponseEntity<Object> clearLogs(@RequestBody LogQuery query) {
esLogService.clearLogs(query);
return new ResponseEntity<>(HttpStatus.OK);

View File

@@ -16,6 +16,7 @@ import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.*;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.BytesRef;
import org.nl.common.utils.ApiDocScan;
import org.nl.config.lucene.LuceneAppender;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.logging.service.EsLogService;
@@ -24,13 +25,11 @@ import org.nl.modules.logging.service.dto.LogRepositoryDTO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.wltea.analyzer.lucene.IKAnalyzer;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.*;
/**
* @author ldjun
@@ -70,11 +69,27 @@ public class LuceneLogServiceImpl implements EsLogService {
@Override
public JSONArray getLabelsValues(String type) {
JSONArray result = new JSONArray();
for (String v : INFO_LEVEL) {
JSONObject item = new JSONObject();
item.put("label", v);
item.put("value", v);
result.add(item);
switch (type){
case "logLevel":
for (String v : INFO_LEVEL) {
JSONObject item = new JSONObject();
item.put("label", v);
item.put("value", v);
result.add(item);
}
break;
case "interface":
if (!CollectionUtils.isEmpty(ApiDocScan.Log_Url)){
Set<String> strings = ApiDocScan.Log_Url.keySet();
for (String label : strings) {
String value = ApiDocScan.Log_Url.get(label);
JSONObject item = new JSONObject();
item.put("label", label);
item.put("value", value);
result.add(item);
}
}
break;
}
return result;
}

View File

@@ -29,7 +29,6 @@ public class AcsUtil {
return jsonObject;
}
@InterfaceLog
public JSONObject notifyAcs3(String api, JSONArray list) {
log.info("下发ACS参数----------------------------------------+" + api + ",---" + list.toString());
//判断是否连接ACS系统