✨ 新页面打开执行日志.
This commit is contained in:
@@ -3,6 +3,9 @@ package com.orion.ops.module.asset.dao;
|
||||
import com.orion.ops.framework.mybatis.core.mapper.IMapper;
|
||||
import com.orion.ops.module.asset.entity.domain.ExecLogDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 批量执行日志 Mapper 接口
|
||||
@@ -14,4 +17,16 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface ExecLogDAO extends IMapper<ExecLogDO> {
|
||||
|
||||
/**
|
||||
* 获取执行历史
|
||||
*
|
||||
* @param source source
|
||||
* @param userId userId
|
||||
* @param limit limit
|
||||
* @return rows
|
||||
*/
|
||||
List<ExecLogDO> getExecHistory(@Param("source") String source,
|
||||
@Param("userId") Long userId,
|
||||
@Param("limit") Integer limit);
|
||||
|
||||
}
|
||||
|
||||
@@ -86,24 +86,18 @@ public class ExecLogServiceImpl implements ExecLogService {
|
||||
@Override
|
||||
public List<ExecLogVO> getExecHistory(ExecLogQueryRequest request) {
|
||||
// 查询执行记录
|
||||
List<ExecLogVO> logs = execLogDAO.of()
|
||||
.createWrapper()
|
||||
.eq(ExecLogDO::getSource, request.getSource())
|
||||
.eq(ExecLogDO::getUserId, request.getUserId())
|
||||
.groupBy(ExecLogDO::getDescription)
|
||||
.orderByDesc(ExecLogDO::getId)
|
||||
.then()
|
||||
.limit(request)
|
||||
.list(ExecLogConvert.MAPPER::to);
|
||||
if (logs.isEmpty()) {
|
||||
return logs;
|
||||
List<ExecLogDO> rows = execLogDAO.getExecHistory(request.getSource(), request.getUserId(), request.getLimit());
|
||||
if (rows.isEmpty()) {
|
||||
return Lists.empty();
|
||||
}
|
||||
List<ExecLogVO> logs = ExecLogConvert.MAPPER.to(rows);
|
||||
List<Long> logIdList = logs.stream()
|
||||
.map(ExecLogVO::getId)
|
||||
.collect(Collectors.toList());
|
||||
// 设置执行主机id
|
||||
Map<Long, List<Long>> hostIdRel = execHostLogDAO.of()
|
||||
.createWrapper()
|
||||
.select(ExecHostLogDO::getId, ExecHostLogDO::getLogId, ExecHostLogDO::getHostId)
|
||||
.in(ExecHostLogDO::getLogId, logIdList)
|
||||
.then()
|
||||
.stream()
|
||||
|
||||
@@ -28,4 +28,17 @@
|
||||
id, user_id, username, source, source_id, description, command, parameter_schema, timeout, status, start_time, finish_time, create_time, update_time, creator, updater, deleted
|
||||
</sql>
|
||||
|
||||
<select id="getExecHistory" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
, max(id) max_id
|
||||
FROM exec_log
|
||||
WHERE deleted = 0
|
||||
AND source = #{source}
|
||||
AND user_id = #{userId}
|
||||
GROUP BY description
|
||||
ORDER BY max_id DESC
|
||||
LIMIT #{limit}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user