🚧 修改 exitCode.
This commit is contained in:
@@ -3,9 +3,53 @@
|
||||
> sql 脚本 - DDL
|
||||
|
||||
```sql
|
||||
-- 修改字段名称
|
||||
ALTER TABLE `exec_host_log`
|
||||
CHANGE COLUMN `exit_status` `exit_code` int(0) NULL DEFAULT NULL COMMENT '退出码' AFTER `parameter`;
|
||||
|
||||
-- 系统消息
|
||||
DROP TABLE IF EXISTS `system_message`;
|
||||
CREATE TABLE `system_message`
|
||||
(
|
||||
`id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
`classify` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '消息分类',
|
||||
`type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '消息类型',
|
||||
`status` tinyint(0) NULL DEFAULT NULL COMMENT '消息状态',
|
||||
`rel_key` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '消息关联',
|
||||
`title` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '标题',
|
||||
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '消息内容',
|
||||
`receiver_id` bigint(0) NULL DEFAULT NULL COMMENT '接收人id',
|
||||
`receiver_username` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '接收人用户名',
|
||||
`create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
|
||||
`deleted` tinyint(1) NULL DEFAULT 0 COMMENT '是否删除 0未删除 1已删除',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `idx_receiver_classify` (`receiver_id`, `classify`) USING BTREE
|
||||
) ENGINE = InnoDB
|
||||
AUTO_INCREMENT = 1
|
||||
CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci COMMENT = '系统消息'
|
||||
ROW_FORMAT = Dynamic;
|
||||
```
|
||||
|
||||
> sql 脚本 - DML
|
||||
|
||||
```sql
|
||||
-- 菜单
|
||||
DELETE FROM system_menu WHERE id IN (161, 175, 197, 198) OR id > 202;
|
||||
INSERT INTO `system_menu` VALUES (161, 176, '执行模板', NULL, 2, 50, 1, 1, 1, 0, 'IconBookmark', NULL, 'execTemplate', '2024-03-07 18:32:41', '2024-05-14 15:58:51', '1', '1', 0);
|
||||
INSERT INTO `system_menu` VALUES (197, 176, '批量上传', NULL, 2, 30, 1, 1, 1, 0, 'IconUpload', NULL, 'batchUpload', '2024-05-08 22:12:23', '2024-05-14 15:58:44', '1', '1', 0);
|
||||
INSERT INTO `system_menu` VALUES (198, 176, '上传任务', NULL, 2, 40, 1, 1, 1, 0, 'IconCloud', NULL, 'uploadTask', '2024-05-08 22:16:05', '2024-05-14 15:58:46', '1', '1', 0);
|
||||
|
||||
-- 字典项
|
||||
DELETE FROM dict_key WHERE id >= 43;
|
||||
INSERT INTO `dict_key` VALUES (43, 'messageType', 'STRING', '[{\"name\": \"tagLabel\", \"type\": \"STRING\"}, {\"name\": \"tagVisible\", \"type\": \"STRING\"}, {\"name\": \"tagColor\", \"type\": \"STRING\"}, {\"name\": \"redirectComponent\", \"type\": \"STRING\"}]', '消息类型', '2024-05-13 12:07:56', '2024-05-14 14:48:28', '1', '1', 0);
|
||||
INSERT INTO `dict_key` VALUES (44, 'messageClassify', 'STRING', '[]', '消息分类', '2024-05-13 15:06:27', '2024-05-13 15:06:27', '1', '1', 0);
|
||||
|
||||
-- 字典值
|
||||
DELETE FROM dict_value WHERE id >= 295;
|
||||
INSERT INTO `dict_value` VALUES (295, 43, 'messageType', 'EXEC_FAILED', '执行失败', '{\"tagColor\": \"red\", \"tagLabel\": \"部分失败\", \"tagVisible\": \"true\", \"redirectComponent\": \"execCommand\"}', 10, '2024-05-13 12:07:56', '2024-05-14 15:19:19', '1', '1', 0);
|
||||
INSERT INTO `dict_value` VALUES (296, 43, 'messageType', 'UPLOAD_FAILED', '上传失败', '{\"tagColor\": \"red\", \"tagLabel\": \"部分失败\", \"tagVisible\": \"true\", \"redirectComponent\": \"batchUpload\"}', 20, '2024-05-13 12:07:56', '2024-05-14 15:11:21', '1', '1', 0);
|
||||
INSERT INTO `dict_value` VALUES (297, 44, 'messageClassify', 'NOTICE', '通知', '{}', 10, '2024-05-13 15:06:27', '2024-05-13 15:06:27', '1', '1', 0);
|
||||
INSERT INTO `dict_value` VALUES (298, 44, 'messageClassify', 'TODO', '待办', '{}', 20, '2024-05-13 15:06:27', '2024-05-13 15:06:27', '1', '1', 0);
|
||||
```
|
||||
|
||||
@@ -61,8 +61,8 @@ public class ExecHostLogDO extends BaseDO {
|
||||
private String parameter;
|
||||
|
||||
@Schema(description = "退出码")
|
||||
@TableField("exit_status")
|
||||
private Integer exitStatus;
|
||||
@TableField("exit_code")
|
||||
private Integer exitCode;
|
||||
|
||||
@Schema(description = "日志路径")
|
||||
@TableField("log_path")
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ExecHostLogVO implements Serializable {
|
||||
private String parameter;
|
||||
|
||||
@Schema(description = "退出码")
|
||||
private Integer exitStatus;
|
||||
private Integer exitCode;
|
||||
|
||||
@Schema(description = "错误信息")
|
||||
private String errorMessage;
|
||||
|
||||
@@ -230,7 +230,7 @@ public abstract class BaseExecCommandHandler implements IExecCommandHandler {
|
||||
} else if (ExecHostStatusEnum.COMPLETED.equals(status)) {
|
||||
// 完成
|
||||
updateRecord.setFinishTime(new Date());
|
||||
updateRecord.setExitStatus(executor.getExitCode());
|
||||
updateRecord.setExitCode(executor.getExitCode());
|
||||
this.exitCode = executor.getExitCode();
|
||||
} else if (ExecHostStatusEnum.FAILED.equals(status)) {
|
||||
// 失败
|
||||
|
||||
@@ -149,17 +149,17 @@ public class ExecCommandAnsiHandler extends BaseExecCommandHandler {
|
||||
.append(Dates.current())
|
||||
.newLine();
|
||||
} else {
|
||||
long ms = this.updateRecord.getFinishTime().getTime() - this.updateRecord.getStartTime().getTime();
|
||||
Integer exitStatus = this.updateRecord.getExitStatus();
|
||||
long ms = updateRecord.getFinishTime().getTime() - updateRecord.getStartTime().getTime();
|
||||
Integer exitCode = updateRecord.getExitCode();
|
||||
// 执行完成
|
||||
appender.append(AnsiForeground.BRIGHT_GREEN, "< 命令执行完成 ")
|
||||
.append(Dates.current())
|
||||
.newLine()
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "exit: ");
|
||||
if (ExitCode.isSuccess(exitStatus)) {
|
||||
appender.append(AnsiForeground.BRIGHT_GREEN, exitStatus);
|
||||
if (ExitCode.isSuccess(exitCode)) {
|
||||
appender.append(AnsiForeground.BRIGHT_GREEN, exitCode);
|
||||
} else {
|
||||
appender.append(AnsiForeground.BRIGHT_RED, exitStatus);
|
||||
appender.append(AnsiForeground.BRIGHT_RED, exitCode);
|
||||
}
|
||||
appender.newLine()
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "used: ")
|
||||
|
||||
@@ -156,7 +156,7 @@ public class ExecLogServiceImpl implements ExecLogService {
|
||||
ExecHostLogDO::getStatus,
|
||||
ExecHostLogDO::getStartTime,
|
||||
ExecHostLogDO::getFinishTime,
|
||||
ExecHostLogDO::getExitStatus,
|
||||
ExecHostLogDO::getExitCode,
|
||||
ExecHostLogDO::getErrorMessage)
|
||||
.in(ExecHostLogDO::getLogId, idList)
|
||||
.then()
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<result column="status" property="status"/>
|
||||
<result column="command" property="command"/>
|
||||
<result column="parameter" property="parameter"/>
|
||||
<result column="exit_status" property="exitStatus"/>
|
||||
<result column="exit_code" property="exitCode"/>
|
||||
<result column="log_path" property="logPath"/>
|
||||
<result column="script_path" property="scriptPath"/>
|
||||
<result column="error_message" property="errorMessage"/>
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, log_id, host_id, host_name, host_address, status, command, parameter, exit_status, log_path, script_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_code, log_path, script_path, error_message, start_time, finish_time, create_time, update_time, creator, updater, deleted
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -54,7 +54,7 @@ export interface ExecHostLogQueryResponse extends TableData {
|
||||
status: string;
|
||||
command: string;
|
||||
parameter: string;
|
||||
exitStatus: number;
|
||||
exitCode: number;
|
||||
errorMessage: string;
|
||||
startTime: number;
|
||||
finishTime: number;
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
host.startTime = hostStatus.startTime;
|
||||
// 结束时间绑定了使用时间 如果未完成则使用当前时间
|
||||
host.finishTime = hostStatus.finishTime || Date.now();
|
||||
host.exitStatus = hostStatus.exitStatus;
|
||||
host.exitCode = hostStatus.exitCode;
|
||||
host.errorMessage = hostStatus.errorMessage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,15 +12,15 @@
|
||||
<a-tag :color="getDictValue(execHostStatusKey, host.status, 'color')">
|
||||
{{ getDictValue(execHostStatusKey, host.status) }}
|
||||
</a-tag>
|
||||
<!-- exitStatus -->
|
||||
<a-tag v-if="host.exitStatus || host.exitStatus === 0"
|
||||
:color="host.exitStatus === 0 ? 'arcoblue' : 'orangered'"
|
||||
title="exit status">
|
||||
<!-- exitCode -->
|
||||
<a-tag v-if="host.exitCode || host.exitCode === 0"
|
||||
:color="host.exitCode === 0 ? 'arcoblue' : 'orangered'"
|
||||
title="exit code">
|
||||
<template #icon>
|
||||
<icon-check v-if="host.exitStatus === 0" />
|
||||
<icon-check v-if="host.exitCode === 0" />
|
||||
<icon-exclamation v-else />
|
||||
</template>
|
||||
<span class="tag-value">{{ host.exitStatus }}</span>
|
||||
<span class="tag-value">{{ host.exitCode }}</span>
|
||||
</a-tag>
|
||||
<!-- 持续时间 -->
|
||||
<a-tag v-if="host.startTime"
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
@change="loadClassifyMessage">
|
||||
<!-- 消息列表 -->
|
||||
<a-tab-pane v-for="item in toOptions(messageClassifyKey)"
|
||||
:key="item.value">
|
||||
:key="item.value as string">
|
||||
<!-- 标题 -->
|
||||
<template #title>
|
||||
<span class="usn">{{ item.label }} ({{ classifyCount[item.value] || 0 }})</span>
|
||||
<span class="usn">{{ item.label }} ({{ classifyCount[item.value as any] || 0 }})</span>
|
||||
</template>
|
||||
<!-- 消息列表 -->
|
||||
</a-tab-pane>
|
||||
@@ -51,11 +51,7 @@
|
||||
:message-list="messageList"
|
||||
@load="loadMessage"
|
||||
@click="clickMessage"
|
||||
@view="viewMessage"
|
||||
@delete="deleteMessage" />
|
||||
<!-- 模态框 -->
|
||||
<modal ref="modalRef"
|
||||
@delete="deleteMessage" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -78,11 +74,10 @@
|
||||
} from '@/api/system/message';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { clearHtmlTag, replaceHtmlTag } from '@/utils';
|
||||
import { useDictStore } from '@/store';
|
||||
import { dictKeys, messageClassifyKey, messageTypeKey, defaultClassify, MESSAGE_CONFIG_KEY, messageLimit, MessageStatus } from './const';
|
||||
import List from './list.vue';
|
||||
import Modal from './modal.vue';
|
||||
import { clearHtmlTag, replaceHtmlTag } from '@/utils';
|
||||
|
||||
const { loading: fetchLoading, setLoading: setFetchLoading } = useLoading();
|
||||
const { loading: messageLoading, setLoading: setMessageLoading } = useLoading();
|
||||
@@ -94,7 +89,6 @@
|
||||
const classifyCount = ref<Record<string, number>>({});
|
||||
const messageList = ref<Array<MessageRecordResponse>>([]);
|
||||
const hasMore = ref(true);
|
||||
const modalRef = ref();
|
||||
|
||||
// 重新加载消息
|
||||
const reloadAllMessage = async () => {
|
||||
@@ -193,26 +187,6 @@
|
||||
if (redirectComponent && redirectComponent !== '0') {
|
||||
// 跳转组件
|
||||
router.push({ name: redirectComponent, query: { key: message.relKey } });
|
||||
} else {
|
||||
// 打开消息模态框
|
||||
modalRef.value.open(message);
|
||||
}
|
||||
};
|
||||
|
||||
// 查看消息
|
||||
const viewMessage = async (message: MessageRecordResponse) => {
|
||||
setMessageLoading(true);
|
||||
try {
|
||||
// 设置为已读
|
||||
if (message.status === MessageStatus.UNREAD) {
|
||||
await updateSystemMessageRead(message.id);
|
||||
message.status = MessageStatus.READ;
|
||||
}
|
||||
// 打开消息模态框
|
||||
modalRef.value.open(message);
|
||||
} catch (ex) {
|
||||
} finally {
|
||||
setMessageLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -33,20 +33,13 @@
|
||||
<!-- tag -->
|
||||
<div class="message-item-title-status">
|
||||
<template v-if="getDictValue(messageTypeKey, message.type, 'tagVisible', false)">
|
||||
<a-tag size="mini" :color="getDictValue(messageTypeKey, message.type, 'tagColor')">
|
||||
<a-tag size="small" :color="getDictValue(messageTypeKey, message.type, 'tagColor')">
|
||||
{{ getDictValue(messageTypeKey, message.type, 'tagLabel') }}
|
||||
</a-tag>
|
||||
</template>
|
||||
</div>
|
||||
<!-- 操作 -->
|
||||
<div class="message-item-title-actions">
|
||||
<!-- 查看 -->
|
||||
<a-button class="mr4"
|
||||
size="mini"
|
||||
type="text"
|
||||
@click.stop="emits('view', message)">
|
||||
查看
|
||||
</a-button>
|
||||
<!-- 删除 -->
|
||||
<a-button size="mini"
|
||||
type="text"
|
||||
@@ -57,12 +50,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- 内容 -->
|
||||
<div v-html="message.contentHtml"
|
||||
class="message-item-content"
|
||||
:title="message.content" />
|
||||
<div v-html="message.contentHtml" class="message-item-content" />
|
||||
<!-- 时间 -->
|
||||
<div class="message-item-time">
|
||||
{{ dateFormat(new Date(message.createTime))}}
|
||||
{{ dateFormat(new Date(message.createTime)) }}
|
||||
</div>
|
||||
</div>
|
||||
<!-- 加载中 -->
|
||||
@@ -98,7 +89,7 @@
|
||||
import { useDictStore } from '@/store';
|
||||
import { dateFormat } from '@/utils';
|
||||
|
||||
const emits = defineEmits(['load', 'click', 'view', 'delete']);
|
||||
const emits = defineEmits(['load', 'click', 'delete']);
|
||||
const props = defineProps<{
|
||||
fetchLoading: boolean;
|
||||
messageLoading: boolean;
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
<template>
|
||||
<a-modal v-model:visible="visible"
|
||||
title-align="start"
|
||||
:title="record.title"
|
||||
:top="80"
|
||||
:align-center="false"
|
||||
:unmount-on-close="true"
|
||||
ok-text="删除"
|
||||
:hide-cancel="true"
|
||||
:ok-button-props="{ status: 'danger', size: 'small' }"
|
||||
:body-style="{ padding: '20px' }"
|
||||
@ok="emits('delete', record)">
|
||||
<div class="content" v-html="record.contentHtml" />
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'messageBoxModal'
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { MessageRecordResponse } from '@/api/system/message';
|
||||
import useVisible from '@/hooks/visible';
|
||||
import { ref } from 'vue';
|
||||
|
||||
const emits = defineEmits(['delete']);
|
||||
|
||||
const { visible, setVisible } = useVisible();
|
||||
|
||||
const record = ref<MessageRecordResponse>({} as MessageRecordResponse);
|
||||
|
||||
// 打开
|
||||
const open = (message: MessageRecordResponse) => {
|
||||
record.value = message;
|
||||
setVisible(true);
|
||||
};
|
||||
|
||||
defineExpose({ open });
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.content {
|
||||
font-size: 16px;
|
||||
color: var(--color-text-2);
|
||||
}
|
||||
</style>
|
||||
@@ -374,7 +374,7 @@
|
||||
host.status = s.status;
|
||||
host.startTime = s.startTime;
|
||||
host.finishTime = s.finishTime;
|
||||
host.exitStatus = s.exitStatus;
|
||||
host.exitCode = s.exitCode;
|
||||
host.errorMessage = s.errorMessage;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -18,12 +18,12 @@ const columns = [
|
||||
tooltip: true,
|
||||
}, {
|
||||
title: '退出码',
|
||||
dataIndex: 'exitStatus',
|
||||
slotName: 'exitStatus',
|
||||
dataIndex: 'exitCode',
|
||||
slotName: 'exitCode',
|
||||
align: 'left',
|
||||
width: 118,
|
||||
render: ({ record }) => {
|
||||
return isNumber(record.exitStatus) ? record.exitStatus : '-';
|
||||
return isNumber(record.exitCode) ? record.exitCode : '-';
|
||||
},
|
||||
}, {
|
||||
title: '执行状态',
|
||||
|
||||
@@ -339,7 +339,7 @@
|
||||
host.status = s.status;
|
||||
host.startTime = s.startTime;
|
||||
host.finishTime = s.finishTime;
|
||||
host.exitStatus = s.exitStatus;
|
||||
host.exitCode = s.exitCode;
|
||||
host.errorMessage = s.errorMessage;
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user