diff --git a/docs/update/v1.0.8.md b/docs/update/v1.0.8.md index 50b325e0..64d79312 100644 --- a/docs/update/v1.0.8.md +++ b/docs/update/v1.0.8.md @@ -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); ``` diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/domain/ExecHostLogDO.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/domain/ExecHostLogDO.java index e6e950c5..3c9e1fee 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/domain/ExecHostLogDO.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/domain/ExecHostLogDO.java @@ -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") diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/vo/ExecHostLogVO.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/vo/ExecHostLogVO.java index 5260a96f..6824aaf0 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/vo/ExecHostLogVO.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/vo/ExecHostLogVO.java @@ -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; diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/exec/command/handler/BaseExecCommandHandler.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/exec/command/handler/BaseExecCommandHandler.java index 78c3c1da..b8a2aecd 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/exec/command/handler/BaseExecCommandHandler.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/exec/command/handler/BaseExecCommandHandler.java @@ -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)) { // 失败 diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/exec/command/handler/ExecCommandAnsiHandler.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/exec/command/handler/ExecCommandAnsiHandler.java index 744bd2e5..b313457f 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/exec/command/handler/ExecCommandAnsiHandler.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/exec/command/handler/ExecCommandAnsiHandler.java @@ -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: ") diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/ExecLogServiceImpl.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/ExecLogServiceImpl.java index 110d33af..a11cb412 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/ExecLogServiceImpl.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/ExecLogServiceImpl.java @@ -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() diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/resources/mapper/ExecHostLogMapper.xml b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/resources/mapper/ExecHostLogMapper.xml index 98177313..1f4b1991 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/resources/mapper/ExecHostLogMapper.xml +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/resources/mapper/ExecHostLogMapper.xml @@ -12,7 +12,7 @@ - + @@ -27,7 +27,7 @@ - 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 diff --git a/orion-ops-ui/src/api/exec/exec-log.ts b/orion-ops-ui/src/api/exec/exec-log.ts index 1a3f4245..bd15063b 100644 --- a/orion-ops-ui/src/api/exec/exec-log.ts +++ b/orion-ops-ui/src/api/exec/exec-log.ts @@ -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; diff --git a/orion-ops-ui/src/components/exec/log/panel/index.vue b/orion-ops-ui/src/components/exec/log/panel/index.vue index 0953a709..8221497c 100644 --- a/orion-ops-ui/src/components/exec/log/panel/index.vue +++ b/orion-ops-ui/src/components/exec/log/panel/index.vue @@ -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; } } diff --git a/orion-ops-ui/src/components/exec/log/panel/log-item.vue b/orion-ops-ui/src/components/exec/log/panel/log-item.vue index 228832b9..1082a4e7 100644 --- a/orion-ops-ui/src/components/exec/log/panel/log-item.vue +++ b/orion-ops-ui/src/components/exec/log/panel/log-item.vue @@ -12,15 +12,15 @@ {{ getDictValue(execHostStatusKey, host.status) }} - - + + - {{ host.exitStatus }} + {{ host.exitCode }} + :key="item.value as string"> @@ -51,11 +51,7 @@ :message-list="messageList" @load="loadMessage" @click="clickMessage" - @view="viewMessage" @delete="deleteMessage" /> - - @@ -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>({}); const messageList = ref>([]); 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); } }; diff --git a/orion-ops-ui/src/components/system/message-box/list.vue b/orion-ops-ui/src/components/system/message-box/list.vue index 815e2250..1920a21d 100644 --- a/orion-ops-ui/src/components/system/message-box/list.vue +++ b/orion-ops-ui/src/components/system/message-box/list.vue @@ -33,20 +33,13 @@
- - - 查看 -
-
+
- {{ dateFormat(new Date(message.createTime))}} + {{ dateFormat(new Date(message.createTime)) }}
@@ -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; diff --git a/orion-ops-ui/src/components/system/message-box/modal.vue b/orion-ops-ui/src/components/system/message-box/modal.vue deleted file mode 100644 index 0a787900..00000000 --- a/orion-ops-ui/src/components/system/message-box/modal.vue +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - diff --git a/orion-ops-ui/src/views/exec/exec-command-log/components/exec-command-log-table.vue b/orion-ops-ui/src/views/exec/exec-command-log/components/exec-command-log-table.vue index 3036d1a1..0ac7e2cf 100644 --- a/orion-ops-ui/src/views/exec/exec-command-log/components/exec-command-log-table.vue +++ b/orion-ops-ui/src/views/exec/exec-command-log/components/exec-command-log-table.vue @@ -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; }); }; diff --git a/orion-ops-ui/src/views/exec/exec-command-log/types/host-table.columns.ts b/orion-ops-ui/src/views/exec/exec-command-log/types/host-table.columns.ts index cb18fd99..04997dc3 100644 --- a/orion-ops-ui/src/views/exec/exec-command-log/types/host-table.columns.ts +++ b/orion-ops-ui/src/views/exec/exec-command-log/types/host-table.columns.ts @@ -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: '执行状态', diff --git a/orion-ops-ui/src/views/job/exec-job-log/components/exec-job-log-table.vue b/orion-ops-ui/src/views/job/exec-job-log/components/exec-job-log-table.vue index 84dcfcfb..89a1350f 100644 --- a/orion-ops-ui/src/views/job/exec-job-log/components/exec-job-log-table.vue +++ b/orion-ops-ui/src/views/job/exec-job-log/components/exec-job-log-table.vue @@ -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; }); };