Merge pull request #2273 from dataease/pr@dev@feat_log_search_type

feat: 日志通过操作类型搜索
This commit is contained in:
fit2cloud-chenyw 2022-05-18 19:07:24 +08:00 committed by GitHub
commit eea37713ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import io.dataease.commons.constants.SysLogConstants;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.BeanUtils;
import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.controller.sys.base.ConditionEntity;
import io.dataease.dto.SysLogDTO;
import io.dataease.dto.SysLogGridDTO;
import io.dataease.dto.log.FolderItem;
@ -16,6 +17,8 @@ import io.dataease.i18n.Translator;
import io.dataease.plugins.common.base.domain.SysLogWithBLOBs;
import io.dataease.plugins.common.base.mapper.SysLogMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -44,6 +47,38 @@ public class LogService {
public List<SysLogGridDTO> query(BaseGridRequest request) {
List<ConditionEntity> conditions = request.getConditions();
if (CollectionUtils.isNotEmpty(conditions)) {
ConditionEntity optypeCondition = null;
ConditionEntity sourceCondition = null;
int matchIndex = -1;
for (int i = 0; i < conditions.size(); i++) {
ConditionEntity conditionEntity = conditions.get(i);
String field = conditionEntity.getField();
Object value = conditionEntity.getValue();
if (StringUtils.isNotBlank(field) && StringUtils.equals("optype", field) && ObjectUtils.isNotEmpty(value)) {
matchIndex = i;
optypeCondition = new ConditionEntity();
sourceCondition = 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());
}
}
if (matchIndex >= 0 ) {
conditions.remove(matchIndex);
if (ObjectUtils.isNotEmpty(optypeCondition))conditions.add(optypeCondition);
if (ObjectUtils.isNotEmpty(sourceCondition))conditions.add(sourceCondition);
}
}
GridExample gridExample = request.convertExample();
List<SysLogWithBLOBs> voLogs = extSysLogMapper.query(gridExample);
List<SysLogGridDTO> dtos = voLogs.stream().map(this::convertDTO).collect(Collectors.toList());

View File

@ -44,7 +44,7 @@ export default {
columns: [],
searchConfig: {
useQuickSearch: true,
useQuickSearch: false,
useComplexSearch: true,
quickPlaceholder: this.$t('log.search_by_key'),
components: [