🔨 执行命令.

This commit is contained in:
lijiahangmax
2024-03-17 21:09:58 +08:00
parent 2abf5bcf08
commit 2819df9c31
22 changed files with 429 additions and 67 deletions

View File

@@ -44,6 +44,10 @@ public class ExecHostLogDO extends BaseDO {
@TableField("host_name")
private String hostName;
@Schema(description = "主机地址")
@TableField("host_address")
private String hostAddress;
@Schema(description = "执行状态")
@TableField("status")
private String status;

View File

@@ -28,4 +28,13 @@ public class ExecCommandHostVO implements Serializable {
@Schema(description = "hostId")
private Long hostId;
@Schema(description = "主机名称")
private String hostName;
@Schema(description = "主机地址")
private String hostAddress;
@Schema(description = "执行状态")
private String status;
}

View File

@@ -37,6 +37,9 @@ public class ExecHostLogVO implements Serializable {
@Schema(description = "主机名称")
private String hostName;
@Schema(description = "主机地址")
private String hostAddress;
@Schema(description = "执行状态")
private String status;

View File

@@ -65,6 +65,8 @@ public class ExecServiceImpl implements ExecService {
private static final ReplacementFormatter FORMATTER = ReplacementFormatters.create("@{{ ", " }}")
.noMatchStrategy(NoMatchStrategy.KEEP);
private static final int DESC_OMIT = 60;
@Resource
private FileClient logsFileClient;
@@ -102,7 +104,13 @@ public class ExecServiceImpl implements ExecService {
.userId(userId)
.username(user.getUsername())
.source(ExecSourceEnum.BATCH.name())
.description(Strings.ifBlank(request.getDescription(), Strings.retain(command, 60) + Const.OMIT))
.description(Strings.ifBlank(request.getDescription(), () -> {
if (command.length() < DESC_OMIT + 3) {
return command;
} else {
return command.substring(0, DESC_OMIT) + Const.OMIT;
}
}))
.command(command)
.parameterSchema(request.getParameterSchema())
.timeout(request.getTimeout())
@@ -120,6 +128,7 @@ public class ExecServiceImpl implements ExecService {
.logId(execId)
.hostId(s.getId())
.hostName(s.getName())
.hostAddress(s.getAddress())
.status(ExecHostStatusEnum.WAITING.name())
.command(FORMATTER.format(command, parameter))
.parameter(parameter)
@@ -136,6 +145,9 @@ public class ExecServiceImpl implements ExecService {
.map(s -> ExecCommandHostVO.builder()
.id(s.getId())
.hostId(s.getHostId())
.hostName(s.getHostName())
.hostAddress(s.getHostAddress())
.status(s.getStatus())
.build())
.collect(Collectors.toList());
return ExecCommandVO.builder()

View File

@@ -8,6 +8,7 @@
<result column="log_id" property="logId"/>
<result column="host_id" property="hostId"/>
<result column="host_name" property="hostName"/>
<result column="host_address" property="hostAddress"/>
<result column="status" property="status"/>
<result column="command" property="command"/>
<result column="parameter" property="parameter"/>
@@ -25,7 +26,7 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, log_id, host_id, host_name, status, command, parameter, exit_status, log_path, error_message, start_time, finish_time, create_time, update_time, creator, updater, deleted
id, log_id, host_id, host_name, host_address, status, command, parameter, exit_status, log_path, error_message, start_time, finish_time, create_time, update_time, creator, updater, deleted
</sql>
</mapper>