diff --git a/backend/src/main/java/io/dataease/ext/ExtSysLogMapper.java b/backend/src/main/java/io/dataease/ext/ExtSysLogMapper.java index ae7875c5f0..e8cccd646c 100644 --- a/backend/src/main/java/io/dataease/ext/ExtSysLogMapper.java +++ b/backend/src/main/java/io/dataease/ext/ExtSysLogMapper.java @@ -3,13 +3,14 @@ package io.dataease.ext; import io.dataease.dto.log.FolderItem; import io.dataease.ext.query.GridExample; import io.dataease.plugins.common.base.domain.SysLogWithBLOBs; +import io.dataease.service.sys.log.LogQueryParam; import org.apache.ibatis.annotations.Param; import java.util.List; public interface ExtSysLogMapper { - List query(GridExample example); + List query(LogQueryParam example); List idAndName(@Param("ids") List ids, @Param("type") Integer type); } diff --git a/backend/src/main/java/io/dataease/ext/ExtSysLogMapper.xml b/backend/src/main/java/io/dataease/ext/ExtSysLogMapper.xml index 362c56f7ba..edc5b01233 100644 --- a/backend/src/main/java/io/dataease/ext/ExtSysLogMapper.xml +++ b/backend/src/main/java/io/dataease/ext/ExtSysLogMapper.xml @@ -7,16 +7,25 @@ - select * from - (select * from sys_log + (select * from sys_log where 1 = 1 - where - nick_name like concat('%', #{extendCondition} , '%') - or - source_name like concat('%', #{extendCondition} , '%') - or - position like concat('%', #{extendCondition} , '%') + and + ( + nick_name like concat('%', #{extendCondition} , '%') + or + source_name like concat('%', #{extendCondition} , '%') + or + position like concat('%', #{extendCondition} , '%') + + or + concat(operate_type, '-', source_type) in + + #{id} + + + ) ) t diff --git a/backend/src/main/java/io/dataease/service/sys/log/LogQueryParam.java b/backend/src/main/java/io/dataease/service/sys/log/LogQueryParam.java new file mode 100644 index 0000000000..13c5e9736f --- /dev/null +++ b/backend/src/main/java/io/dataease/service/sys/log/LogQueryParam.java @@ -0,0 +1,12 @@ +package io.dataease.service.sys.log; + +import io.dataease.ext.query.GridExample; +import lombok.Data; + +import java.util.List; + +@Data +public class LogQueryParam extends GridExample { + + private List unionIds; +} diff --git a/backend/src/main/java/io/dataease/service/sys/log/LogService.java b/backend/src/main/java/io/dataease/service/sys/log/LogService.java index d934d3623b..4a92767f15 100644 --- a/backend/src/main/java/io/dataease/service/sys/log/LogService.java +++ b/backend/src/main/java/io/dataease/service/sys/log/LogService.java @@ -70,11 +70,21 @@ public class LogService { public List query(KeyGridRequest request) { + + request = detailRequest(request); String keyWord = request.getKeyWord(); + List ids = null; GridExample gridExample = request.convertExample(); gridExample.setExtendCondition(keyWord); - List voLogs = extSysLogMapper.query(gridExample); + LogQueryParam logQueryParam = BeanUtils.copyBean(new LogQueryParam(), gridExample); + if (StringUtils.isNotBlank(keyWord)) { + List types = types(); + ids = types.stream().filter(item -> item.getName().toLowerCase().contains(keyWord.toLowerCase())).map(FolderItem::getId).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(ids)) + logQueryParam.setUnionIds(ids); + } + List voLogs = extSysLogMapper.query(logQueryParam); List dtos = voLogs.stream().map(this::convertDTO).collect(Collectors.toList()); return dtos; } @@ -256,12 +266,20 @@ public class LogService { public void exportExcel(KeyGridRequest request) throws Exception { request = detailRequest(request); String keyWord = request.getKeyWord(); + List ids = null; HttpServletResponse response = ServletUtils.response(); OutputStream outputStream = response.getOutputStream(); try { GridExample gridExample = request.convertExample(); gridExample.setExtendCondition(keyWord); - List lists = extSysLogMapper.query(gridExample); + LogQueryParam logQueryParam = BeanUtils.copyBean(new LogQueryParam(), gridExample); + if (StringUtils.isNotBlank(keyWord)) { + List types = types(); + ids = types.stream().filter(item -> item.getName().toLowerCase().contains(keyWord.toLowerCase())).map(FolderItem::getId).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(ids)) + logQueryParam.setUnionIds(ids); + } + List lists = extSysLogMapper.query(logQueryParam); List details = lists.stream().map(item -> { String operateTypeName = SysLogConstants.operateTypeName(item.getOperateType()); String sourceTypeName = SysLogConstants.sourceTypeName(item.getSourceType());