Merge pull request #2346 from dataease/pr@dev@fix_log_filter_error

fix: 操作日志列表查询条件包含多个操作类型结果集逻辑错误
This commit is contained in:
fit2cloud-chenyw 2022-05-30 10:07:53 +08:00 committed by GitHub
commit ce1f06705e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,6 +26,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
@ -46,7 +47,6 @@ public class LogService {
private static Integer[] driver_file_ope = {11, 3};
// 排除驱动和驱动文件的公共操作的资源类型
// 暂时屏蔽视图日志
// private static Integer[] COMMON_SOURCE = {1, 2,3,4,6,7,8,9};
@ -63,10 +63,6 @@ public class LogService {
private static Integer[] AUTH_SOURCE = {1, 2, 3, 11};
@Resource
private SysLogMapper sysLogMapper;
@ -77,7 +73,6 @@ public class LogService {
private LogManager logManager;
public List<SysLogGridDTO> query(BaseGridRequest request) {
request = detailRequest(request);
@ -90,8 +85,8 @@ public class LogService {
private BaseGridRequest detailRequest(BaseGridRequest request) {
List<ConditionEntity> conditions = request.getConditions();
if (CollectionUtils.isNotEmpty(conditions)) {
ConditionEntity optypeCondition = null;
ConditionEntity sourceCondition = null;
ConditionEntity uninCondition = null;
int matchIndex = -1;
for (int i = 0; i < conditions.size(); i++) {
ConditionEntity conditionEntity = conditions.get(i);
@ -100,23 +95,21 @@ public class LogService {
if (StringUtils.isNotBlank(field) && StringUtils.equals("optype", field) && ObjectUtils.isNotEmpty(value)) {
matchIndex = i;
optypeCondition = new ConditionEntity();
sourceCondition = new ConditionEntity();
uninCondition = new ConditionEntity();
List<String> values = (List<String>) value;
sourceCondition.setField("source_type");
optypeCondition.setField("operate_type");
List<Integer> opValue = values.stream().map(v -> Integer.parseInt(v.split("-")[0])).collect(Collectors.toList());
List<Integer> soValue = values.stream().map(v -> Integer.parseInt(v.split("-")[1])).collect(Collectors.toList());
optypeCondition.setValue(opValue);
sourceCondition.setValue(soValue);
optypeCondition.setOperator(conditionEntity.getOperator());
sourceCondition.setOperator(conditionEntity.getOperator());
uninCondition.setField("concat(operate_type, '-de-', source_type)");
List<String> uninValue = values.stream().map(v -> v.replace("-", "-de-")).collect(Collectors.toList());
uninCondition.setValue(uninValue);
uninCondition.setOperator(conditionEntity.getOperator());
}
}
if (matchIndex >= 0) {
conditions.remove(matchIndex);
if (ObjectUtils.isNotEmpty(optypeCondition))conditions.add(optypeCondition);
if (ObjectUtils.isNotEmpty(sourceCondition))conditions.add(sourceCondition);
if (ObjectUtils.isNotEmpty(uninCondition)) conditions.add(uninCondition);
}
}
return request;
@ -182,7 +175,6 @@ public class LogService {
}
return results;
}
@ -215,7 +207,6 @@ public class LogService {
}
public void exportExcel(BaseGridRequest request) throws Exception {
request = detailRequest(request);
HttpServletResponse response = ServletUtils.response();
@ -285,5 +276,4 @@ public class LogService {
}
}