Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
wangjiahao 2022-08-30 13:05:55 +08:00
commit 3ea23844d2
4 changed files with 51 additions and 11 deletions

View File

@ -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<SysLogWithBLOBs> query(GridExample example);
List<SysLogWithBLOBs> query(LogQueryParam example);
List<FolderItem> idAndName(@Param("ids") List<String> ids, @Param("type") Integer type);
}

View File

@ -7,16 +7,25 @@
<select id="query" parameterType="io.dataease.ext.query.GridExample" resultMap="io.dataease.plugins.common.base.mapper.SysLogMapper.ResultMapWithBLOBs">
<select id="query" parameterType="io.dataease.service.sys.log.LogQueryParam" resultMap="io.dataease.plugins.common.base.mapper.SysLogMapper.ResultMapWithBLOBs">
select * from
(select * from sys_log
(select * from sys_log where 1 = 1
<if test="extendCondition != null">
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} , '%')
<if test="unionIds != null">
or
concat(operate_type, '-', source_type) in
<foreach collection="unionIds" item="id" index="index" open="(" separator="," close=")">
#{id}
</foreach>
</if>
)
</if>
) t

View File

@ -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<String> unionIds;
}

View File

@ -70,11 +70,21 @@ public class LogService {
public List<SysLogGridDTO> query(KeyGridRequest request) {
request = detailRequest(request);
String keyWord = request.getKeyWord();
List<String> ids = null;
GridExample gridExample = request.convertExample();
gridExample.setExtendCondition(keyWord);
List<SysLogWithBLOBs> voLogs = extSysLogMapper.query(gridExample);
LogQueryParam logQueryParam = BeanUtils.copyBean(new LogQueryParam(), gridExample);
if (StringUtils.isNotBlank(keyWord)) {
List<FolderItem> 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<SysLogWithBLOBs> voLogs = extSysLogMapper.query(logQueryParam);
List<SysLogGridDTO> 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<String> ids = null;
HttpServletResponse response = ServletUtils.response();
OutputStream outputStream = response.getOutputStream();
try {
GridExample gridExample = request.convertExample();
gridExample.setExtendCondition(keyWord);
List<SysLogWithBLOBs> lists = extSysLogMapper.query(gridExample);
LogQueryParam logQueryParam = BeanUtils.copyBean(new LogQueryParam(), gridExample);
if (StringUtils.isNotBlank(keyWord)) {
List<FolderItem> 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<SysLogWithBLOBs> lists = extSysLogMapper.query(logQueryParam);
List<String[]> details = lists.stream().map(item -> {
String operateTypeName = SysLogConstants.operateTypeName(item.getOperateType());
String sourceTypeName = SysLogConstants.sourceTypeName(item.getSourceType());