Merge remote-tracking branch 'origin/lichang'
This commit is contained in:
@@ -7,57 +7,58 @@ SET FOREIGN_KEY_CHECKS = 0;
|
|||||||
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `ne_host`;
|
DROP TABLE IF EXISTS `ne_host`;
|
||||||
|
CREATE TABLE `ne_host` (
|
||||||
CREATE TABLE `ne_host` (
|
|
||||||
`host_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主机主键',
|
`host_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主机主键',
|
||||||
`host_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '主机类型 ssh telnet',
|
`host_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '连接类型 ssh telnet redis',
|
||||||
`group_id` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '分组(0默认 1网元 2系统)',
|
`group_id` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '分组(0默认 1网元 2系统)',
|
||||||
`title` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '标题名称',
|
`title` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '标题名称',
|
||||||
`addr` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '主机地址',
|
`addr` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '主机地址',
|
||||||
`port` int NULL DEFAULT 22 COMMENT 'SSH端口',
|
`port` int DEFAULT '22' COMMENT '端口 22 4100 6379',
|
||||||
`user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '主机用户名',
|
`user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '认证用户名',
|
||||||
`auth_mode` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '认证模式(0密码 1主机私钥 2已免密)',
|
`auth_mode` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '认证模式(0密码 1主机私钥 2已免密)',
|
||||||
`password` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '认证密码',
|
`password` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '认证密码',
|
||||||
`private_key` varchar(6000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '认证私钥',
|
`private_key` varchar(6000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '认证私钥',
|
||||||
`pass_phrase` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '认证私钥密码',
|
`pass_phrase` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '认证私钥密码',
|
||||||
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
|
`db_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '数据库名称',
|
||||||
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
|
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '备注',
|
||||||
`create_time` bigint NULL DEFAULT 0 COMMENT '创建时间',
|
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
|
||||||
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
|
`create_time` bigint DEFAULT '0' COMMENT '创建时间',
|
||||||
`update_time` bigint NULL DEFAULT 0 COMMENT '更新时间',
|
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
|
||||||
|
`update_time` bigint DEFAULT '0' COMMENT '更新时间',
|
||||||
PRIMARY KEY (`host_id`) USING BTREE,
|
PRIMARY KEY (`host_id`) USING BTREE,
|
||||||
UNIQUE INDEX `uk_type_group_title`(`host_type` ASC, `group_id` ASC, `title` ASC) USING BTREE COMMENT '同组内名称唯一'
|
UNIQUE KEY `uk_type_group_title` (`host_type`,`group_id`,`title`) USING BTREE COMMENT '同组内名称唯一'
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '网元主机表' ROW_FORMAT = DYNAMIC;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元主机表';
|
||||||
|
|
||||||
-- 初始数据对应网元
|
-- 初始数据对应网元
|
||||||
INSERT INTO `ne_host` VALUES (1, 'ssh', '1', 'OMC_001_22', '127.0.0.1', 22, 'omcuser', '0', 'E4Tm7TQuydT1aOXXYvjAIUnSSwqSPaeZ59Ls4qRcxZU=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (1, 'ssh', '1', 'OMC_001_22', '127.0.0.1', 22, 'omcuser', '2', '', '', '', '', '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
|
||||||
INSERT INTO `ne_host` VALUES (2, 'telnet', '1', 'OMC_001_4100', '127.0.0.1', 4100, 'admin', '0', 'gsjnG8iYpON7T9ae21l955gZi8RRsBWr2WRP31x6ENg=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (2, 'telnet', '1', 'OMC_001_4100', '127.0.0.1', 4100, 'admin', '0', 'NUBonCin4GZgl7o12YjeClE8ToQmYp9KWdhMjSNxc2M=', '', '', '', '', 'supervisor', 1729063407333, 'supervisor', 1729063818375);
|
||||||
INSERT INTO `ne_host` VALUES (3, 'ssh', '1', 'IMS_001_22', '172.16.5.110', 22, 'omcuser', '0', 'E4Tm7TQuydT1aOXXYvjAIUnSSwqSPaeZ59Ls4qRcxZU=', '', '', '', 'admin', 1708314682742, NULL, 0);
|
INSERT INTO `ne_host` VALUES (3, 'ssh', '1', 'IMS_001_22', '172.16.5.110', 22, 'omcuser', '2', '', '', '', '', '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
|
||||||
INSERT INTO `ne_host` VALUES (4, 'telnet', '1', 'IMS_001_4100', '172.16.5.110', 4100, 'admin', '0', 'gsjnG8iYpON7T9ae21l955gZi8RRsBWr2WRP31x6ENg=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (4, 'telnet', '1', 'IMS_001_4100', '172.16.5.110', 4100, 'admin', '0', 'NUBonCin4GZgl7o12YjeClE8ToQmYp9KWdhMjSNxc2M=', '', '', '', '', 'supervisor', 1729063407333, 'supervisor', 1729063818375);
|
||||||
INSERT INTO `ne_host` VALUES (5, 'ssh', '1', 'AMF_001_22', '172.16.5.120', 22, 'omcuser', '0', 'E4Tm7TQuydT1aOXXYvjAIUnSSwqSPaeZ59Ls4qRcxZU=', '', '', '', 'admin', 1708314682742, NULL, 0);
|
INSERT INTO `ne_host` VALUES (5, 'ssh', '1', 'AMF_001_22', '172.16.5.120', 22, 'omcuser', '2', '', '', '', '', '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
|
||||||
INSERT INTO `ne_host` VALUES (6, 'telnet', '1', 'AMF_001_4100', '172.16.5.120', 4100, 'admin', '0', 'gsjnG8iYpON7T9ae21l955gZi8RRsBWr2WRP31x6ENg=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (6, 'telnet', '1', 'AMF_001_4100', '172.16.5.120', 4100, 'admin', '0', 'NUBonCin4GZgl7o12YjeClE8ToQmYp9KWdhMjSNxc2M=', '', '', '', '', 'supervisor', 1729063407333, 'supervisor', 1729063818375);
|
||||||
INSERT INTO `ne_host` VALUES (7, 'ssh', '1', 'AUSF_001_22', '172.16.5.130', 22, 'omcuser', '0', 'E4Tm7TQuydT1aOXXYvjAIUnSSwqSPaeZ59Ls4qRcxZU=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (7, 'ssh', '1', 'AUSF_001_22', '172.16.5.130', 22, 'omcuser', '2', '', '', '', '', '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
|
||||||
INSERT INTO `ne_host` VALUES (8, 'telnet', '1', 'AUSF_001_4100', '172.16.5.130', 4100, 'admin', '0', 'gsjnG8iYpON7T9ae21l955gZi8RRsBWr2WRP31x6ENg=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (8, 'telnet', '1', 'AUSF_001_4100', '172.16.5.130', 4100, 'admin', '0', 'NUBonCin4GZgl7o12YjeClE8ToQmYp9KWdhMjSNxc2M=', '', '', '', '', 'supervisor', 1729063407333, 'supervisor', 1729063818375);
|
||||||
INSERT INTO `ne_host` VALUES (9, 'ssh', '1', 'UDM_001_22', '172.16.5.140', 22, 'omcuser', '0', 'E4Tm7TQuydT1aOXXYvjAIUnSSwqSPaeZ59Ls4qRcxZU=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (9, 'ssh', '1', 'UDM_001_22', '172.16.5.140', 22, 'omcuser', '2', '', '', '', '', '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
|
||||||
INSERT INTO `ne_host` VALUES (10, 'telnet', '1', 'UDM_001_4100', '172.16.5.140', 4100, 'admin', '0', 'gsjnG8iYpON7T9ae21l955gZi8RRsBWr2WRP31x6ENg=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (10, 'telnet', '1', 'UDM_001_4100', '172.16.5.140', 4100, 'admin', '0', 'NUBonCin4GZgl7o12YjeClE8ToQmYp9KWdhMjSNxc2M=', '', '', '', '', 'supervisor', 1729063407333, 'supervisor', 1729063818375);
|
||||||
INSERT INTO `ne_host` VALUES (11, 'ssh', '1', 'SMF_001_22', '172.16.5.150', 22, 'omcuser', '0', 'E4Tm7TQuydT1aOXXYvjAIUnSSwqSPaeZ59Ls4qRcxZU=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (11, 'redis', '1', 'UDM_001_6379', '172.16.5.140', 6379, 'udmdb', '0', 'nO3fEhtuKuBkQE5ozsUhNfzn02vhnyxYTEiPn2CIlr4=', '', '', '0', '', 'supervisor', 1728989383529, 'supervisor', 1729065073516);
|
||||||
INSERT INTO `ne_host` VALUES (12, 'telnet', '1', 'SMF_001_4100', '172.16.5.150', 4100, 'admin', '0', 'gsjnG8iYpON7T9ae21l955gZi8RRsBWr2WRP31x6ENg=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (12, 'ssh', '1', 'SMF_001_22', '172.16.5.150', 22, 'omcuser', '2', '', '', '', '', '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
|
||||||
INSERT INTO `ne_host` VALUES (13, 'ssh', '1', 'PCF_001_22', '172.16.5.160', 22, 'omcuser', '0', 'E4Tm7TQuydT1aOXXYvjAIUnSSwqSPaeZ59Ls4qRcxZU=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (13, 'telnet', '1', 'SMF_001_4100', '172.16.5.150', 4100, 'admin', '0', 'NUBonCin4GZgl7o12YjeClE8ToQmYp9KWdhMjSNxc2M=', '', '', '', '', 'supervisor', 1729063407333, 'supervisor', 1729063818375);
|
||||||
INSERT INTO `ne_host` VALUES (14, 'telnet', '1', 'PCF_001_4100', '172.16.5.160', 4100, 'admin', '0', 'gsjnG8iYpON7T9ae21l955gZi8RRsBWr2WRP31x6ENg=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (14, 'ssh', '1', 'PCF_001_22', '172.16.5.160', 22, 'omcuser', '2', '', '', '', '', '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
|
||||||
INSERT INTO `ne_host` VALUES (15, 'ssh', '1', 'NSSF_001_22', '172.16.5.170', 22, 'omcuser', '0', 'E4Tm7TQuydT1aOXXYvjAIUnSSwqSPaeZ59Ls4qRcxZU=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (15, 'telnet', '1', 'PCF_001_4100', '172.16.5.160', 4100, 'admin', '0', 'NUBonCin4GZgl7o12YjeClE8ToQmYp9KWdhMjSNxc2M=', '', '', '', '', 'supervisor', 1729063407333, 'supervisor', 1729063818375);
|
||||||
INSERT INTO `ne_host` VALUES (16, 'telnet', '1', 'NSSF_001_4100', '172.16.5.170', 4100, 'admin', '0', 'gsjnG8iYpON7T9ae21l955gZi8RRsBWr2WRP31x6ENg=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (16, 'ssh', '1', 'NSSF_001_22', '172.16.5.170', 22, 'omcuser', '2', '', '', '', '', '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
|
||||||
INSERT INTO `ne_host` VALUES (17, 'ssh', '1', 'NRF_001_22', '172.16.5.180', 22, 'omcuser', '0', 'E4Tm7TQuydT1aOXXYvjAIUnSSwqSPaeZ59Ls4qRcxZU=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (17, 'telnet', '1', 'NSSF_001_4100', '172.16.5.170', 4100, 'admin', '0', 'NUBonCin4GZgl7o12YjeClE8ToQmYp9KWdhMjSNxc2M=', '', '', '', '', 'supervisor', 1729063407333, 'supervisor', 1729063818375);
|
||||||
INSERT INTO `ne_host` VALUES (18, 'telnet', '1', 'NRF_001_4100', '172.16.5.180', 4100, 'admin', '0', 'gsjnG8iYpON7T9ae21l955gZi8RRsBWr2WRP31x6ENg=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (18, 'ssh', '1', 'NRF_001_22', '172.16.5.180', 22, 'omcuser', '2', '', '', '', '', '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
|
||||||
INSERT INTO `ne_host` VALUES (19, 'ssh', '1', 'UPF_001_22', '172.16.5.190', 22, 'omcuser', '0', 'E4Tm7TQuydT1aOXXYvjAIUnSSwqSPaeZ59Ls4qRcxZU=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (19, 'telnet', '1', 'NRF_001_4100', '172.16.5.180', 4100, 'admin', '0', 'NUBonCin4GZgl7o12YjeClE8ToQmYp9KWdhMjSNxc2M=', '', '', '', '', 'supervisor', 1729063407333, 'supervisor', 1729063818375);
|
||||||
INSERT INTO `ne_host` VALUES (20, 'telnet', '1', 'UPF_001_4100', '172.16.5.190', 4100, 'admin', '0', 'gsjnG8iYpON7T9ae21l955gZi8RRsBWr2WRP31x6ENg=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (20, 'ssh', '1', 'UPF_001_22', '172.16.5.190', 22, 'omcuser', '2', '', '', '', '', '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
|
||||||
INSERT INTO `ne_host` VALUES (21, 'telnet', '1', 'UPF_001_5002', '172.16.5.190', 5002, 'admin', '0', '', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (21, 'telnet', '1', 'UPF_001_4100', '172.16.5.190', 4100, 'admin', '0', 'NUBonCin4GZgl7o12YjeClE8ToQmYp9KWdhMjSNxc2M=', '', '', '', '', 'supervisor', 1729063407333, 'supervisor', 1729063818375);
|
||||||
INSERT INTO `ne_host` VALUES (22, 'ssh', '1', 'LMF_001_22', '172.16.5.200', 22, 'omcuser', '0', 'E4Tm7TQuydT1aOXXYvjAIUnSSwqSPaeZ59Ls4qRcxZU=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (22, 'telnet', '1', 'UPF_001_5002', '172.16.5.190', 5002, 'admin', '0', '', '', '', '', '', 'supervisor', 1729063407333, 'supervisor', 1729063818375);
|
||||||
INSERT INTO `ne_host` VALUES (23, 'telnet', '1', 'LMF_001_4100', '172.16.5.200', 4100, 'admin', '0', 'gsjnG8iYpON7T9ae21l955gZi8RRsBWr2WRP31x6ENg=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (23, 'ssh', '1', 'LMF_001_22', '172.16.5.200', 22, 'omcuser', '2', '', '', '', '', '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
|
||||||
INSERT INTO `ne_host` VALUES (24, 'ssh', '1', 'NEF_001_22', '172.16.5.210', 22, 'omcuser', '0', 'E4Tm7TQuydT1aOXXYvjAIUnSSwqSPaeZ59Ls4qRcxZU=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (23, 'telnet', '1', 'LMF_001_4100', '172.16.5.200', 4100, 'admin', '0', 'NUBonCin4GZgl7o12YjeClE8ToQmYp9KWdhMjSNxc2M=', '', '', '', '', 'supervisor', 1729063407333, 'supervisor', 1729063818375);
|
||||||
INSERT INTO `ne_host` VALUES (25, 'telnet', '1', 'NEF_001_4100', '172.16.5.210', 4100, 'admin', '0', 'gsjnG8iYpON7T9ae21l955gZi8RRsBWr2WRP31x6ENg=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (24, 'ssh', '1', 'NEF_001_22', '172.16.5.210', 22, 'omcuser', '2', '', '', '', '', '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
|
||||||
INSERT INTO `ne_host` VALUES (26, 'ssh', '1', 'MME_001_22', '172.16.5.220', 22, 'omcuser', '0', 'E4Tm7TQuydT1aOXXYvjAIUnSSwqSPaeZ59Ls4qRcxZU=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (25, 'telnet', '1', 'NEF_001_4100', '172.16.5.210', 4100, 'admin', '0', 'NUBonCin4GZgl7o12YjeClE8ToQmYp9KWdhMjSNxc2M=', '', '', '', '', 'supervisor', 1729063407333, 'supervisor', 1729063818375);
|
||||||
INSERT INTO `ne_host` VALUES (27, 'telnet', '1', 'MME_001_4100', '172.16.5.220', 4100, 'admin', '0', 'gsjnG8iYpON7T9ae21l955gZi8RRsBWr2WRP31x6ENg=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (26, 'ssh', '1', 'MME_001_22', '172.16.5.220', 22, 'omcuser', '2', '', '', '', '', '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
|
||||||
INSERT INTO `ne_host` VALUES (28, 'ssh', '1', 'N3IWF_001_22', '172.16.5.230', 22, 'omcuser', '0', 'E4Tm7TQuydT1aOXXYvjAIUnSSwqSPaeZ59Ls4qRcxZU=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (27, 'telnet', '1', 'MME_001_4100', '172.16.5.220', 4100, 'admin', '0', 'NUBonCin4GZgl7o12YjeClE8ToQmYp9KWdhMjSNxc2M=', '', '', '', '', 'supervisor', 1729063407333, 'supervisor', 1729063818375);
|
||||||
INSERT INTO `ne_host` VALUES (29, 'telnet', '1', 'N3IWF_001_4100', '172.16.5.230', 4100, 'admin', '0', 'gsjnG8iYpON7T9ae21l955gZi8RRsBWr2WRP31x6ENg=', '', '', '', 'admin', 1708333292882, NULL, 0);
|
INSERT INTO `ne_host` VALUES (28, 'ssh', '1', 'N3IWF_001_22', '172.16.5.230', 22, 'omcuser', '2', '', '', '', '', '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
|
||||||
|
INSERT INTO `ne_host` VALUES (29, 'telnet', '1', 'N3IWF_001_4100', '172.16.5.230', 4100, 'admin', '0', 'NUBonCin4GZgl7o12YjeClE8ToQmYp9KWdhMjSNxc2M=', '', '', '', '', 'supervisor', 1729063407333, 'supervisor', 1729063818375);
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS=1;
|
SET FOREIGN_KEY_CHECKS=1;
|
||||||
|
|||||||
@@ -7,47 +7,44 @@ SET FOREIGN_KEY_CHECKS = 0;
|
|||||||
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `ne_info`;
|
DROP TABLE IF EXISTS `ne_info`;
|
||||||
|
|
||||||
CREATE TABLE `ne_info` (
|
CREATE TABLE `ne_info` (
|
||||||
`id` int NOT NULL AUTO_INCREMENT,
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
`ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
`ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||||
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||||
`rm_uid` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',
|
`rm_uid` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
|
||||||
`ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',
|
`ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
|
||||||
`ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',
|
`ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
|
||||||
`port` int NULL DEFAULT 0 COMMENT '端口',
|
`port` int DEFAULT '0' COMMENT '端口',
|
||||||
`pv_flag` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'PNF' COMMENT '\'PNF\',\'VNF\'',
|
`pv_flag` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'PNF' COMMENT '''PNF'',''VNF''',
|
||||||
`province` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '省份地域',
|
`province` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '省份地域',
|
||||||
`vendor_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-',
|
`vendor_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-',
|
||||||
`dn` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',
|
`dn` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
|
||||||
`ne_address` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'MAC地址',
|
`ne_address` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT 'MAC地址',
|
||||||
`host_ids` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '网元主机ID组 数据格式(ssh,telnet,telnet)',
|
`host_ids` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '网元主机ID组 数据格式(ssh,telnet)-来自ne_host表',
|
||||||
`status` int NULL DEFAULT 0 COMMENT '0离线 1在线 2配置待下发',
|
`status` int DEFAULT '0' COMMENT '0离线 1在线 2配置待下发',
|
||||||
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
|
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '备注',
|
||||||
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
|
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
|
||||||
`create_time` bigint NULL DEFAULT 0 COMMENT '创建时间',
|
`create_time` bigint DEFAULT '0' COMMENT '创建时间',
|
||||||
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
|
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
|
||||||
`update_time` bigint NULL DEFAULT 0 COMMENT '更新时间',
|
`update_time` bigint DEFAULT '0' COMMENT '更新时间',
|
||||||
PRIMARY KEY (`id`) USING BTREE,
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
UNIQUE INDEX `ux_netype_neid`(`ne_type` ASC, `ne_id` ASC) USING BTREE
|
UNIQUE KEY `ux_netype_neid` (`ne_type`,`ne_id`) USING BTREE
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '网元信息表 对应一个网元版本、网元授权、网元主机' ROW_FORMAT = DYNAMIC;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元信息表 对应一个网元版本、网元授权、网元主机';
|
||||||
|
|
||||||
-- 初始网元数据
|
-- 初始网元数据
|
||||||
INSERT INTO `ne_info` VALUES (1, 'OMC', '001', '4400HXOMC001', 'OMC_001', '172.16.5.100', 33030, 'PNF', '-', '-', '-', '-', '1,2', 0, '', '', 0, '', 0);
|
INSERT INTO `ne_info` VALUES (1, 'OMC', '001', '4400HXOMC001', 'OMC_001', '172.16.5.100', 33030, 'PNF', '-', '-', '-', '-', '1,2', 0, '', '', 0, '', 0);
|
||||||
INSERT INTO `ne_info` VALUES (2, 'IMS', '001', '4400HXIMS001', 'IMS_001', '172.16.5.110', 33030, 'PNF', '-', '-', '-', '-', '3,4', 0, '', '', 0, '', 0);
|
INSERT INTO `ne_info` VALUES (2, 'IMS', '001', '4400HXIMS001', 'IMS_001', '172.16.5.110', 33030, 'PNF', '-', '-', '-', '-', '3,4', 0, '', '', 0, '', 0);
|
||||||
INSERT INTO `ne_info` VALUES (3, 'AMF', '001', '4400HXAMF001', 'AMF_001', '172.16.5.120', 33030, 'PNF', '-', '-', '-', '', '5,6', 0, '', '', 0, '', 0);
|
INSERT INTO `ne_info` VALUES (3, 'AMF', '001', '4400HXAMF001', 'AMF_001', '172.16.5.120', 33030, 'PNF', '-', '-', '-', '', '5,6', 0, '', '', 0, '', 0);
|
||||||
INSERT INTO `ne_info` VALUES (4, 'AUSF', '001', '4400HXAUSF001', 'AUSF_001', '172.16.5.130', 33030, 'PNF', '-', '-', '-', '', '7,8', 0, '', '', 0, '', 0);
|
INSERT INTO `ne_info` VALUES (4, 'AUSF', '001', '4400HXAUSF001', 'AUSF_001', '172.16.5.130', 33030, 'PNF', '-', '-', '-', '', '7,8', 0, '', '', 0, '', 0);
|
||||||
INSERT INTO `ne_info` VALUES (5, 'UDM', '001', '4400HXUDM001', 'UDM_001', '172.16.5.140', 33030, 'PNF', '-', '-', '-', '-', '9,10', 0, '', '', 0, '', 0);
|
INSERT INTO `ne_info` VALUES (5, 'UDM', '001', '4400HXUDM001', 'UDM_001', '172.16.5.140', 33030, 'PNF', '-', '-', '-', '-', '9,10,11', 0, '', '', 0, '', 0);
|
||||||
INSERT INTO `ne_info` VALUES (6, 'SMF', '001', '4400HXSMF001', 'SMF_001', '172.16.5.150', 33030, 'PNF', '-', '-', '-', '-', '11,12', 0, '', '', 0, '', 0);
|
INSERT INTO `ne_info` VALUES (6, 'SMF', '001', '4400HXSMF001', 'SMF_001', '172.16.5.150', 33030, 'PNF', '-', '-', '-', '-', '12,13', 0, '', '', 0, '', 0);
|
||||||
INSERT INTO `ne_info` VALUES (7, 'PCF', '001', '4400HXPCF001', 'PCF_001', '172.16.5.160', 33030, 'PNF', '-', '-', '-', '-', '13,14', 0, '', '', 0, '', 0);
|
INSERT INTO `ne_info` VALUES (7, 'PCF', '001', '4400HXPCF001', 'PCF_001', '172.16.5.160', 33030, 'PNF', '-', '-', '-', '-', '14,15', 0, '', '', 0, '', 0);
|
||||||
INSERT INTO `ne_info` VALUES (8, 'NSSF', '001', '4400HXNSF001', 'NSSF_001', '172.16.5.170', 33030, 'PNF', '-', '-', '-', '-', '15,16', 0, '', '', 0, '', 0);
|
INSERT INTO `ne_info` VALUES (8, 'NSSF', '001', '4400HXNSF001', 'NSSF_001', '172.16.5.170', 33030, 'PNF', '-', '-', '-', '-', '16,17', 0, '', '', 0, '', 0);
|
||||||
INSERT INTO `ne_info` VALUES (9, 'NRF', '001', '4400HXNRF001', 'NRF_001', '172.16.5.180', 33030, 'PNF', '-', '-', '-', '-', '17,18', 0, '', '', 0, '', 0);
|
INSERT INTO `ne_info` VALUES (9, 'NRF', '001', '4400HXNRF001', 'NRF_001', '172.16.5.180', 33030, 'PNF', '-', '-', '-', '-', '18,19', 0, '', '', 0, '', 0);
|
||||||
INSERT INTO `ne_info` VALUES (10, 'UPF', '001', '4400HXUPF001', 'UPF_001', '172.16.5.190', 33030, 'PNF', '-', '-', '-', '', '19,20,21', 0, '', '', 0, '', 0);
|
INSERT INTO `ne_info` VALUES (10, 'UPF', '001', '4400HXUPF001', 'UPF_001', '172.16.5.190', 33030, 'PNF', '-', '-', '-', '', '20,21,22', 0, '', '', 0, '', 0);
|
||||||
INSERT INTO `ne_info` VALUES (11, 'LMF', '001', '4400HXLMF001', 'LMF_001', '172.16.5.200', 33030, 'PNF', '-', '-', '-', '-', '22,23', 0, '', '', 0, '', 0);
|
INSERT INTO `ne_info` VALUES (11, 'LMF', '001', '4400HXLMF001', 'LMF_001', '172.16.5.200', 33030, 'PNF', '-', '-', '-', '-', '23,24', 0, '', '', 0, '', 0);
|
||||||
INSERT INTO `ne_info` VALUES (12, 'NEF', '001', '4400HXNEF001', 'NEF_001', '172.16.5.210', 33030, 'PNF', '-', '-', '-', '-', '24,25', 0, '', '', 0, '', 0);
|
INSERT INTO `ne_info` VALUES (12, 'NEF', '001', '4400HXNEF001', 'NEF_001', '172.16.5.210', 33030, 'PNF', '-', '-', '-', '-', '25,26', 0, '', '', 0, '', 0);
|
||||||
INSERT INTO `ne_info` VALUES (13, 'MME', '001', '4400HXMME001', 'MME_001', '172.16.5.220', 33030, 'PNF', '-', '-', '-', '', '26,27', 0, '', '', 0, '', 0);
|
INSERT INTO `ne_info` VALUES (13, 'MME', '001', '4400HXMME001', 'MME_001', '172.16.5.220', 33030, 'PNF', '-', '-', '-', '', '27,28', 0, '', '', 0, '', 0);
|
||||||
INSERT INTO `ne_info` VALUES (14, 'N3IWF', '001', '4400HXN3IWF001', 'N3IWF_001', '172.16.5.230', 33030, 'PNF', '-', '-', '-', '', '28,29', 0, '', '', 0, '', 0);
|
INSERT INTO `ne_info` VALUES (14, 'N3IWF', '001', '4400HXN3IWF001', 'N3IWF_001', '172.16.5.230', 33030, 'PNF', '-', '-', '-', '', '29,30', 0, '', '', 0, '', 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS=1;
|
SET FOREIGN_KEY_CHECKS=1;
|
||||||
|
|||||||
@@ -7,24 +7,23 @@ SET FOREIGN_KEY_CHECKS = 0;
|
|||||||
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `ne_license`;
|
DROP TABLE IF EXISTS `ne_license`;
|
||||||
|
CREATE TABLE `ne_license` (
|
||||||
CREATE TABLE `ne_license` (
|
|
||||||
`id` int NOT NULL AUTO_INCREMENT,
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
`ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型',
|
`ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型',
|
||||||
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID',
|
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID',
|
||||||
`activation_request_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '激活申请代码',
|
`activation_request_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '激活申请代码',
|
||||||
`license_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '激活授权文件',
|
`license_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '激活授权文件',
|
||||||
`serial_num` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '序列号',
|
`serial_num` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '序列号',
|
||||||
`expiry_date` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '许可证到期日期',
|
`expiry_date` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '许可证到期日期',
|
||||||
`status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '状态 0无效 1有效',
|
`status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '状态 0无效 1有效',
|
||||||
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
|
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '备注',
|
||||||
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
|
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
|
||||||
`create_time` bigint NULL DEFAULT 0 COMMENT '创建时间',
|
`create_time` bigint DEFAULT '0' COMMENT '创建时间',
|
||||||
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
|
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
|
||||||
`update_time` bigint NULL DEFAULT 0 COMMENT '更新时间',
|
`update_time` bigint DEFAULT '0' COMMENT '更新时间',
|
||||||
PRIMARY KEY (`id`) USING BTREE,
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
UNIQUE INDEX `uk_type_id`(`ne_type` ASC, `ne_id` ASC) USING BTREE COMMENT '唯一网元类型和网元ID'
|
UNIQUE KEY `uk_type_id` (`ne_type`,`ne_id`) USING BTREE COMMENT '唯一网元类型和网元ID'
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '网元授权激活信息' ROW_FORMAT = DYNAMIC;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元授权激活信息';
|
||||||
|
|
||||||
-- 初始数据对应网元
|
-- 初始数据对应网元
|
||||||
INSERT INTO `ne_license` VALUES (1, 'OMC', '001', '', '', '', '', '0', '', 'supervisor', 1713928436971, '', 0);
|
INSERT INTO `ne_license` VALUES (1, 'OMC', '001', '', '', '', '', '0', '', 'supervisor', 1713928436971, '', 0);
|
||||||
|
|||||||
@@ -7,28 +7,27 @@ SET FOREIGN_KEY_CHECKS = 0;
|
|||||||
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `ne_version`;
|
DROP TABLE IF EXISTS `ne_version`;
|
||||||
|
CREATE TABLE `ne_version` (
|
||||||
CREATE TABLE `ne_version` (
|
|
||||||
`id` int NOT NULL AUTO_INCREMENT,
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
`ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型',
|
`ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型',
|
||||||
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID',
|
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID',
|
||||||
`name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '当前包名',
|
`name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '当前包名',
|
||||||
`version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '当前版本',
|
`version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '当前版本',
|
||||||
`path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '当前软件包',
|
`path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '当前软件包',
|
||||||
`pre_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '上一版本包名',
|
`pre_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '上一版本包名',
|
||||||
`pre_version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '上一版本',
|
`pre_version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '上一版本',
|
||||||
`pre_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '上一版本软件包',
|
`pre_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '上一版本软件包',
|
||||||
`new_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '新版本报名',
|
`new_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '新版本报名',
|
||||||
`new_version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '新版本',
|
`new_version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '新版本',
|
||||||
`new_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '新版软件包',
|
`new_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '新版软件包',
|
||||||
`status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '当前状态 0无 1当前版本 2上一版本 3有新版本',
|
`status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '当前状态 0无 1当前版本 2上一版本 3有新版本',
|
||||||
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
|
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
|
||||||
`create_time` bigint NULL DEFAULT 0 COMMENT '创建时间',
|
`create_time` bigint DEFAULT '0' COMMENT '创建时间',
|
||||||
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
|
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
|
||||||
`update_time` bigint NULL DEFAULT 0 COMMENT '更新时间',
|
`update_time` bigint DEFAULT '0' COMMENT '更新时间',
|
||||||
PRIMARY KEY (`id`) USING BTREE,
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
UNIQUE INDEX `uk_type_id`(`ne_type` ASC, `ne_id` ASC) USING BTREE COMMENT '唯一网元类型和ID'
|
UNIQUE KEY `uk_type_id` (`ne_type`,`ne_id`) USING BTREE COMMENT '唯一网元类型和ID'
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '网元版本信息' ROW_FORMAT = DYNAMIC;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元版本信息';
|
||||||
|
|
||||||
-- 初始数据对应网元
|
-- 初始数据对应网元
|
||||||
INSERT INTO `ne_version` VALUES (1, 'OMC', '001', '', '', '', '', '', '', '', '', '', '0', 'supervisor', 1713928436957, '', 0);
|
INSERT INTO `ne_version` VALUES (1, 'OMC', '001', '', '', '', '', '', '', '', '', '', '0', 'supervisor', 1713928436957, '', 0);
|
||||||
|
|||||||
@@ -591,7 +591,7 @@ INSERT INTO `sys_dict_data` VALUES (2080, 2080, 'log.operate.title.ws', 'WS会
|
|||||||
INSERT INTO `sys_dict_data` VALUES (2081, 2081, 'log.operate.title.neHost', '网元主机', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
INSERT INTO `sys_dict_data` VALUES (2081, 2081, 'log.operate.title.neHost', '网元主机', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
INSERT INTO `sys_dict_data` VALUES (2082, 2082, 'neHost.noData', '没有可访问主机信息数据!', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
INSERT INTO `sys_dict_data` VALUES (2082, 2082, 'neHost.noData', '没有可访问主机信息数据!', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
INSERT INTO `sys_dict_data` VALUES (2083, 2083, 'neHost.errKeyExists', '主机信息操作【{name}】失败,同组内名称已存在', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
INSERT INTO `sys_dict_data` VALUES (2083, 2083, 'neHost.errKeyExists', '主机信息操作【{name}】失败,同组内名称已存在', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
INSERT INTO `sys_dict_data` VALUES (2084, 2084, 'neHost.errByHostInfo', '连接主机失败,请检查连接参数后重试', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
INSERT INTO `sys_dict_data` VALUES (2084, 2084, 'neHost.errByHostInfo', '连接失败,请检查连接参数后重试', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
INSERT INTO `sys_dict_data` VALUES (2085, 2085, 'dictType.ne_host_type', '网元主机连接类型', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
INSERT INTO `sys_dict_data` VALUES (2085, 2085, 'dictType.ne_host_type', '网元主机连接类型', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
INSERT INTO `sys_dict_data` VALUES (2086, 2086, 'dictType.ne_host_groupId', '网元主机分组', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
INSERT INTO `sys_dict_data` VALUES (2086, 2086, 'dictType.ne_host_groupId', '网元主机分组', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
INSERT INTO `sys_dict_data` VALUES (2087, 2087, 'dictType.ne_host_authMode', '网元主机认证模式', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
INSERT INTO `sys_dict_data` VALUES (2087, 2087, 'dictType.ne_host_authMode', '网元主机认证模式', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
|
|||||||
@@ -591,7 +591,7 @@ INSERT INTO `sys_dict_data` VALUES (4080, 4080, 'log.operate.title.ws', 'WS Sess
|
|||||||
INSERT INTO `sys_dict_data` VALUES (4081, 4081, 'log.operate.title.neHost', 'NE Host', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
INSERT INTO `sys_dict_data` VALUES (4081, 4081, 'log.operate.title.neHost', 'NE Host', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
INSERT INTO `sys_dict_data` VALUES (4082, 4082, 'neHost.noData', 'There is no accessible host information data!', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
INSERT INTO `sys_dict_data` VALUES (4082, 4082, 'neHost.noData', 'There is no accessible host information data!', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
INSERT INTO `sys_dict_data` VALUES (4083, 4083, 'neHost.errKeyExists', 'Host information operation [{name}] failed, name already exists in the same group', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
INSERT INTO `sys_dict_data` VALUES (4083, 4083, 'neHost.errKeyExists', 'Host information operation [{name}] failed, name already exists in the same group', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
INSERT INTO `sys_dict_data` VALUES (4084, 4084, 'neHost.errByHostInfo', 'Failed to connect to the host, please check the connection parameters and try again', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
INSERT INTO `sys_dict_data` VALUES (4084, 4084, 'neHost.errByHostInfo', 'Connection Failed, Please check connection parameters and retry', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
INSERT INTO `sys_dict_data` VALUES (4085, 4085, 'dictType.ne_host_type', 'Network element host connection type', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
INSERT INTO `sys_dict_data` VALUES (4085, 4085, 'dictType.ne_host_type', 'Network element host connection type', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
INSERT INTO `sys_dict_data` VALUES (4086, 4086, 'dictType.ne_host_groupId', 'Network element host grouping', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
INSERT INTO `sys_dict_data` VALUES (4086, 4086, 'dictType.ne_host_groupId', 'Network element host grouping', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
INSERT INTO `sys_dict_data` VALUES (4087, 4087, 'dictType.ne_host_authMode', 'Network element host authentication mode', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
INSERT INTO `sys_dict_data` VALUES (4087, 4087, 'dictType.ne_host_authMode', 'Network element host authentication mode', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `trace_data`;
|
DROP TABLE IF EXISTS `trace_data`;
|
||||||
|
|
||||||
CREATE TABLE `trace_data` (
|
CREATE TABLE `trace_data` (
|
||||||
`id` int NOT NULL AUTO_INCREMENT,
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
`task_id` int NOT NULL COMMENT '跟踪任务ID',
|
`task_id` int NOT NULL COMMENT '跟踪任务ID',
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `trace_task`
|
-- Table structure for table `trace_task`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `trace_task`;
|
DROP TABLE IF EXISTS `trace_task`;
|
||||||
|
|
||||||
CREATE TABLE `trace_task` (
|
CREATE TABLE `trace_task` (
|
||||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '跟踪任务ID',
|
`id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||||
`trace_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '1-Interface,2-Device,3-User',
|
`trace_id` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '任务编号',
|
||||||
|
`trace_type` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '1-Interface,2-Device,3-User',
|
||||||
`start_time` bigint DEFAULT '0' COMMENT '开始时间 毫秒',
|
`start_time` bigint DEFAULT '0' COMMENT '开始时间 毫秒',
|
||||||
`end_time` bigint DEFAULT '0' COMMENT '结束时间 毫秒',
|
`end_time` bigint DEFAULT '0' COMMENT '结束时间 毫秒',
|
||||||
`ue_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '设备跟踪必须 IP',
|
|
||||||
`interfaces` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '' COMMENT '接口跟踪必须 例如 N8,N10',
|
`interfaces` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '' COMMENT '接口跟踪必须 例如 N8,N10',
|
||||||
`imsi` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '用户跟踪必须',
|
`imsi` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '用户跟踪必须',
|
||||||
`msisdn` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '用户跟踪可选',
|
`msisdn` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '用户跟踪可选',
|
||||||
|
`ue_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '设备跟踪必须 IP',
|
||||||
`src_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '源地址IP',
|
`src_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '源地址IP',
|
||||||
`dst_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '目标地址IP',
|
`dst_ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '目标地址IP',
|
||||||
`signal_port` int DEFAULT '0' COMMENT '地址IP端口',
|
`signal_port` int DEFAULT '0' COMMENT '地址IP端口',
|
||||||
@@ -25,6 +24,7 @@ CREATE TABLE `trace_task` (
|
|||||||
`ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型',
|
`ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型',
|
||||||
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID',
|
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID',
|
||||||
`notify_url` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '信息数据通知回调地址UDP 例如udp:192.168.5.58:29500',
|
`notify_url` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '信息数据通知回调地址UDP 例如udp:192.168.5.58:29500',
|
||||||
|
`fetch_msg` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '任务下发请求响应消息',
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='跟踪_任务';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='跟踪_任务';
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,35 @@
|
|||||||
SET FOREIGN_KEY_CHECKS=0;
|
SET FOREIGN_KEY_CHECKS=0;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `ne_host` (
|
CREATE TABLE IF NOT EXISTS `ne_host` (
|
||||||
`host_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主机主键',
|
`host_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主机主键',
|
||||||
`host_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '主机类型 ssh telnet',
|
`host_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '连接类型 ssh telnet redis',
|
||||||
`group_id` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '分组(0默认 1网元 2系统)',
|
`group_id` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '分组(0默认 1网元 2系统)',
|
||||||
`title` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '标题名称',
|
`title` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '标题名称',
|
||||||
`addr` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '主机地址',
|
`addr` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '主机地址',
|
||||||
`port` int NULL DEFAULT 22 COMMENT 'SSH端口',
|
`port` int DEFAULT '22' COMMENT '端口 22 4100 6379',
|
||||||
`user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '主机用户名',
|
`user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '认证用户名',
|
||||||
`auth_mode` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '认证模式(0密码 1主机私钥 2已免密)',
|
`auth_mode` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '认证模式(0密码 1主机私钥 2已免密)',
|
||||||
`password` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '认证密码',
|
`password` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '认证密码',
|
||||||
`private_key` varchar(6000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '认证私钥',
|
`private_key` varchar(6000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '认证私钥',
|
||||||
`pass_phrase` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '认证私钥密码',
|
`pass_phrase` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '认证私钥密码',
|
||||||
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
|
`db_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '数据库名称',
|
||||||
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
|
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '备注',
|
||||||
`create_time` bigint NULL DEFAULT 0 COMMENT '创建时间',
|
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
|
||||||
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
|
`create_time` bigint DEFAULT '0' COMMENT '创建时间',
|
||||||
`update_time` bigint NULL DEFAULT 0 COMMENT '更新时间',
|
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
|
||||||
|
`update_time` bigint DEFAULT '0' COMMENT '更新时间',
|
||||||
PRIMARY KEY (`host_id`) USING BTREE,
|
PRIMARY KEY (`host_id`) USING BTREE,
|
||||||
UNIQUE INDEX `uk_type_group_title`(`host_type` ASC, `group_id` ASC, `title` ASC) USING BTREE COMMENT '同组内名称唯一'
|
UNIQUE KEY `uk_type_group_title` (`host_type`,`group_id`,`title`) USING BTREE COMMENT '同组内名称唯一'
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '网元主机表' ROW_FORMAT = DYNAMIC;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元主机表';
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS=1;
|
-- 20241016前旧表更新
|
||||||
|
ALTER TABLE `ne_host` ADD COLUMN IF NOT EXISTS `db_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '数据库名称' AFTER `pass_phrase`;
|
||||||
|
ALTER TABLE `ne_host` MODIFY COLUMN IF NOT EXISTS `host_id` bigint NOT NULL COMMENT '主机主键' FIRST;
|
||||||
|
ALTER TABLE `ne_host` MODIFY COLUMN IF NOT EXISTS `host_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '连接类型 ssh telnet redis' AFTER `host_id`;
|
||||||
|
ALTER TABLE `ne_host` MODIFY COLUMN IF NOT EXISTS `port` int NULL DEFAULT 22 COMMENT '端口 22 4100 6379' AFTER `addr`;
|
||||||
|
ALTER TABLE `ne_host` MODIFY COLUMN IF NOT EXISTS `user` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '认证用户名' AFTER `port`;
|
||||||
|
ALTER TABLE `ne_host` MODIFY COLUMN IF NOT EXISTS `create_time` bigint NULL DEFAULT 0 COMMENT '创建时间' AFTER `create_by`;
|
||||||
|
ALTER TABLE `ne_host` MODIFY COLUMN IF NOT EXISTS `update_time` bigint NULL DEFAULT 0 COMMENT '更新时间' AFTER `update_by`;
|
||||||
|
ALTER TABLE `ne_host` MODIFY COLUMN IF NOT EXISTS `host_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主机主键';
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS=1;
|
||||||
|
|||||||
@@ -7,25 +7,25 @@ CREATE TABLE IF NOT EXISTS `ne_info` (
|
|||||||
`id` int NOT NULL AUTO_INCREMENT,
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
`ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
`ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||||
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||||
`rm_uid` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',
|
`rm_uid` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
|
||||||
`ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',
|
`ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
|
||||||
`ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',
|
`ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
|
||||||
`port` int NULL DEFAULT 0 COMMENT '端口',
|
`port` int DEFAULT '0' COMMENT '端口',
|
||||||
`pv_flag` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'PNF' COMMENT '\'PNF\',\'VNF\'',
|
`pv_flag` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'PNF' COMMENT '''PNF'',''VNF''',
|
||||||
`province` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '省份地域',
|
`province` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '省份地域',
|
||||||
`vendor_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-',
|
`vendor_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-',
|
||||||
`dn` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',
|
`dn` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
|
||||||
`ne_address` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'MAC地址',
|
`ne_address` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT 'MAC地址',
|
||||||
`host_ids` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '网元主机ID组 数据格式(ssh,telnet,telnet)',
|
`host_ids` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '网元主机ID组 数据格式(ssh,telnet)-来自ne_host表',
|
||||||
`status` int NULL DEFAULT 0 COMMENT '0离线 1在线 2配置待下发',
|
`status` int DEFAULT '0' COMMENT '0离线 1在线 2配置待下发',
|
||||||
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
|
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '备注',
|
||||||
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
|
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
|
||||||
`create_time` bigint NULL DEFAULT 0 COMMENT '创建时间',
|
`create_time` bigint DEFAULT '0' COMMENT '创建时间',
|
||||||
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
|
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
|
||||||
`update_time` bigint NULL DEFAULT 0 COMMENT '更新时间',
|
`update_time` bigint DEFAULT '0' COMMENT '更新时间',
|
||||||
PRIMARY KEY (`id`) USING BTREE,
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
UNIQUE INDEX `ux_netype_neid`(`ne_type` ASC, `ne_id` ASC) USING BTREE
|
UNIQUE KEY `ux_netype_neid` (`ne_type`,`ne_id`) USING BTREE
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '网元信息表 对应一个网元版本、网元授权、网元主机' ROW_FORMAT = DYNAMIC;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元信息表 对应一个网元版本、网元授权、网元主机';
|
||||||
|
|
||||||
-- 20240511前旧表更新
|
-- 20240511前旧表更新
|
||||||
ALTER TABLE `ne_info` COMMENT = '网元信息表 对应一个网元版本、网元授权、网元主机';
|
ALTER TABLE `ne_info` COMMENT = '网元信息表 对应一个网元版本、网元授权、网元主机';
|
||||||
|
|||||||
@@ -8,18 +8,18 @@ CREATE TABLE IF NOT EXISTS `ne_license` (
|
|||||||
`ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型',
|
`ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型',
|
||||||
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID',
|
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID',
|
||||||
`activation_request_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '激活申请代码',
|
`activation_request_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '激活申请代码',
|
||||||
`license_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '激活授权文件',
|
`license_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '激活授权文件',
|
||||||
`serial_num` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '序列号',
|
`serial_num` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '序列号',
|
||||||
`expiry_date` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '许可证到期日期',
|
`expiry_date` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '许可证到期日期',
|
||||||
`status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '状态 0无效 1有效',
|
`status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '状态 0无效 1有效',
|
||||||
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
|
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '备注',
|
||||||
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
|
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
|
||||||
`create_time` bigint NULL DEFAULT 0 COMMENT '创建时间',
|
`create_time` bigint DEFAULT '0' COMMENT '创建时间',
|
||||||
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
|
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
|
||||||
`update_time` bigint NULL DEFAULT 0 COMMENT '更新时间',
|
`update_time` bigint DEFAULT '0' COMMENT '更新时间',
|
||||||
PRIMARY KEY (`id`) USING BTREE,
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
UNIQUE INDEX `uk_type_id`(`ne_type` ASC, `ne_id` ASC) USING BTREE COMMENT '唯一网元类型和网元ID'
|
UNIQUE KEY `uk_type_id` (`ne_type`,`ne_id`) USING BTREE COMMENT '唯一网元类型和网元ID'
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '网元授权激活信息' ROW_FORMAT = DYNAMIC;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元授权激活信息';
|
||||||
|
|
||||||
-- 20240511前旧表更新
|
-- 20240511前旧表更新
|
||||||
ALTER TABLE `ne_license` COMMENT = '网元授权激活信息';
|
ALTER TABLE `ne_license` COMMENT = '网元授权激活信息';
|
||||||
|
|||||||
@@ -7,23 +7,23 @@ CREATE TABLE IF NOT EXISTS `ne_version` (
|
|||||||
`id` int NOT NULL AUTO_INCREMENT,
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
`ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型',
|
`ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型',
|
||||||
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID',
|
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID',
|
||||||
`name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '当前包名',
|
`name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '当前包名',
|
||||||
`version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '当前版本',
|
`version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '当前版本',
|
||||||
`path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '当前软件包',
|
`path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '当前软件包',
|
||||||
`pre_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '上一版本包名',
|
`pre_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '上一版本包名',
|
||||||
`pre_version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '上一版本',
|
`pre_version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '上一版本',
|
||||||
`pre_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '上一版本软件包',
|
`pre_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '上一版本软件包',
|
||||||
`new_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '新版本报名',
|
`new_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '新版本报名',
|
||||||
`new_version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '新版本',
|
`new_version` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '-' COMMENT '新版本',
|
||||||
`new_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '新版软件包',
|
`new_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '新版软件包',
|
||||||
`status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '当前状态 0无 1当前版本 2上一版本 3有新版本',
|
`status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '当前状态 0无 1当前版本 2上一版本 3有新版本',
|
||||||
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
|
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
|
||||||
`create_time` bigint NULL DEFAULT 0 COMMENT '创建时间',
|
`create_time` bigint DEFAULT '0' COMMENT '创建时间',
|
||||||
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
|
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
|
||||||
`update_time` bigint NULL DEFAULT 0 COMMENT '更新时间',
|
`update_time` bigint DEFAULT '0' COMMENT '更新时间',
|
||||||
PRIMARY KEY (`id`) USING BTREE,
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
UNIQUE INDEX `uk_type_id`(`ne_type` ASC, `ne_id` ASC) USING BTREE COMMENT '唯一网元类型和ID'
|
UNIQUE KEY `uk_type_id` (`ne_type`,`ne_id`) USING BTREE COMMENT '唯一网元类型和ID'
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '网元版本信息' ROW_FORMAT = DYNAMIC;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元版本信息';
|
||||||
|
|
||||||
-- 20240511前旧表更新
|
-- 20240511前旧表更新
|
||||||
ALTER TABLE `ne_version` COMMENT = '网元版本信息';
|
ALTER TABLE `ne_version` COMMENT = '网元版本信息';
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
SET FOREIGN_KEY_CHECKS=0;
|
SET FOREIGN_KEY_CHECKS=0;
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `sys_menu`;
|
|
||||||
CREATE TABLE IF NOT EXISTS `sys_dept` (
|
CREATE TABLE IF NOT EXISTS `sys_dept` (
|
||||||
`dept_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '部门id',
|
`dept_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '部门id',
|
||||||
`parent_id` bigint(20) DEFAULT 0 COMMENT '父部门id 默认0',
|
`parent_id` bigint(20) DEFAULT 0 COMMENT '父部门id 默认0',
|
||||||
|
|||||||
@@ -598,7 +598,7 @@ REPLACE INTO `sys_dict_data` VALUES (2080, 2080, 'log.operate.title.ws', 'WS会
|
|||||||
REPLACE INTO `sys_dict_data` VALUES (2081, 2081, 'log.operate.title.neHost', '网元主机', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
REPLACE INTO `sys_dict_data` VALUES (2081, 2081, 'log.operate.title.neHost', '网元主机', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
REPLACE INTO `sys_dict_data` VALUES (2082, 2082, 'neHost.noData', '没有可访问主机信息数据!', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
REPLACE INTO `sys_dict_data` VALUES (2082, 2082, 'neHost.noData', '没有可访问主机信息数据!', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
REPLACE INTO `sys_dict_data` VALUES (2083, 2083, 'neHost.errKeyExists', '主机信息操作【{name}】失败,同组内名称已存在', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
REPLACE INTO `sys_dict_data` VALUES (2083, 2083, 'neHost.errKeyExists', '主机信息操作【{name}】失败,同组内名称已存在', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
REPLACE INTO `sys_dict_data` VALUES (2084, 2084, 'neHost.errByHostInfo', '连接主机失败,请检查连接参数后重试', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
REPLACE INTO `sys_dict_data` VALUES (2084, 2084, 'neHost.errByHostInfo', '连接失败,请检查连接参数后重试', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
REPLACE INTO `sys_dict_data` VALUES (2085, 2085, 'dictType.ne_host_type', '网元主机连接类型', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
REPLACE INTO `sys_dict_data` VALUES (2085, 2085, 'dictType.ne_host_type', '网元主机连接类型', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
REPLACE INTO `sys_dict_data` VALUES (2086, 2086, 'dictType.ne_host_groupId', '网元主机分组', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
REPLACE INTO `sys_dict_data` VALUES (2086, 2086, 'dictType.ne_host_groupId', '网元主机分组', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
REPLACE INTO `sys_dict_data` VALUES (2087, 2087, 'dictType.ne_host_authMode', '网元主机认证模式', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
REPLACE INTO `sys_dict_data` VALUES (2087, 2087, 'dictType.ne_host_authMode', '网元主机认证模式', 'i18n_zh', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
|
|||||||
@@ -593,7 +593,7 @@ REPLACE INTO `sys_dict_data` VALUES (4080, 4080, 'log.operate.title.ws', 'WS Ses
|
|||||||
REPLACE INTO `sys_dict_data` VALUES (4081, 4081, 'log.operate.title.neHost', 'NE Host', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
REPLACE INTO `sys_dict_data` VALUES (4081, 4081, 'log.operate.title.neHost', 'NE Host', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
REPLACE INTO `sys_dict_data` VALUES (4082, 4082, 'neHost.noData', 'There is no accessible host information data!', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
REPLACE INTO `sys_dict_data` VALUES (4082, 4082, 'neHost.noData', 'There is no accessible host information data!', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
REPLACE INTO `sys_dict_data` VALUES (4083, 4083, 'neHost.errKeyExists', 'Host information operation [{name}] failed, name already exists in the same group', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
REPLACE INTO `sys_dict_data` VALUES (4083, 4083, 'neHost.errKeyExists', 'Host information operation [{name}] failed, name already exists in the same group', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
REPLACE INTO `sys_dict_data` VALUES (4084, 4084, 'neHost.errByHostInfo', 'Failed to connect to the host, please check the connection parameters and try again', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
REPLACE INTO `sys_dict_data` VALUES (4084, 4084, 'neHost.errByHostInfo', 'Connection Failed, Please check connection parameters and retry', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
REPLACE INTO `sys_dict_data` VALUES (4085, 4085, 'dictType.ne_host_type', 'Network element host connection type', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
REPLACE INTO `sys_dict_data` VALUES (4085, 4085, 'dictType.ne_host_type', 'Network element host connection type', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
REPLACE INTO `sys_dict_data` VALUES (4086, 4086, 'dictType.ne_host_groupId', 'Network element host grouping', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
REPLACE INTO `sys_dict_data` VALUES (4086, 4086, 'dictType.ne_host_groupId', 'Network element host grouping', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
REPLACE INTO `sys_dict_data` VALUES (4087, 4087, 'dictType.ne_host_authMode', 'Network element host authentication mode', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
REPLACE INTO `sys_dict_data` VALUES (4087, 4087, 'dictType.ne_host_authMode', 'Network element host authentication mode', 'i18n_en', '', '', '1', 'supervisor', 1705550000000, '', 0, '');
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ ALTER TABLE `u_sub_user` ADD COLUMN IF NOT EXISTS `mico` varchar(50) CHARACTER S
|
|||||||
ALTER TABLE `u_sub_user` ADD COLUMN IF NOT EXISTS `odb_ps` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'AmData ODB_PS 0-all,1-hplmn,2-vplmn' AFTER `mico`;
|
ALTER TABLE `u_sub_user` ADD COLUMN IF NOT EXISTS `odb_ps` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'AmData ODB_PS 0-all,1-hplmn,2-vplmn' AFTER `mico`;
|
||||||
ALTER TABLE `u_sub_user` ADD COLUMN IF NOT EXISTS `group_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'AmData GroupId' AFTER `odb_ps`;
|
ALTER TABLE `u_sub_user` ADD COLUMN IF NOT EXISTS `group_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'AmData GroupId' AFTER `odb_ps`;
|
||||||
ALTER TABLE `u_sub_user` ADD COLUMN IF NOT EXISTS `apn_mum` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'EpsDat apnNum' AFTER `context_id`;
|
ALTER TABLE `u_sub_user` ADD COLUMN IF NOT EXISTS `apn_mum` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'EpsDat apnNum' AFTER `context_id`;
|
||||||
|
ALTER TABLE `u_sub_user` ADD COLUMN IF NOT EXISTS `cag` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'CAG' AFTER `smf_sel`;
|
||||||
ALTER TABLE `u_sub_user` MODIFY COLUMN IF EXISTS `ambr` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'AmData SubUeAMBRTemp' AFTER `am_dat`;
|
ALTER TABLE `u_sub_user` MODIFY COLUMN IF EXISTS `ambr` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'AmData SubUeAMBRTemp' AFTER `am_dat`;
|
||||||
ALTER TABLE `u_sub_user` MODIFY COLUMN IF EXISTS `nssai` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'AmData SubSNSSAITemp' AFTER `ambr`;
|
ALTER TABLE `u_sub_user` MODIFY COLUMN IF EXISTS `nssai` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'AmData SubSNSSAITemp' AFTER `ambr`;
|
||||||
ALTER TABLE `u_sub_user` MODIFY COLUMN IF EXISTS `rat` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'AmData RAT 0x00:VIRTUAL 0x01:WLAN 0x02:EUTRA 0x03:NR' AFTER `nssai`;
|
ALTER TABLE `u_sub_user` MODIFY COLUMN IF EXISTS `rat` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'AmData RAT 0x00:VIRTUAL 0x01:WLAN 0x02:EUTRA 0x03:NR' AFTER `nssai`;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func ClearLocaleData() {
|
|||||||
// LoadLocaleData 加载国际化数据
|
// LoadLocaleData 加载国际化数据
|
||||||
func LoadLocaleData(language string) []localeItem {
|
func LoadLocaleData(language string) []localeItem {
|
||||||
dictType := fmt.Sprintf("i18n_%s", language)
|
dictType := fmt.Sprintf("i18n_%s", language)
|
||||||
dictTypeList := systemService.NewSysDictTypeImpl.DictDataCache(dictType)
|
dictTypeList := systemService.NewSysDictType.DictDataCache(dictType)
|
||||||
localeData := []localeItem{}
|
localeData := []localeItem{}
|
||||||
for _, v := range dictTypeList {
|
for _, v := range dictTypeList {
|
||||||
localeData = append(localeData, localeItem{
|
localeData = append(localeData, localeItem{
|
||||||
@@ -58,7 +58,7 @@ func UpdateKeyValue(language, key, value string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更新字典数据
|
// 更新字典数据
|
||||||
sysDictDataService := systemService.NewSysDictDataImpl
|
sysDictDataService := systemService.NewSysDictData
|
||||||
item := sysDictDataService.SelectDictDataByCode(code)
|
item := sysDictDataService.SelectDictDataByCode(code)
|
||||||
if item.DictCode == code && item.DictLabel == key {
|
if item.DictCode == code && item.DictLabel == key {
|
||||||
item.DictValue = value
|
item.DictValue = value
|
||||||
|
|||||||
61
src/framework/redis/conn.go
Normal file
61
src/framework/redis/conn.go
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
package redis
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/redis/go-redis/v9"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ConnRedis 连接redis对象
|
||||||
|
type ConnRedis struct {
|
||||||
|
Addr string `json:"addr"` // 地址
|
||||||
|
Port int64 `json:"port"` // 端口
|
||||||
|
User string `json:"user"` // 用户名
|
||||||
|
Password string `json:"password"` // 认证密码
|
||||||
|
Database int `json:"database"` // 数据库名称
|
||||||
|
|
||||||
|
DialTimeOut time.Duration `json:"dialTimeOut"` // 连接超时断开
|
||||||
|
|
||||||
|
Client *redis.Client `json:"client"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewClient 创建Redis客户端
|
||||||
|
func (c *ConnRedis) NewClient() (*ConnRedis, error) {
|
||||||
|
// IPV6地址协议
|
||||||
|
if strings.Contains(c.Addr, ":") {
|
||||||
|
c.Addr = fmt.Sprintf("[%s]", c.Addr)
|
||||||
|
}
|
||||||
|
addr := fmt.Sprintf("%s:%d", c.Addr, c.Port)
|
||||||
|
|
||||||
|
// 默认等待5s
|
||||||
|
if c.DialTimeOut == 0 {
|
||||||
|
c.DialTimeOut = 5 * time.Second
|
||||||
|
}
|
||||||
|
|
||||||
|
// 连接
|
||||||
|
rdb := redis.NewClient(&redis.Options{
|
||||||
|
Addr: addr,
|
||||||
|
// Username: c.User,
|
||||||
|
Password: c.Password,
|
||||||
|
DB: c.Database,
|
||||||
|
DialTimeout: c.DialTimeOut,
|
||||||
|
})
|
||||||
|
|
||||||
|
// 测试数据库连接
|
||||||
|
if _, err := rdb.Ping(context.Background()).Result(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Client = rdb
|
||||||
|
return c, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close 关闭当前Redis客户端
|
||||||
|
func (c *ConnRedis) Close() {
|
||||||
|
if c.Client != nil {
|
||||||
|
c.Client.Close()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,6 +30,15 @@ if tonumber(current) == 1 then
|
|||||||
end
|
end
|
||||||
return tonumber(current);`)
|
return tonumber(current);`)
|
||||||
|
|
||||||
|
// 连接Redis实例
|
||||||
|
func ConnectPush(source string, rdb *redis.Client) {
|
||||||
|
if rdb == nil {
|
||||||
|
delete(rdbMap, source)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rdbMap[source] = rdb
|
||||||
|
}
|
||||||
|
|
||||||
// 连接Redis实例
|
// 连接Redis实例
|
||||||
func Connect() {
|
func Connect() {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|||||||
@@ -52,16 +52,18 @@ func (s *SocketTCP) Close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resolve 处理消息
|
// Resolve 处理消息
|
||||||
func (s *SocketTCP) Resolve(callback func(conn *net.Conn)) error {
|
func (s *SocketTCP) Resolve(callback func(conn *net.Conn, err error)) {
|
||||||
if s.Listener == nil {
|
if s.Listener == nil {
|
||||||
return fmt.Errorf("tcp service not created")
|
callback(nil, fmt.Errorf("tcp service not created"))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
listener := *s.Listener
|
listener := *s.Listener
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-s.StopChan:
|
case <-s.StopChan:
|
||||||
return fmt.Errorf("udp service stop")
|
callback(nil, fmt.Errorf("udp service stop"))
|
||||||
|
return
|
||||||
default:
|
default:
|
||||||
conn, err := listener.Accept()
|
conn, err := listener.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -69,14 +71,7 @@ func (s *SocketTCP) Resolve(callback func(conn *net.Conn)) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
callback(&conn, nil)
|
||||||
// 处理连接
|
|
||||||
callback(&conn)
|
|
||||||
|
|
||||||
// 发送响应
|
|
||||||
if _, err = conn.Write([]byte("tcp>")); err != nil {
|
|
||||||
fmt.Println("Error sending response:", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,22 +50,18 @@ func (s *SocketUDP) Close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resolve 处理消息
|
// Resolve 处理消息
|
||||||
func (s *SocketUDP) Resolve(callback func(*net.UDPConn)) error {
|
func (s *SocketUDP) Resolve(callback func(*net.UDPConn, error)) {
|
||||||
if s.Conn == nil {
|
if s.Conn == nil {
|
||||||
return fmt.Errorf("udp service not created")
|
callback(nil, fmt.Errorf("udp service not created"))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-s.StopChan:
|
case <-s.StopChan:
|
||||||
return fmt.Errorf("udp service stop")
|
callback(nil, fmt.Errorf("udp service not created"))
|
||||||
default:
|
default:
|
||||||
callback(s.Conn)
|
callback(s.Conn, nil)
|
||||||
|
|
||||||
// 发送响应
|
|
||||||
if _, err := s.Conn.WriteTo([]byte("udp>"), s.Conn.RemoteAddr()); err != nil {
|
|
||||||
fmt.Println("Error sending response:", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,11 +212,14 @@ func (c *ConnSSH) SendToAuthorizedKeys() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// "sudo mkdir -p ~/.ssh && sudo chown omcuser:omcuser ~/.ssh && sudo chmod 700 ~/.ssh"
|
||||||
|
// "sudo touch ~/.ssh/authorized_keys && sudo chown omcuser:omcuser ~/.ssh/authorized_keys && sudo chmod 600 ~/.ssh/authorized_keys"
|
||||||
|
// "echo 'ssh-rsa AAAAB3= pc-host\n' | sudo tee -a ~/.ssh/authorized_keys"
|
||||||
authorizedKeysEntry := fmt.Sprintln(strings.TrimSpace(publicKey))
|
authorizedKeysEntry := fmt.Sprintln(strings.TrimSpace(publicKey))
|
||||||
cmdStrArr := []string{
|
cmdStrArr := []string{
|
||||||
fmt.Sprintf("sudo mkdir -p /home/%s/.ssh && sudo chown %s:%s /home/%s/.ssh && sudo chmod 700 /home/%s/.ssh", c.User, c.User, c.User, c.User, c.User),
|
fmt.Sprintf("sudo mkdir -p ~/.ssh && sudo chown %s:%s ~/.ssh && sudo chmod 700 ~/.ssh", c.User, c.User),
|
||||||
fmt.Sprintf("sudo touch /home/%s/.ssh/authorized_keys && sudo chown %s:%s /home/%s/.ssh/authorized_keys && sudo chmod 600 /home/%s/.ssh/authorized_keys", c.User, c.User, c.User, c.User, c.User),
|
fmt.Sprintf("sudo touch ~/.ssh/authorized_keys && sudo chown %s:%s ~/.ssh/authorized_keys && sudo chmod 600 ~/.ssh/authorized_keys", c.User, c.User),
|
||||||
fmt.Sprintf("echo '%s' | sudo tee -a /home/%s/.ssh/authorized_keys", authorizedKeysEntry, c.User),
|
fmt.Sprintf("echo '%s' | sudo tee -a ~/.ssh/authorized_keys", authorizedKeysEntry),
|
||||||
}
|
}
|
||||||
_, err = c.RunCMD(strings.Join(cmdStrArr, " && "))
|
_, err = c.RunCMD(strings.Join(cmdStrArr, " && "))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
|
|
||||||
// 实例化控制层 AccountController 结构体
|
// 实例化控制层 AccountController 结构体
|
||||||
var NewAccount = &AccountController{
|
var NewAccount = &AccountController{
|
||||||
accountService: commonService.NewAccountImpl,
|
accountService: commonService.NewAccount,
|
||||||
sysLogLoginService: systemService.NewSysLogLoginImpl,
|
sysLogLoginService: systemService.NewSysLogLoginImpl,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,8 +25,7 @@ var NewAccount = &AccountController{
|
|||||||
//
|
//
|
||||||
// PATH /
|
// PATH /
|
||||||
type AccountController struct {
|
type AccountController struct {
|
||||||
// 账号身份操作服务
|
accountService *commonService.Account // 账号身份操作服务
|
||||||
accountService commonService.IAccount
|
|
||||||
// 系统登录访问
|
// 系统登录访问
|
||||||
sysLogLoginService systemService.ISysLogLogin
|
sysLogLoginService systemService.ISysLogLogin
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import (
|
|||||||
|
|
||||||
// 实例化控制层 BootloaderController 结构体
|
// 实例化控制层 BootloaderController 结构体
|
||||||
var NewBootloader = &BootloaderController{
|
var NewBootloader = &BootloaderController{
|
||||||
accountService: commonService.NewAccountImpl,
|
accountService: commonService.NewAccount,
|
||||||
sysUserService: systemService.NewSysUserImpl,
|
sysUserService: systemService.NewSysUserImpl,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,8 +26,7 @@ var NewBootloader = &BootloaderController{
|
|||||||
//
|
//
|
||||||
// PATH /bootloader
|
// PATH /bootloader
|
||||||
type BootloaderController struct {
|
type BootloaderController struct {
|
||||||
// 账号身份操作服务
|
accountService *commonService.Account // 账号身份操作服务
|
||||||
accountService commonService.IAccount
|
|
||||||
// 用户信息服务
|
// 用户信息服务
|
||||||
sysUserService systemService.ISysUser
|
sysUserService systemService.ISysUser
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,194 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import "be.ems/src/framework/vo"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
// 账号身份操作服务 服务层接口
|
"be.ems/src/framework/config"
|
||||||
type IAccount interface {
|
adminConstants "be.ems/src/framework/constants/admin"
|
||||||
// ValidateCaptcha 校验验证码
|
"be.ems/src/framework/constants/cachekey"
|
||||||
ValidateCaptcha(code, uuid string) error
|
"be.ems/src/framework/constants/common"
|
||||||
|
"be.ems/src/framework/redis"
|
||||||
|
"be.ems/src/framework/utils/crypto"
|
||||||
|
"be.ems/src/framework/utils/parse"
|
||||||
|
"be.ems/src/framework/vo"
|
||||||
|
"be.ems/src/modules/system/model"
|
||||||
|
systemService "be.ems/src/modules/system/service"
|
||||||
|
)
|
||||||
|
|
||||||
// LoginByUsername 登录生成token
|
// 实例化服务层 Account 结构体
|
||||||
LoginByUsername(username, password string) (vo.LoginUser, error)
|
var NewAccount = &Account{
|
||||||
|
sysUserService: systemService.NewSysUserImpl,
|
||||||
// UpdateLoginDateAndIP 更新登录时间和IP
|
sysConfigService: systemService.NewSysConfigImpl,
|
||||||
UpdateLoginDateAndIP(loginUser *vo.LoginUser) bool
|
sysRoleService: systemService.NewSysRoleImpl,
|
||||||
|
sysMenuService: systemService.NewSysMenuImpl,
|
||||||
// ClearLoginRecordCache 清除错误记录次数
|
}
|
||||||
ClearLoginRecordCache(username string) bool
|
|
||||||
|
// 账号身份操作服务 服务层处理
|
||||||
// RoleAndMenuPerms 角色和菜单数据权限
|
type Account struct {
|
||||||
RoleAndMenuPerms(userId string, isAdmin bool) ([]string, []string)
|
// 用户信息服务
|
||||||
|
sysUserService systemService.ISysUser
|
||||||
// RouteMenus 前端路由所需要的菜单
|
// 参数配置服务
|
||||||
RouteMenus(userId string, isAdmin bool) []vo.Router
|
sysConfigService systemService.ISysConfig
|
||||||
|
// 角色服务
|
||||||
|
sysRoleService systemService.ISysRole
|
||||||
|
// 菜单服务
|
||||||
|
sysMenuService systemService.ISysMenu
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidateCaptcha 校验验证码
|
||||||
|
func (s *Account) ValidateCaptcha(code, uuid string) error {
|
||||||
|
// 验证码检查,从数据库配置获取验证码开关 true开启,false关闭
|
||||||
|
captchaEnabledStr := s.sysConfigService.SelectConfigValueByKey("sys.account.captchaEnabled")
|
||||||
|
if !parse.Boolean(captchaEnabledStr) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if code == "" || uuid == "" {
|
||||||
|
// 验证码信息错误
|
||||||
|
return fmt.Errorf("captcha.err")
|
||||||
|
}
|
||||||
|
verifyKey := cachekey.CAPTCHA_CODE_KEY + uuid
|
||||||
|
captcha, _ := redis.Get("", verifyKey)
|
||||||
|
if captcha == "" {
|
||||||
|
// 验证码已失效
|
||||||
|
return fmt.Errorf("captcha.errValid")
|
||||||
|
}
|
||||||
|
redis.Del("", verifyKey)
|
||||||
|
if captcha != code {
|
||||||
|
// 验证码错误
|
||||||
|
return fmt.Errorf("captcha.err")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginByUsername 登录创建用户信息
|
||||||
|
func (s *Account) LoginByUsername(username, password string) (vo.LoginUser, error) {
|
||||||
|
loginUser := vo.LoginUser{}
|
||||||
|
|
||||||
|
// 检查密码重试次数
|
||||||
|
retrykey, retryCount, lockTime, err := s.passwordRetryCount(username)
|
||||||
|
if err != nil {
|
||||||
|
return loginUser, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询用户登录账号
|
||||||
|
sysUser := s.sysUserService.SelectUserByUserName(username)
|
||||||
|
if sysUser.UserName != username {
|
||||||
|
return loginUser, fmt.Errorf("login.errNameOrPasswd")
|
||||||
|
}
|
||||||
|
if sysUser.DelFlag == common.STATUS_YES {
|
||||||
|
// 对不起,您的账号已被删除
|
||||||
|
return loginUser, fmt.Errorf("login.errDelFlag")
|
||||||
|
}
|
||||||
|
if sysUser.Status == common.STATUS_NO {
|
||||||
|
return loginUser, fmt.Errorf("login.errStatus")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检验用户密码
|
||||||
|
compareBool := crypto.BcryptCompare(password, sysUser.Password)
|
||||||
|
if !compareBool {
|
||||||
|
redis.SetByExpire("", retrykey, retryCount+1, lockTime)
|
||||||
|
// 用户不存在或密码错误
|
||||||
|
return loginUser, fmt.Errorf("login.errNameOrPasswd")
|
||||||
|
} else {
|
||||||
|
// 清除错误记录次数
|
||||||
|
s.ClearLoginRecordCache(username)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 登录用户信息
|
||||||
|
loginUser.UserID = sysUser.UserID
|
||||||
|
loginUser.DeptID = sysUser.DeptID
|
||||||
|
loginUser.User = sysUser
|
||||||
|
// 用户权限组标识
|
||||||
|
isAdmin := config.IsAdmin(sysUser.UserID)
|
||||||
|
if isAdmin {
|
||||||
|
loginUser.Permissions = []string{adminConstants.PERMISSION}
|
||||||
|
} else {
|
||||||
|
perms := s.sysMenuService.SelectMenuPermsByUserId(sysUser.UserID)
|
||||||
|
loginUser.Permissions = parse.RemoveDuplicates(perms)
|
||||||
|
}
|
||||||
|
return loginUser, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateLoginDateAndIP 更新登录时间和IP
|
||||||
|
func (s *Account) UpdateLoginDateAndIP(loginUser *vo.LoginUser) bool {
|
||||||
|
sysUser := loginUser.User
|
||||||
|
userInfo := model.SysUser{
|
||||||
|
UserID: sysUser.UserID,
|
||||||
|
LoginIP: sysUser.LoginIP,
|
||||||
|
LoginDate: sysUser.LoginDate,
|
||||||
|
UpdateBy: sysUser.UserName,
|
||||||
|
Sex: sysUser.Sex,
|
||||||
|
PhoneNumber: sysUser.PhoneNumber,
|
||||||
|
Email: sysUser.Email,
|
||||||
|
Remark: sysUser.Remark,
|
||||||
|
}
|
||||||
|
rows := s.sysUserService.UpdateUser(userInfo)
|
||||||
|
return rows > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearLoginRecordCache 清除错误记录次数
|
||||||
|
func (s *Account) ClearLoginRecordCache(username string) bool {
|
||||||
|
cacheKey := cachekey.PWD_ERR_CNT_KEY + username
|
||||||
|
hasKey, _ := redis.Has("", cacheKey)
|
||||||
|
if hasKey {
|
||||||
|
delOk, _ := redis.Del("", cacheKey)
|
||||||
|
return delOk
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// passwordRetryCount 密码重试次数
|
||||||
|
func (s *Account) passwordRetryCount(username string) (string, int64, time.Duration, error) {
|
||||||
|
// 从数据库配置获取登录次数和错误锁定时间
|
||||||
|
maxRetryCountStr := s.sysConfigService.SelectConfigValueByKey("sys.user.maxRetryCount")
|
||||||
|
lockTimeStr := s.sysConfigService.SelectConfigValueByKey("sys.user.lockTime")
|
||||||
|
|
||||||
|
// 验证登录次数和错误锁定时间
|
||||||
|
maxRetryCount := parse.Number(maxRetryCountStr)
|
||||||
|
lockTime := parse.Number(lockTimeStr)
|
||||||
|
// 验证缓存记录次数
|
||||||
|
retrykey := cachekey.PWD_ERR_CNT_KEY + username
|
||||||
|
retryCount, err := redis.Get("", retrykey)
|
||||||
|
if retryCount == "" || err != nil {
|
||||||
|
retryCount = "0"
|
||||||
|
}
|
||||||
|
// 是否超过错误值
|
||||||
|
retryCountInt64 := parse.Number(retryCount)
|
||||||
|
if retryCountInt64 >= maxRetryCount {
|
||||||
|
// 密码输入错误多次,帐户已被锁定
|
||||||
|
errorMsg := fmt.Errorf("login.errRetryPasswd")
|
||||||
|
return retrykey, retryCountInt64, time.Duration(lockTime) * time.Minute, errorMsg
|
||||||
|
}
|
||||||
|
return retrykey, retryCountInt64, time.Duration(lockTime) * time.Minute, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleAndMenuPerms 角色和菜单数据权限
|
||||||
|
func (s *Account) RoleAndMenuPerms(userId string, isAdmin bool) ([]string, []string) {
|
||||||
|
if isAdmin {
|
||||||
|
return []string{adminConstants.ROLE_KEY}, []string{adminConstants.PERMISSION}
|
||||||
|
} else {
|
||||||
|
// 角色key
|
||||||
|
roleGroup := []string{}
|
||||||
|
roles := s.sysRoleService.SelectRoleListByUserId(userId)
|
||||||
|
for _, role := range roles {
|
||||||
|
roleGroup = append(roleGroup, role.RoleKey)
|
||||||
|
}
|
||||||
|
// 菜单权限key
|
||||||
|
perms := s.sysMenuService.SelectMenuPermsByUserId(userId)
|
||||||
|
return parse.RemoveDuplicates(roleGroup), parse.RemoveDuplicates(perms)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RouteMenus 前端路由所需要的菜单
|
||||||
|
func (s *Account) RouteMenus(userId string, isAdmin bool) []vo.Router {
|
||||||
|
var buildMenus []vo.Router
|
||||||
|
if isAdmin {
|
||||||
|
menus := s.sysMenuService.SelectMenuTreeByUserId("*")
|
||||||
|
buildMenus = s.sysMenuService.BuildRouteMenus(menus, "")
|
||||||
|
} else {
|
||||||
|
menus := s.sysMenuService.SelectMenuTreeByUserId(userId)
|
||||||
|
buildMenus = s.sysMenuService.BuildRouteMenus(menus, "")
|
||||||
|
}
|
||||||
|
return buildMenus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,190 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"be.ems/src/framework/config"
|
|
||||||
adminConstants "be.ems/src/framework/constants/admin"
|
|
||||||
"be.ems/src/framework/constants/cachekey"
|
|
||||||
"be.ems/src/framework/constants/common"
|
|
||||||
"be.ems/src/framework/redis"
|
|
||||||
"be.ems/src/framework/utils/crypto"
|
|
||||||
"be.ems/src/framework/utils/parse"
|
|
||||||
"be.ems/src/framework/vo"
|
|
||||||
"be.ems/src/modules/system/model"
|
|
||||||
systemService "be.ems/src/modules/system/service"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 实例化服务层 AccountImpl 结构体
|
|
||||||
var NewAccountImpl = &AccountImpl{
|
|
||||||
sysUserService: systemService.NewSysUserImpl,
|
|
||||||
sysConfigService: systemService.NewSysConfigImpl,
|
|
||||||
sysRoleService: systemService.NewSysRoleImpl,
|
|
||||||
sysMenuService: systemService.NewSysMenuImpl,
|
|
||||||
}
|
|
||||||
|
|
||||||
// 账号身份操作服务 服务层处理
|
|
||||||
type AccountImpl struct {
|
|
||||||
// 用户信息服务
|
|
||||||
sysUserService systemService.ISysUser
|
|
||||||
// 参数配置服务
|
|
||||||
sysConfigService systemService.ISysConfig
|
|
||||||
// 角色服务
|
|
||||||
sysRoleService systemService.ISysRole
|
|
||||||
// 菜单服务
|
|
||||||
sysMenuService systemService.ISysMenu
|
|
||||||
}
|
|
||||||
|
|
||||||
// ValidateCaptcha 校验验证码
|
|
||||||
func (s *AccountImpl) ValidateCaptcha(code, uuid string) error {
|
|
||||||
// 验证码检查,从数据库配置获取验证码开关 true开启,false关闭
|
|
||||||
captchaEnabledStr := s.sysConfigService.SelectConfigValueByKey("sys.account.captchaEnabled")
|
|
||||||
if !parse.Boolean(captchaEnabledStr) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if code == "" || uuid == "" {
|
|
||||||
// 验证码信息错误
|
|
||||||
return fmt.Errorf("captcha.err")
|
|
||||||
}
|
|
||||||
verifyKey := cachekey.CAPTCHA_CODE_KEY + uuid
|
|
||||||
captcha, _ := redis.Get("", verifyKey)
|
|
||||||
if captcha == "" {
|
|
||||||
// 验证码已失效
|
|
||||||
return fmt.Errorf("captcha.errValid")
|
|
||||||
}
|
|
||||||
redis.Del("", verifyKey)
|
|
||||||
if captcha != code {
|
|
||||||
// 验证码错误
|
|
||||||
return fmt.Errorf("captcha.err")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// LoginByUsername 登录创建用户信息
|
|
||||||
func (s *AccountImpl) LoginByUsername(username, password string) (vo.LoginUser, error) {
|
|
||||||
loginUser := vo.LoginUser{}
|
|
||||||
|
|
||||||
// 检查密码重试次数
|
|
||||||
retrykey, retryCount, lockTime, err := s.passwordRetryCount(username)
|
|
||||||
if err != nil {
|
|
||||||
return loginUser, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询用户登录账号
|
|
||||||
sysUser := s.sysUserService.SelectUserByUserName(username)
|
|
||||||
if sysUser.UserName != username {
|
|
||||||
return loginUser, fmt.Errorf("login.errNameOrPasswd")
|
|
||||||
}
|
|
||||||
if sysUser.DelFlag == common.STATUS_YES {
|
|
||||||
// 对不起,您的账号已被删除
|
|
||||||
return loginUser, fmt.Errorf("login.errDelFlag")
|
|
||||||
}
|
|
||||||
if sysUser.Status == common.STATUS_NO {
|
|
||||||
return loginUser, fmt.Errorf("login.errStatus")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检验用户密码
|
|
||||||
compareBool := crypto.BcryptCompare(password, sysUser.Password)
|
|
||||||
if !compareBool {
|
|
||||||
redis.SetByExpire("", retrykey, retryCount+1, lockTime)
|
|
||||||
// 用户不存在或密码错误
|
|
||||||
return loginUser, fmt.Errorf("login.errNameOrPasswd")
|
|
||||||
} else {
|
|
||||||
// 清除错误记录次数
|
|
||||||
s.ClearLoginRecordCache(username)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 登录用户信息
|
|
||||||
loginUser.UserID = sysUser.UserID
|
|
||||||
loginUser.DeptID = sysUser.DeptID
|
|
||||||
loginUser.User = sysUser
|
|
||||||
// 用户权限组标识
|
|
||||||
isAdmin := config.IsAdmin(sysUser.UserID)
|
|
||||||
if isAdmin {
|
|
||||||
loginUser.Permissions = []string{adminConstants.PERMISSION}
|
|
||||||
} else {
|
|
||||||
perms := s.sysMenuService.SelectMenuPermsByUserId(sysUser.UserID)
|
|
||||||
loginUser.Permissions = parse.RemoveDuplicates(perms)
|
|
||||||
}
|
|
||||||
return loginUser, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateLoginDateAndIP 更新登录时间和IP
|
|
||||||
func (s *AccountImpl) UpdateLoginDateAndIP(loginUser *vo.LoginUser) bool {
|
|
||||||
sysUser := loginUser.User
|
|
||||||
userInfo := model.SysUser{
|
|
||||||
UserID: sysUser.UserID,
|
|
||||||
LoginIP: sysUser.LoginIP,
|
|
||||||
LoginDate: sysUser.LoginDate,
|
|
||||||
UpdateBy: sysUser.UserName,
|
|
||||||
}
|
|
||||||
rows := s.sysUserService.UpdateUser(userInfo)
|
|
||||||
return rows > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearLoginRecordCache 清除错误记录次数
|
|
||||||
func (s *AccountImpl) ClearLoginRecordCache(username string) bool {
|
|
||||||
cacheKey := cachekey.PWD_ERR_CNT_KEY + username
|
|
||||||
hasKey, _ := redis.Has("", cacheKey)
|
|
||||||
if hasKey {
|
|
||||||
delOk, _ := redis.Del("", cacheKey)
|
|
||||||
return delOk
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// passwordRetryCount 密码重试次数
|
|
||||||
func (s *AccountImpl) passwordRetryCount(username string) (string, int64, time.Duration, error) {
|
|
||||||
// 从数据库配置获取登录次数和错误锁定时间
|
|
||||||
maxRetryCountStr := s.sysConfigService.SelectConfigValueByKey("sys.user.maxRetryCount")
|
|
||||||
lockTimeStr := s.sysConfigService.SelectConfigValueByKey("sys.user.lockTime")
|
|
||||||
|
|
||||||
// 验证登录次数和错误锁定时间
|
|
||||||
maxRetryCount := parse.Number(maxRetryCountStr)
|
|
||||||
lockTime := parse.Number(lockTimeStr)
|
|
||||||
// 验证缓存记录次数
|
|
||||||
retrykey := cachekey.PWD_ERR_CNT_KEY + username
|
|
||||||
retryCount, err := redis.Get("", retrykey)
|
|
||||||
if retryCount == "" || err != nil {
|
|
||||||
retryCount = "0"
|
|
||||||
}
|
|
||||||
// 是否超过错误值
|
|
||||||
retryCountInt64 := parse.Number(retryCount)
|
|
||||||
if retryCountInt64 >= maxRetryCount {
|
|
||||||
// 密码输入错误多次,帐户已被锁定
|
|
||||||
errorMsg := fmt.Errorf("login.errRetryPasswd")
|
|
||||||
return retrykey, retryCountInt64, time.Duration(lockTime) * time.Minute, errorMsg
|
|
||||||
}
|
|
||||||
return retrykey, retryCountInt64, time.Duration(lockTime) * time.Minute, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// RoleAndMenuPerms 角色和菜单数据权限
|
|
||||||
func (s *AccountImpl) RoleAndMenuPerms(userId string, isAdmin bool) ([]string, []string) {
|
|
||||||
if isAdmin {
|
|
||||||
return []string{adminConstants.ROLE_KEY}, []string{adminConstants.PERMISSION}
|
|
||||||
} else {
|
|
||||||
// 角色key
|
|
||||||
roleGroup := []string{}
|
|
||||||
roles := s.sysRoleService.SelectRoleListByUserId(userId)
|
|
||||||
for _, role := range roles {
|
|
||||||
roleGroup = append(roleGroup, role.RoleKey)
|
|
||||||
}
|
|
||||||
// 菜单权限key
|
|
||||||
perms := s.sysMenuService.SelectMenuPermsByUserId(userId)
|
|
||||||
return parse.RemoveDuplicates(roleGroup), parse.RemoveDuplicates(perms)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RouteMenus 前端路由所需要的菜单
|
|
||||||
func (s *AccountImpl) RouteMenus(userId string, isAdmin bool) []vo.Router {
|
|
||||||
var buildMenus []vo.Router
|
|
||||||
if isAdmin {
|
|
||||||
menus := s.sysMenuService.SelectMenuTreeByUserId("*")
|
|
||||||
buildMenus = s.sysMenuService.BuildRouteMenus(menus, "")
|
|
||||||
} else {
|
|
||||||
menus := s.sysMenuService.SelectMenuTreeByUserId(userId)
|
|
||||||
buildMenus = s.sysMenuService.BuildRouteMenus(menus, "")
|
|
||||||
}
|
|
||||||
return buildMenus
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var NewProcessor = &MonitorSysResourceProcessor{
|
var NewProcessor = &MonitorSysResourceProcessor{
|
||||||
monitorService: monitorService.NewMonitorImpl,
|
monitorService: monitorService.NewMonitor,
|
||||||
count: 0,
|
count: 0,
|
||||||
openDataCancel: false,
|
openDataCancel: false,
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ var NewProcessor = &MonitorSysResourceProcessor{
|
|||||||
// MonitorSysResourceProcessor 系统资源CPU/IO/Netword收集
|
// MonitorSysResourceProcessor 系统资源CPU/IO/Netword收集
|
||||||
type MonitorSysResourceProcessor struct {
|
type MonitorSysResourceProcessor struct {
|
||||||
// 服务器系统相关信息服务
|
// 服务器系统相关信息服务
|
||||||
monitorService monitorService.IMonitor
|
monitorService *monitorService.Monitor
|
||||||
// 执行次数
|
// 执行次数
|
||||||
count int
|
count int
|
||||||
// 是否已经开启数据通道
|
// 是否已经开启数据通道
|
||||||
|
|||||||
@@ -11,15 +11,14 @@ import (
|
|||||||
|
|
||||||
// 实例化控制层 MonitorInfoController 结构体
|
// 实例化控制层 MonitorInfoController 结构体
|
||||||
var NewMonitor = &MonitorController{
|
var NewMonitor = &MonitorController{
|
||||||
monitorService: service.NewMonitorImpl,
|
monitorService: service.NewMonitor,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 服务器资源监控信息
|
// 服务器资源监控信息
|
||||||
//
|
//
|
||||||
// PATH /monitor
|
// PATH /monitor
|
||||||
type MonitorController struct {
|
type MonitorController struct {
|
||||||
// 服务器系统相关信息服务
|
monitorService *service.Monitor // 服务器系统相关信息服务
|
||||||
monitorService service.IMonitor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 资源监控信息加载
|
// 资源监控信息加载
|
||||||
|
|||||||
@@ -22,18 +22,16 @@ import (
|
|||||||
|
|
||||||
// 实例化控制层 SysJobLogController 结构体
|
// 实例化控制层 SysJobLogController 结构体
|
||||||
var NewSysJob = &SysJobController{
|
var NewSysJob = &SysJobController{
|
||||||
sysJobService: service.NewSysJobImpl,
|
sysJobService: service.NewSysJob,
|
||||||
sysDictDataService: systemService.NewSysDictDataImpl,
|
sysDictDataService: systemService.NewSysDictData,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调度任务信息
|
// 调度任务信息
|
||||||
//
|
//
|
||||||
// PATH /monitor/job
|
// PATH /monitor/job
|
||||||
type SysJobController struct {
|
type SysJobController struct {
|
||||||
// 调度任务服务
|
sysJobService *service.SysJob // 调度任务服务
|
||||||
sysJobService service.ISysJob
|
sysDictDataService *systemService.SysDictData // 字典数据服务
|
||||||
// 字典数据服务
|
|
||||||
sysDictDataService systemService.ISysDictData
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调度任务列表
|
// 调度任务列表
|
||||||
|
|||||||
@@ -21,18 +21,16 @@ import (
|
|||||||
|
|
||||||
// 实例化控制层 SysJobLogController 结构体
|
// 实例化控制层 SysJobLogController 结构体
|
||||||
var NewSysJobLog = &SysJobLogController{
|
var NewSysJobLog = &SysJobLogController{
|
||||||
sysJobLogService: service.NewSysJobLogImpl,
|
sysJobLogService: service.NewSysJobLog,
|
||||||
sysDictDataService: systemService.NewSysDictDataImpl,
|
sysDictDataService: systemService.NewSysDictData,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调度任务日志信息
|
// 调度任务日志信息
|
||||||
//
|
//
|
||||||
// PATH /monitor/jobLog
|
// PATH /monitor/jobLog
|
||||||
type SysJobLogController struct {
|
type SysJobLogController struct {
|
||||||
// 调度任务日志服务
|
sysJobLogService *service.SysJobLog // 调度任务日志服务
|
||||||
sysJobLogService service.ISysJobLog
|
sysDictDataService *systemService.SysDictData // 字典数据服务
|
||||||
// 字典数据服务
|
|
||||||
sysDictDataService systemService.ISysDictData
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调度任务日志列表
|
// 调度任务日志列表
|
||||||
@@ -44,7 +42,7 @@ func (s *SysJobLogController) List(c *gin.Context) {
|
|||||||
querys := ctx.QueryMap(c)
|
querys := ctx.QueryMap(c)
|
||||||
// 任务ID优先级更高
|
// 任务ID优先级更高
|
||||||
if v, ok := querys["jobId"]; ok && v != nil {
|
if v, ok := querys["jobId"]; ok && v != nil {
|
||||||
jobInfo := service.NewSysJobImpl.SelectJobById(v.(string))
|
jobInfo := service.NewSysJob.SelectJobById(v.(string))
|
||||||
querys["jobName"] = jobInfo.JobName
|
querys["jobName"] = jobInfo.JobName
|
||||||
querys["jobGroup"] = jobInfo.JobGroup
|
querys["jobGroup"] = jobInfo.JobGroup
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,15 +19,14 @@ import (
|
|||||||
|
|
||||||
// 实例化控制层 SysUserOnlineController 结构体
|
// 实例化控制层 SysUserOnlineController 结构体
|
||||||
var NewSysUserOnline = &SysUserOnlineController{
|
var NewSysUserOnline = &SysUserOnlineController{
|
||||||
sysUserOnlineService: service.NewSysUserOnlineImpl,
|
sysUserOnlineService: service.NewSysUserOnline,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 在线用户监控
|
// 在线用户监控
|
||||||
//
|
//
|
||||||
// PATH /monitor/online
|
// PATH /monitor/online
|
||||||
type SysUserOnlineController struct {
|
type SysUserOnlineController struct {
|
||||||
// 在线用户服务
|
sysUserOnlineService *service.SysUserOnline // 在线用户服务
|
||||||
sysUserOnlineService service.ISysUserOnline
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 在线用户列表
|
// 在线用户列表
|
||||||
|
|||||||
@@ -9,15 +9,14 @@ import (
|
|||||||
|
|
||||||
// 实例化控制层 SystemInfoController 结构体
|
// 实例化控制层 SystemInfoController 结构体
|
||||||
var NewSystemInfo = &SystemInfoController{
|
var NewSystemInfo = &SystemInfoController{
|
||||||
systemInfogService: service.NewSystemInfoImpl,
|
systemInfogService: service.NewSystemInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 服务器监控信息
|
// 服务器监控信息
|
||||||
//
|
//
|
||||||
// PATH /monitor/system-info
|
// PATH /monitor/system-info
|
||||||
type SystemInfoController struct {
|
type SystemInfoController struct {
|
||||||
// 服务器系统相关信息服务
|
systemInfogService *service.SystemInfo // 服务器系统相关信息服务
|
||||||
systemInfogService service.ISystemInfo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 服务器信息
|
// 服务器信息
|
||||||
|
|||||||
@@ -165,5 +165,5 @@ func InitLoad() {
|
|||||||
// 初始化定时任务处理
|
// 初始化定时任务处理
|
||||||
processor.InitCronQueue()
|
processor.InitCronQueue()
|
||||||
// 启动时,初始化调度任务
|
// 启动时,初始化调度任务
|
||||||
service.NewSysJobImpl.ResetQueueJob()
|
service.NewSysJob.ResetQueueJob()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,274 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
// IMonitor 服务器系统相关信息 服务层接口
|
import (
|
||||||
type IMonitor interface {
|
"context"
|
||||||
// RunMonitor 执行资源监控
|
"strconv"
|
||||||
RunMonitor()
|
"time"
|
||||||
|
|
||||||
// RunMonitorDataCancel 启动资源监控数据存储io/network通道 移除之前的chan上下文后在设置新的均值
|
"be.ems/src/framework/logger"
|
||||||
// interval 采集的平均值(分钟)
|
"be.ems/src/modules/monitor/model"
|
||||||
RunMonitorDataCancel(removeBefore bool, interval float64)
|
"be.ems/src/modules/monitor/repository"
|
||||||
|
systemService "be.ems/src/modules/system/service"
|
||||||
|
"github.com/shirou/gopsutil/v4/cpu"
|
||||||
|
"github.com/shirou/gopsutil/v4/disk"
|
||||||
|
"github.com/shirou/gopsutil/v4/load"
|
||||||
|
"github.com/shirou/gopsutil/v4/mem"
|
||||||
|
"github.com/shirou/gopsutil/v4/net"
|
||||||
|
)
|
||||||
|
|
||||||
// SelectMonitorInfo 查询监控资源信息
|
// 实例化服务层 Monitor 结构体
|
||||||
SelectMonitorInfo(query map[string]any) map[string]any
|
var NewMonitor = &Monitor{
|
||||||
|
sysConfigService: systemService.NewSysConfigImpl,
|
||||||
|
monitorRepository: repository.NewMonitorImpl,
|
||||||
|
diskIO: make(chan []disk.IOCountersStat, 2),
|
||||||
|
netIO: make(chan []net.IOCountersStat, 2),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Monitor 服务器系统相关信息 服务层处理
|
||||||
|
type Monitor struct {
|
||||||
|
// 参数配置服务
|
||||||
|
sysConfigService systemService.ISysConfig
|
||||||
|
// 监控服务资源数据信息
|
||||||
|
monitorRepository repository.IMonitor
|
||||||
|
// 磁盘网络IO 数据通道
|
||||||
|
diskIO chan ([]disk.IOCountersStat)
|
||||||
|
netIO chan ([]net.IOCountersStat)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RunMonitor 执行资源监控
|
||||||
|
func (s *Monitor) RunMonitor() {
|
||||||
|
var itemBase model.MonitorBase
|
||||||
|
itemBase.CreateTime = time.Now().UnixMilli()
|
||||||
|
itemBase.NeType = "#"
|
||||||
|
itemBase.NeID = "#"
|
||||||
|
loadInfo, _ := load.Avg()
|
||||||
|
itemBase.CPULoad1 = loadInfo.Load1
|
||||||
|
itemBase.CPULoad5 = loadInfo.Load5
|
||||||
|
itemBase.CPULoad15 = loadInfo.Load15
|
||||||
|
totalPercent, _ := cpu.Percent(3*time.Second, false)
|
||||||
|
if len(totalPercent) > 0 {
|
||||||
|
itemBase.CPU = totalPercent[0]
|
||||||
|
}
|
||||||
|
cpuCount, _ := cpu.Counts(false)
|
||||||
|
cpuAvg := (float64(cpuCount*2) * 0.75) * 100
|
||||||
|
itemBase.LoadUsage = 0
|
||||||
|
if cpuAvg > 0 {
|
||||||
|
itemBase.LoadUsage = loadInfo.Load1 / cpuAvg
|
||||||
|
}
|
||||||
|
|
||||||
|
memoryInfo, _ := mem.VirtualMemory()
|
||||||
|
itemBase.Memory = memoryInfo.UsedPercent
|
||||||
|
|
||||||
|
if err := s.monitorRepository.CreateMonitorBase(itemBase); err != nil {
|
||||||
|
logger.Errorf("CreateMonitorBase err: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将当前资源发送到chan中处理保存
|
||||||
|
s.loadDiskIO()
|
||||||
|
s.loadNetIO()
|
||||||
|
|
||||||
|
// 监控系统资源-保留天数
|
||||||
|
storeDays := s.sysConfigService.SelectConfigValueByKey("monitor.sysResource.storeDays")
|
||||||
|
if storeDays != "" {
|
||||||
|
storeDays, _ := strconv.Atoi(storeDays)
|
||||||
|
ltTime := time.Now().AddDate(0, 0, -storeDays).UnixMilli()
|
||||||
|
_ = s.monitorRepository.DelMonitorBase(ltTime)
|
||||||
|
_ = s.monitorRepository.DelMonitorIO(ltTime)
|
||||||
|
_ = s.monitorRepository.DelMonitorNet(ltTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Monitor) loadDiskIO() {
|
||||||
|
ioStat, _ := disk.IOCounters()
|
||||||
|
var diskIOList []disk.IOCountersStat
|
||||||
|
for _, io := range ioStat {
|
||||||
|
diskIOList = append(diskIOList, io)
|
||||||
|
}
|
||||||
|
s.diskIO <- diskIOList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Monitor) loadNetIO() {
|
||||||
|
netStat, _ := net.IOCounters(true)
|
||||||
|
netStatAll, _ := net.IOCounters(false)
|
||||||
|
var netList []net.IOCountersStat
|
||||||
|
netList = append(netList, netStat...)
|
||||||
|
netList = append(netList, netStatAll...)
|
||||||
|
s.netIO <- netList
|
||||||
|
}
|
||||||
|
|
||||||
|
// monitorCancel 监控搜集IO/Network上下文
|
||||||
|
var monitorCancel context.CancelFunc
|
||||||
|
|
||||||
|
// RunMonitorDataCancel 启动资源监控数据存储io/network通道 移除之前的chan上下文后在设置新的均值
|
||||||
|
// interval 采集的平均值(分钟)
|
||||||
|
func (s *Monitor) RunMonitorDataCancel(removeBefore bool, interval float64) {
|
||||||
|
// 是否取消之前的
|
||||||
|
if removeBefore {
|
||||||
|
monitorCancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 上下文控制
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
monitorCancel = cancel
|
||||||
|
|
||||||
|
// chanl 通道进行存储数据
|
||||||
|
go s.saveIODataToDB(ctx, interval)
|
||||||
|
go s.saveNetDataToDB(ctx, interval)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Monitor) saveIODataToDB(ctx context.Context, interval float64) {
|
||||||
|
defer close(s.diskIO)
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
|
case ioStat := <-s.diskIO:
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
|
case ioStat2 := <-s.diskIO:
|
||||||
|
var ioList []model.MonitorIO
|
||||||
|
timeMilli := time.Now().UnixMilli()
|
||||||
|
for _, io2 := range ioStat2 {
|
||||||
|
for _, io1 := range ioStat {
|
||||||
|
if io2.Name == io1.Name {
|
||||||
|
var itemIO model.MonitorIO
|
||||||
|
itemIO.CreateTime = timeMilli
|
||||||
|
itemIO.NeType = "#"
|
||||||
|
itemIO.NeID = "#"
|
||||||
|
itemIO.Name = io1.Name
|
||||||
|
|
||||||
|
if io2.ReadBytes != 0 && io1.ReadBytes != 0 && io2.ReadBytes > io1.ReadBytes {
|
||||||
|
itemIO.Read = int64(float64(io2.ReadBytes-io1.ReadBytes) / interval / 60)
|
||||||
|
}
|
||||||
|
if io2.WriteBytes != 0 && io1.WriteBytes != 0 && io2.WriteBytes > io1.WriteBytes {
|
||||||
|
itemIO.Write = int64(float64(io2.WriteBytes-io1.WriteBytes) / interval / 60)
|
||||||
|
}
|
||||||
|
|
||||||
|
if io2.ReadCount != 0 && io1.ReadCount != 0 && io2.ReadCount > io1.ReadCount {
|
||||||
|
itemIO.Count = int64(float64(io2.ReadCount-io1.ReadCount) / interval / 60)
|
||||||
|
}
|
||||||
|
writeCount := int64(0)
|
||||||
|
if io2.WriteCount != 0 && io1.WriteCount != 0 && io2.WriteCount > io1.WriteCount {
|
||||||
|
writeCount = int64(float64(io2.WriteCount-io1.WriteCount) / interval * 60)
|
||||||
|
}
|
||||||
|
if writeCount > itemIO.Count {
|
||||||
|
itemIO.Count = writeCount
|
||||||
|
}
|
||||||
|
|
||||||
|
if io2.ReadTime != 0 && io1.ReadTime != 0 && io2.ReadTime > io1.ReadTime {
|
||||||
|
itemIO.Time = int64(float64(io2.ReadTime-io1.ReadTime) / interval / 60)
|
||||||
|
}
|
||||||
|
writeTime := int64(0)
|
||||||
|
if io2.WriteTime != 0 && io1.WriteTime != 0 && io2.WriteTime > io1.WriteTime {
|
||||||
|
writeTime = int64(float64(io2.WriteTime-io1.WriteTime) / interval / 60)
|
||||||
|
}
|
||||||
|
if writeTime > itemIO.Time {
|
||||||
|
itemIO.Time = writeTime
|
||||||
|
}
|
||||||
|
ioList = append(ioList, itemIO)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := s.monitorRepository.BatchCreateMonitorIO(ioList); err != nil {
|
||||||
|
logger.Errorf("BatchCreateMonitorIO err: %v", err)
|
||||||
|
}
|
||||||
|
s.diskIO <- ioStat2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Monitor) saveNetDataToDB(ctx context.Context, interval float64) {
|
||||||
|
defer close(s.netIO)
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
|
case netStat := <-s.netIO:
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
|
case netStat2 := <-s.netIO:
|
||||||
|
var netList []model.MonitorNetwork
|
||||||
|
timeMilli := time.Now().UnixMilli()
|
||||||
|
for _, net2 := range netStat2 {
|
||||||
|
for _, net1 := range netStat {
|
||||||
|
if net2.Name == net1.Name {
|
||||||
|
var itemNet model.MonitorNetwork
|
||||||
|
itemNet.CreateTime = timeMilli
|
||||||
|
itemNet.NeType = "#"
|
||||||
|
itemNet.NeID = "#"
|
||||||
|
itemNet.Name = net1.Name
|
||||||
|
|
||||||
|
if net2.BytesSent != 0 && net1.BytesSent != 0 && net2.BytesSent > net1.BytesSent {
|
||||||
|
itemNet.Up = float64(net2.BytesSent-net1.BytesSent) / 1024 / interval / 60
|
||||||
|
}
|
||||||
|
if net2.BytesRecv != 0 && net1.BytesRecv != 0 && net2.BytesRecv > net1.BytesRecv {
|
||||||
|
itemNet.Down = float64(net2.BytesRecv-net1.BytesRecv) / 1024 / interval / 60
|
||||||
|
}
|
||||||
|
netList = append(netList, itemNet)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := s.monitorRepository.BatchCreateMonitorNet(netList); err != nil {
|
||||||
|
logger.Errorf("BatchCreateMonitorNet err: %v", err)
|
||||||
|
}
|
||||||
|
s.netIO <- netStat2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SelectMonitorInfo 查询监控资源信息
|
||||||
|
func (s *Monitor) SelectMonitorInfo(query map[string]any) map[string]any {
|
||||||
|
infoType := query["type"]
|
||||||
|
startTimeMilli := query["startTime"]
|
||||||
|
endTimeMilli := query["endTime"]
|
||||||
|
neType := query["neType"]
|
||||||
|
neId := query["neId"]
|
||||||
|
name := query["name"]
|
||||||
|
|
||||||
|
// 返回数据
|
||||||
|
backDatas := map[string]any{}
|
||||||
|
|
||||||
|
// 基本信息
|
||||||
|
if infoType == "all" || infoType == "load" || infoType == "cpu" || infoType == "memory" {
|
||||||
|
rows := s.monitorRepository.SelectMonitorBase(map[string]any{
|
||||||
|
"startTime": startTimeMilli,
|
||||||
|
"endTime": endTimeMilli,
|
||||||
|
"neType": neType,
|
||||||
|
"neId": neId,
|
||||||
|
})
|
||||||
|
backDatas["base"] = rows
|
||||||
|
}
|
||||||
|
|
||||||
|
// 磁盘IO
|
||||||
|
if infoType == "all" || infoType == "io" {
|
||||||
|
rows := s.monitorRepository.SelectMonitorIO(map[string]any{
|
||||||
|
"startTime": startTimeMilli,
|
||||||
|
"endTime": endTimeMilli,
|
||||||
|
"neType": neType,
|
||||||
|
"neId": neId,
|
||||||
|
"name": name,
|
||||||
|
})
|
||||||
|
backDatas["io"] = rows
|
||||||
|
}
|
||||||
|
|
||||||
|
// 网络
|
||||||
|
if infoType == "all" || infoType == "network" {
|
||||||
|
rows := s.monitorRepository.SelectMonitorNetwork(map[string]any{
|
||||||
|
"startTime": startTimeMilli,
|
||||||
|
"endTime": endTimeMilli,
|
||||||
|
"neType": neType,
|
||||||
|
"neId": neId,
|
||||||
|
"name": name,
|
||||||
|
})
|
||||||
|
backDatas["network"] = rows
|
||||||
|
}
|
||||||
|
|
||||||
|
return backDatas
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,274 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"be.ems/src/framework/logger"
|
|
||||||
"be.ems/src/modules/monitor/model"
|
|
||||||
"be.ems/src/modules/monitor/repository"
|
|
||||||
systemService "be.ems/src/modules/system/service"
|
|
||||||
"github.com/shirou/gopsutil/v4/cpu"
|
|
||||||
"github.com/shirou/gopsutil/v4/disk"
|
|
||||||
"github.com/shirou/gopsutil/v4/load"
|
|
||||||
"github.com/shirou/gopsutil/v4/mem"
|
|
||||||
"github.com/shirou/gopsutil/v4/net"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 实例化服务层 MonitorImpl 结构体
|
|
||||||
var NewMonitorImpl = &MonitorImpl{
|
|
||||||
sysConfigService: systemService.NewSysConfigImpl,
|
|
||||||
monitorRepository: repository.NewMonitorImpl,
|
|
||||||
diskIO: make(chan []disk.IOCountersStat, 2),
|
|
||||||
netIO: make(chan []net.IOCountersStat, 2),
|
|
||||||
}
|
|
||||||
|
|
||||||
// MonitorImpl 服务器系统相关信息 服务层处理
|
|
||||||
type MonitorImpl struct {
|
|
||||||
// 参数配置服务
|
|
||||||
sysConfigService systemService.ISysConfig
|
|
||||||
// 监控服务资源数据信息
|
|
||||||
monitorRepository repository.IMonitor
|
|
||||||
// 磁盘网络IO 数据通道
|
|
||||||
diskIO chan ([]disk.IOCountersStat)
|
|
||||||
netIO chan ([]net.IOCountersStat)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RunMonitor 执行资源监控
|
|
||||||
func (s *MonitorImpl) RunMonitor() {
|
|
||||||
var itemBase model.MonitorBase
|
|
||||||
itemBase.CreateTime = time.Now().UnixMilli()
|
|
||||||
itemBase.NeType = "#"
|
|
||||||
itemBase.NeID = "#"
|
|
||||||
loadInfo, _ := load.Avg()
|
|
||||||
itemBase.CPULoad1 = loadInfo.Load1
|
|
||||||
itemBase.CPULoad5 = loadInfo.Load5
|
|
||||||
itemBase.CPULoad15 = loadInfo.Load15
|
|
||||||
totalPercent, _ := cpu.Percent(3*time.Second, false)
|
|
||||||
if len(totalPercent) == 1 {
|
|
||||||
itemBase.CPU = totalPercent[0]
|
|
||||||
}
|
|
||||||
cpuCount, _ := cpu.Counts(false)
|
|
||||||
cpuAvg := (float64(cpuCount*2) * 0.75) * 100
|
|
||||||
itemBase.LoadUsage = 0
|
|
||||||
if cpuAvg > 0 {
|
|
||||||
itemBase.LoadUsage = loadInfo.Load1 / cpuAvg
|
|
||||||
}
|
|
||||||
|
|
||||||
memoryInfo, _ := mem.VirtualMemory()
|
|
||||||
itemBase.Memory = memoryInfo.UsedPercent
|
|
||||||
|
|
||||||
if err := s.monitorRepository.CreateMonitorBase(itemBase); err != nil {
|
|
||||||
logger.Errorf("CreateMonitorBase err: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 将当前资源发送到chan中处理保存
|
|
||||||
s.loadDiskIO()
|
|
||||||
s.loadNetIO()
|
|
||||||
|
|
||||||
// 监控系统资源-保留天数
|
|
||||||
storeDays := s.sysConfigService.SelectConfigValueByKey("monitor.sysResource.storeDays")
|
|
||||||
if storeDays != "" {
|
|
||||||
storeDays, _ := strconv.Atoi(storeDays)
|
|
||||||
ltTime := time.Now().AddDate(0, 0, -storeDays).UnixMilli()
|
|
||||||
_ = s.monitorRepository.DelMonitorBase(ltTime)
|
|
||||||
_ = s.monitorRepository.DelMonitorIO(ltTime)
|
|
||||||
_ = s.monitorRepository.DelMonitorNet(ltTime)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *MonitorImpl) loadDiskIO() {
|
|
||||||
ioStat, _ := disk.IOCounters()
|
|
||||||
var diskIOList []disk.IOCountersStat
|
|
||||||
for _, io := range ioStat {
|
|
||||||
diskIOList = append(diskIOList, io)
|
|
||||||
}
|
|
||||||
s.diskIO <- diskIOList
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *MonitorImpl) loadNetIO() {
|
|
||||||
netStat, _ := net.IOCounters(true)
|
|
||||||
netStatAll, _ := net.IOCounters(false)
|
|
||||||
var netList []net.IOCountersStat
|
|
||||||
netList = append(netList, netStat...)
|
|
||||||
netList = append(netList, netStatAll...)
|
|
||||||
s.netIO <- netList
|
|
||||||
}
|
|
||||||
|
|
||||||
// monitorCancel 监控搜集IO/Network上下文
|
|
||||||
var monitorCancel context.CancelFunc
|
|
||||||
|
|
||||||
// RunMonitorDataCancel 启动资源监控数据存储io/network通道 移除之前的chan上下文后在设置新的均值
|
|
||||||
// interval 采集的平均值(分钟)
|
|
||||||
func (s *MonitorImpl) RunMonitorDataCancel(removeBefore bool, interval float64) {
|
|
||||||
// 是否取消之前的
|
|
||||||
if removeBefore {
|
|
||||||
monitorCancel()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 上下文控制
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
|
||||||
monitorCancel = cancel
|
|
||||||
|
|
||||||
// chanl 通道进行存储数据
|
|
||||||
go s.saveIODataToDB(ctx, interval)
|
|
||||||
go s.saveNetDataToDB(ctx, interval)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *MonitorImpl) saveIODataToDB(ctx context.Context, interval float64) {
|
|
||||||
defer close(s.diskIO)
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-ctx.Done():
|
|
||||||
return
|
|
||||||
case ioStat := <-s.diskIO:
|
|
||||||
select {
|
|
||||||
case <-ctx.Done():
|
|
||||||
return
|
|
||||||
case ioStat2 := <-s.diskIO:
|
|
||||||
var ioList []model.MonitorIO
|
|
||||||
timeMilli := time.Now().UnixMilli()
|
|
||||||
for _, io2 := range ioStat2 {
|
|
||||||
for _, io1 := range ioStat {
|
|
||||||
if io2.Name == io1.Name {
|
|
||||||
var itemIO model.MonitorIO
|
|
||||||
itemIO.CreateTime = timeMilli
|
|
||||||
itemIO.NeType = "#"
|
|
||||||
itemIO.NeID = "#"
|
|
||||||
itemIO.Name = io1.Name
|
|
||||||
|
|
||||||
if io2.ReadBytes != 0 && io1.ReadBytes != 0 && io2.ReadBytes > io1.ReadBytes {
|
|
||||||
itemIO.Read = int64(float64(io2.ReadBytes-io1.ReadBytes) / interval / 60)
|
|
||||||
}
|
|
||||||
if io2.WriteBytes != 0 && io1.WriteBytes != 0 && io2.WriteBytes > io1.WriteBytes {
|
|
||||||
itemIO.Write = int64(float64(io2.WriteBytes-io1.WriteBytes) / interval / 60)
|
|
||||||
}
|
|
||||||
|
|
||||||
if io2.ReadCount != 0 && io1.ReadCount != 0 && io2.ReadCount > io1.ReadCount {
|
|
||||||
itemIO.Count = int64(float64(io2.ReadCount-io1.ReadCount) / interval / 60)
|
|
||||||
}
|
|
||||||
writeCount := int64(0)
|
|
||||||
if io2.WriteCount != 0 && io1.WriteCount != 0 && io2.WriteCount > io1.WriteCount {
|
|
||||||
writeCount = int64(float64(io2.WriteCount-io1.WriteCount) / interval * 60)
|
|
||||||
}
|
|
||||||
if writeCount > itemIO.Count {
|
|
||||||
itemIO.Count = writeCount
|
|
||||||
}
|
|
||||||
|
|
||||||
if io2.ReadTime != 0 && io1.ReadTime != 0 && io2.ReadTime > io1.ReadTime {
|
|
||||||
itemIO.Time = int64(float64(io2.ReadTime-io1.ReadTime) / interval / 60)
|
|
||||||
}
|
|
||||||
writeTime := int64(0)
|
|
||||||
if io2.WriteTime != 0 && io1.WriteTime != 0 && io2.WriteTime > io1.WriteTime {
|
|
||||||
writeTime = int64(float64(io2.WriteTime-io1.WriteTime) / interval / 60)
|
|
||||||
}
|
|
||||||
if writeTime > itemIO.Time {
|
|
||||||
itemIO.Time = writeTime
|
|
||||||
}
|
|
||||||
ioList = append(ioList, itemIO)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := s.monitorRepository.BatchCreateMonitorIO(ioList); err != nil {
|
|
||||||
logger.Errorf("BatchCreateMonitorIO err: %v", err)
|
|
||||||
}
|
|
||||||
s.diskIO <- ioStat2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *MonitorImpl) saveNetDataToDB(ctx context.Context, interval float64) {
|
|
||||||
defer close(s.netIO)
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-ctx.Done():
|
|
||||||
return
|
|
||||||
case netStat := <-s.netIO:
|
|
||||||
select {
|
|
||||||
case <-ctx.Done():
|
|
||||||
return
|
|
||||||
case netStat2 := <-s.netIO:
|
|
||||||
var netList []model.MonitorNetwork
|
|
||||||
timeMilli := time.Now().UnixMilli()
|
|
||||||
for _, net2 := range netStat2 {
|
|
||||||
for _, net1 := range netStat {
|
|
||||||
if net2.Name == net1.Name {
|
|
||||||
var itemNet model.MonitorNetwork
|
|
||||||
itemNet.CreateTime = timeMilli
|
|
||||||
itemNet.NeType = "#"
|
|
||||||
itemNet.NeID = "#"
|
|
||||||
itemNet.Name = net1.Name
|
|
||||||
|
|
||||||
if net2.BytesSent != 0 && net1.BytesSent != 0 && net2.BytesSent > net1.BytesSent {
|
|
||||||
itemNet.Up = float64(net2.BytesSent-net1.BytesSent) / 1024 / interval / 60
|
|
||||||
}
|
|
||||||
if net2.BytesRecv != 0 && net1.BytesRecv != 0 && net2.BytesRecv > net1.BytesRecv {
|
|
||||||
itemNet.Down = float64(net2.BytesRecv-net1.BytesRecv) / 1024 / interval / 60
|
|
||||||
}
|
|
||||||
netList = append(netList, itemNet)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := s.monitorRepository.BatchCreateMonitorNet(netList); err != nil {
|
|
||||||
logger.Errorf("BatchCreateMonitorNet err: %v", err)
|
|
||||||
}
|
|
||||||
s.netIO <- netStat2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SelectMonitorInfo 查询监控资源信息
|
|
||||||
func (s *MonitorImpl) SelectMonitorInfo(query map[string]any) map[string]any {
|
|
||||||
infoType := query["type"]
|
|
||||||
startTimeMilli := query["startTime"]
|
|
||||||
endTimeMilli := query["endTime"]
|
|
||||||
neType := query["neType"]
|
|
||||||
neId := query["neId"]
|
|
||||||
name := query["name"]
|
|
||||||
|
|
||||||
// 返回数据
|
|
||||||
backDatas := map[string]any{}
|
|
||||||
|
|
||||||
// 基本信息
|
|
||||||
if infoType == "all" || infoType == "load" || infoType == "cpu" || infoType == "memory" {
|
|
||||||
rows := s.monitorRepository.SelectMonitorBase(map[string]any{
|
|
||||||
"startTime": startTimeMilli,
|
|
||||||
"endTime": endTimeMilli,
|
|
||||||
"neType": neType,
|
|
||||||
"neId": neId,
|
|
||||||
})
|
|
||||||
backDatas["base"] = rows
|
|
||||||
}
|
|
||||||
|
|
||||||
// 磁盘IO
|
|
||||||
if infoType == "all" || infoType == "io" {
|
|
||||||
rows := s.monitorRepository.SelectMonitorIO(map[string]any{
|
|
||||||
"startTime": startTimeMilli,
|
|
||||||
"endTime": endTimeMilli,
|
|
||||||
"neType": neType,
|
|
||||||
"neId": neId,
|
|
||||||
"name": name,
|
|
||||||
})
|
|
||||||
backDatas["io"] = rows
|
|
||||||
}
|
|
||||||
|
|
||||||
// 网络
|
|
||||||
if infoType == "all" || infoType == "network" {
|
|
||||||
rows := s.monitorRepository.SelectMonitorNetwork(map[string]any{
|
|
||||||
"startTime": startTimeMilli,
|
|
||||||
"endTime": endTimeMilli,
|
|
||||||
"neType": neType,
|
|
||||||
"neId": neId,
|
|
||||||
"name": name,
|
|
||||||
})
|
|
||||||
backDatas["network"] = rows
|
|
||||||
}
|
|
||||||
|
|
||||||
return backDatas
|
|
||||||
}
|
|
||||||
@@ -12,10 +12,6 @@ import (
|
|||||||
"github.com/shirou/gopsutil/v4/net"
|
"github.com/shirou/gopsutil/v4/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestInfo(t *testing.T) {
|
func TestInfo(t *testing.T) {
|
||||||
s := MonitorInfo{}
|
s := MonitorInfo{}
|
||||||
s.load(0.5) // 0.5 半分钟
|
s.load(0.5) // 0.5 半分钟
|
||||||
@@ -36,17 +32,21 @@ func (m *MonitorInfo) load(interval float64) {
|
|||||||
var itemBase MonitorBase
|
var itemBase MonitorBase
|
||||||
itemBase.CreateTime = time.Now().UnixMilli()
|
itemBase.CreateTime = time.Now().UnixMilli()
|
||||||
|
|
||||||
totalPercent, _ := cpu.Percent(3*time.Second, false)
|
|
||||||
if len(totalPercent) == 1 {
|
|
||||||
itemBase.CPU = totalPercent[0]
|
|
||||||
}
|
|
||||||
cpuCount, _ := cpu.Counts(false)
|
|
||||||
|
|
||||||
loadInfo, _ := load.Avg()
|
loadInfo, _ := load.Avg()
|
||||||
itemBase.CPULoad1 = loadInfo.Load1
|
itemBase.CPULoad1 = loadInfo.Load1
|
||||||
itemBase.CPULoad5 = loadInfo.Load5
|
itemBase.CPULoad5 = loadInfo.Load5
|
||||||
itemBase.CPULoad15 = loadInfo.Load15
|
itemBase.CPULoad15 = loadInfo.Load15
|
||||||
itemBase.LoadUsage = loadInfo.Load1 / (float64(cpuCount*2) * 0.75) * 100
|
|
||||||
|
totalPercent, _ := cpu.Percent(3*time.Second, false)
|
||||||
|
if len(totalPercent) > 0 {
|
||||||
|
itemBase.CPU = totalPercent[0]
|
||||||
|
}
|
||||||
|
cpuCount, _ := cpu.Counts(false)
|
||||||
|
cpuAvg := (float64(cpuCount*2) * 0.75) * 100
|
||||||
|
itemBase.LoadUsage = 0
|
||||||
|
if cpuAvg > 0 {
|
||||||
|
itemBase.LoadUsage = loadInfo.Load1 / cpuAvg
|
||||||
|
}
|
||||||
|
|
||||||
memoryInfo, _ := mem.VirtualMemory()
|
memoryInfo, _ := mem.VirtualMemory()
|
||||||
itemBase.Memory = memoryInfo.UsedPercent
|
itemBase.Memory = memoryInfo.UsedPercent
|
||||||
|
|||||||
@@ -1,35 +1,169 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"be.ems/src/framework/constants/common"
|
||||||
|
"be.ems/src/framework/cron"
|
||||||
"be.ems/src/modules/monitor/model"
|
"be.ems/src/modules/monitor/model"
|
||||||
|
"be.ems/src/modules/monitor/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ISysJob 调度任务信息 服务层接口
|
// 实例化服务层 SysJob 结构体
|
||||||
type ISysJob interface {
|
var NewSysJob = &SysJob{
|
||||||
// SelectJobPage 分页查询调度任务集合
|
sysJobRepository: repository.NewSysJobImpl,
|
||||||
SelectJobPage(query map[string]any) map[string]any
|
}
|
||||||
|
|
||||||
// SelectJobList 查询调度任务集合
|
// SysJob 调度任务 服务层处理
|
||||||
SelectJobList(sysJob model.SysJob) []model.SysJob
|
type SysJob struct {
|
||||||
|
// 调度任务数据信息
|
||||||
// SelectJobById 通过调度ID查询调度任务信息
|
sysJobRepository repository.ISysJob
|
||||||
SelectJobById(jobId string) model.SysJob
|
}
|
||||||
|
|
||||||
// CheckUniqueJobName 校验调度任务名称和组是否唯一
|
// SelectJobPage 分页查询调度任务集合
|
||||||
CheckUniqueJobName(jobName, jobGroup, jobId string) bool
|
func (r *SysJob) SelectJobPage(query map[string]any) map[string]any {
|
||||||
|
return r.sysJobRepository.SelectJobPage(query)
|
||||||
// InsertJob 新增调度任务信息
|
}
|
||||||
InsertJob(sysJob model.SysJob) string
|
|
||||||
|
// SelectJobList 查询调度任务集合
|
||||||
// UpdateJob 修改调度任务信息
|
func (r *SysJob) SelectJobList(sysJob model.SysJob) []model.SysJob {
|
||||||
UpdateJob(sysJob model.SysJob) int64
|
return r.sysJobRepository.SelectJobList(sysJob)
|
||||||
|
}
|
||||||
// DeleteJobByIds 批量删除调度任务信息
|
|
||||||
DeleteJobByIds(jobIds []string) (int64, error)
|
// SelectJobById 通过调度ID查询调度任务信息
|
||||||
|
func (r *SysJob) SelectJobById(jobId string) model.SysJob {
|
||||||
// RunQueueJob 立即运行一次调度任务
|
if jobId == "" {
|
||||||
RunQueueJob(sysJob model.SysJob) bool
|
return model.SysJob{}
|
||||||
|
}
|
||||||
// ResetQueueJob 重置初始调度任务
|
jobs := r.sysJobRepository.SelectJobByIds([]string{jobId})
|
||||||
ResetQueueJob()
|
if len(jobs) > 0 {
|
||||||
|
return jobs[0]
|
||||||
|
}
|
||||||
|
return model.SysJob{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckUniqueJobName 校验调度任务名称和组是否唯一
|
||||||
|
func (r *SysJob) CheckUniqueJobName(jobName, jobGroup, jobId string) bool {
|
||||||
|
uniqueId := r.sysJobRepository.CheckUniqueJob(model.SysJob{
|
||||||
|
JobName: jobName,
|
||||||
|
JobGroup: jobGroup,
|
||||||
|
})
|
||||||
|
if uniqueId == jobId {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return uniqueId == ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// InsertJob 新增调度任务信息
|
||||||
|
func (r *SysJob) InsertJob(sysJob model.SysJob) string {
|
||||||
|
insertId := r.sysJobRepository.InsertJob(sysJob)
|
||||||
|
if insertId == "" && sysJob.Status == common.STATUS_YES {
|
||||||
|
sysJob.JobID = insertId
|
||||||
|
r.insertQueueJob(sysJob, true)
|
||||||
|
}
|
||||||
|
return insertId
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateJob 修改调度任务信息
|
||||||
|
func (r *SysJob) UpdateJob(sysJob model.SysJob) int64 {
|
||||||
|
rows := r.sysJobRepository.UpdateJob(sysJob)
|
||||||
|
if rows > 0 {
|
||||||
|
//状态正常添加队列任务
|
||||||
|
if sysJob.Status == common.STATUS_YES {
|
||||||
|
r.insertQueueJob(sysJob, true)
|
||||||
|
}
|
||||||
|
// 状态禁用删除队列任务
|
||||||
|
if sysJob.Status == common.STATUS_NO {
|
||||||
|
r.deleteQueueJob(sysJob)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rows
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteJobByIds 批量删除调度任务信息
|
||||||
|
func (r *SysJob) DeleteJobByIds(jobIds []string) (int64, error) {
|
||||||
|
// 检查是否存在
|
||||||
|
jobs := r.sysJobRepository.SelectJobByIds(jobIds)
|
||||||
|
if len(jobs) <= 0 {
|
||||||
|
// 没有可访问调度任务数据!
|
||||||
|
return 0, fmt.Errorf("there is no accessible scheduling task data")
|
||||||
|
}
|
||||||
|
if len(jobs) == len(jobIds) {
|
||||||
|
// 清除任务
|
||||||
|
for _, job := range jobs {
|
||||||
|
r.deleteQueueJob(job)
|
||||||
|
}
|
||||||
|
rows := r.sysJobRepository.DeleteJobByIds(jobIds)
|
||||||
|
return rows, nil
|
||||||
|
}
|
||||||
|
// 删除调度任务信息失败!
|
||||||
|
return 0, fmt.Errorf("failed to delete scheduling task information")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetQueueJob 重置初始调度任务
|
||||||
|
func (r *SysJob) ResetQueueJob() {
|
||||||
|
// 获取注册的队列名称
|
||||||
|
queueNames := cron.QueueNames()
|
||||||
|
if len(queueNames) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 查询系统中定义状态为正常启用的任务
|
||||||
|
sysJobs := r.sysJobRepository.SelectJobList(model.SysJob{
|
||||||
|
Status: common.STATUS_YES,
|
||||||
|
})
|
||||||
|
for _, sysJob := range sysJobs {
|
||||||
|
for _, name := range queueNames {
|
||||||
|
if name == sysJob.InvokeTarget {
|
||||||
|
r.insertQueueJob(sysJob, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RunQueueJob 立即运行一次调度任务
|
||||||
|
func (r *SysJob) RunQueueJob(sysJob model.SysJob) bool {
|
||||||
|
return r.insertQueueJob(sysJob, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// insertQueueJob 添加调度任务
|
||||||
|
func (r *SysJob) insertQueueJob(sysJob model.SysJob, repeat bool) bool {
|
||||||
|
// 获取队列 Processor
|
||||||
|
queue := cron.GetQueue(sysJob.InvokeTarget)
|
||||||
|
if queue.Name != sysJob.InvokeTarget {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 给执行任务数据参数
|
||||||
|
options := cron.JobData{
|
||||||
|
Repeat: repeat,
|
||||||
|
SysJob: sysJob,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不是重复任务的情况,立即执行一次
|
||||||
|
if !repeat {
|
||||||
|
// 执行单次任务
|
||||||
|
status := queue.RunJob(options, cron.JobOptions{
|
||||||
|
JobId: sysJob.JobID,
|
||||||
|
})
|
||||||
|
// 执行中或等待中的都返回正常
|
||||||
|
return status == cron.Active || status == cron.Waiting
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行重复任务
|
||||||
|
queue.RunJob(options, cron.JobOptions{
|
||||||
|
JobId: sysJob.JobID,
|
||||||
|
Cron: sysJob.CronExpression,
|
||||||
|
})
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// deleteQueueJob 删除调度任务
|
||||||
|
func (r *SysJob) deleteQueueJob(sysJob model.SysJob) bool {
|
||||||
|
// 获取队列 Processor
|
||||||
|
queue := cron.GetQueue(sysJob.InvokeTarget)
|
||||||
|
if queue.Name != sysJob.InvokeTarget {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return queue.RemoveJob(sysJob.JobID)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,169 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"be.ems/src/framework/constants/common"
|
|
||||||
"be.ems/src/framework/cron"
|
|
||||||
"be.ems/src/modules/monitor/model"
|
|
||||||
"be.ems/src/modules/monitor/repository"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 实例化服务层 SysJobImpl 结构体
|
|
||||||
var NewSysJobImpl = &SysJobImpl{
|
|
||||||
sysJobRepository: repository.NewSysJobImpl,
|
|
||||||
}
|
|
||||||
|
|
||||||
// SysJobImpl 调度任务 服务层处理
|
|
||||||
type SysJobImpl struct {
|
|
||||||
// 调度任务数据信息
|
|
||||||
sysJobRepository repository.ISysJob
|
|
||||||
}
|
|
||||||
|
|
||||||
// SelectJobPage 分页查询调度任务集合
|
|
||||||
func (r *SysJobImpl) SelectJobPage(query map[string]any) map[string]any {
|
|
||||||
return r.sysJobRepository.SelectJobPage(query)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SelectJobList 查询调度任务集合
|
|
||||||
func (r *SysJobImpl) SelectJobList(sysJob model.SysJob) []model.SysJob {
|
|
||||||
return r.sysJobRepository.SelectJobList(sysJob)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SelectJobById 通过调度ID查询调度任务信息
|
|
||||||
func (r *SysJobImpl) SelectJobById(jobId string) model.SysJob {
|
|
||||||
if jobId == "" {
|
|
||||||
return model.SysJob{}
|
|
||||||
}
|
|
||||||
jobs := r.sysJobRepository.SelectJobByIds([]string{jobId})
|
|
||||||
if len(jobs) > 0 {
|
|
||||||
return jobs[0]
|
|
||||||
}
|
|
||||||
return model.SysJob{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckUniqueJobName 校验调度任务名称和组是否唯一
|
|
||||||
func (r *SysJobImpl) CheckUniqueJobName(jobName, jobGroup, jobId string) bool {
|
|
||||||
uniqueId := r.sysJobRepository.CheckUniqueJob(model.SysJob{
|
|
||||||
JobName: jobName,
|
|
||||||
JobGroup: jobGroup,
|
|
||||||
})
|
|
||||||
if uniqueId == jobId {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return uniqueId == ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// InsertJob 新增调度任务信息
|
|
||||||
func (r *SysJobImpl) InsertJob(sysJob model.SysJob) string {
|
|
||||||
insertId := r.sysJobRepository.InsertJob(sysJob)
|
|
||||||
if insertId == "" && sysJob.Status == common.STATUS_YES {
|
|
||||||
sysJob.JobID = insertId
|
|
||||||
r.insertQueueJob(sysJob, true)
|
|
||||||
}
|
|
||||||
return insertId
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateJob 修改调度任务信息
|
|
||||||
func (r *SysJobImpl) UpdateJob(sysJob model.SysJob) int64 {
|
|
||||||
rows := r.sysJobRepository.UpdateJob(sysJob)
|
|
||||||
if rows > 0 {
|
|
||||||
//状态正常添加队列任务
|
|
||||||
if sysJob.Status == common.STATUS_YES {
|
|
||||||
r.insertQueueJob(sysJob, true)
|
|
||||||
}
|
|
||||||
// 状态禁用删除队列任务
|
|
||||||
if sysJob.Status == common.STATUS_NO {
|
|
||||||
r.deleteQueueJob(sysJob)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rows
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteJobByIds 批量删除调度任务信息
|
|
||||||
func (r *SysJobImpl) DeleteJobByIds(jobIds []string) (int64, error) {
|
|
||||||
// 检查是否存在
|
|
||||||
jobs := r.sysJobRepository.SelectJobByIds(jobIds)
|
|
||||||
if len(jobs) <= 0 {
|
|
||||||
// 没有可访问调度任务数据!
|
|
||||||
return 0, fmt.Errorf("there is no accessible scheduling task data")
|
|
||||||
}
|
|
||||||
if len(jobs) == len(jobIds) {
|
|
||||||
// 清除任务
|
|
||||||
for _, job := range jobs {
|
|
||||||
r.deleteQueueJob(job)
|
|
||||||
}
|
|
||||||
rows := r.sysJobRepository.DeleteJobByIds(jobIds)
|
|
||||||
return rows, nil
|
|
||||||
}
|
|
||||||
// 删除调度任务信息失败!
|
|
||||||
return 0, fmt.Errorf("failed to delete scheduling task information")
|
|
||||||
}
|
|
||||||
|
|
||||||
// ResetQueueJob 重置初始调度任务
|
|
||||||
func (r *SysJobImpl) ResetQueueJob() {
|
|
||||||
// 获取注册的队列名称
|
|
||||||
queueNames := cron.QueueNames()
|
|
||||||
if len(queueNames) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 查询系统中定义状态为正常启用的任务
|
|
||||||
sysJobs := r.sysJobRepository.SelectJobList(model.SysJob{
|
|
||||||
Status: common.STATUS_YES,
|
|
||||||
})
|
|
||||||
for _, sysJob := range sysJobs {
|
|
||||||
for _, name := range queueNames {
|
|
||||||
if name == sysJob.InvokeTarget {
|
|
||||||
r.insertQueueJob(sysJob, true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RunQueueJob 立即运行一次调度任务
|
|
||||||
func (r *SysJobImpl) RunQueueJob(sysJob model.SysJob) bool {
|
|
||||||
return r.insertQueueJob(sysJob, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
// insertQueueJob 添加调度任务
|
|
||||||
func (r *SysJobImpl) insertQueueJob(sysJob model.SysJob, repeat bool) bool {
|
|
||||||
// 获取队列 Processor
|
|
||||||
queue := cron.GetQueue(sysJob.InvokeTarget)
|
|
||||||
if queue.Name != sysJob.InvokeTarget {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// 给执行任务数据参数
|
|
||||||
options := cron.JobData{
|
|
||||||
Repeat: repeat,
|
|
||||||
SysJob: sysJob,
|
|
||||||
}
|
|
||||||
|
|
||||||
// 不是重复任务的情况,立即执行一次
|
|
||||||
if !repeat {
|
|
||||||
// 执行单次任务
|
|
||||||
status := queue.RunJob(options, cron.JobOptions{
|
|
||||||
JobId: sysJob.JobID,
|
|
||||||
})
|
|
||||||
// 执行中或等待中的都返回正常
|
|
||||||
return status == cron.Active || status == cron.Waiting
|
|
||||||
}
|
|
||||||
|
|
||||||
// 执行重复任务
|
|
||||||
queue.RunJob(options, cron.JobOptions{
|
|
||||||
JobId: sysJob.JobID,
|
|
||||||
Cron: sysJob.CronExpression,
|
|
||||||
})
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// deleteQueueJob 删除调度任务
|
|
||||||
func (r *SysJobImpl) deleteQueueJob(sysJob model.SysJob) bool {
|
|
||||||
// 获取队列 Processor
|
|
||||||
queue := cron.GetQueue(sysJob.InvokeTarget)
|
|
||||||
if queue.Name != sysJob.InvokeTarget {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return queue.RemoveJob(sysJob.JobID)
|
|
||||||
}
|
|
||||||
@@ -2,22 +2,41 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"be.ems/src/modules/monitor/model"
|
"be.ems/src/modules/monitor/model"
|
||||||
|
"be.ems/src/modules/monitor/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ISysJobLog 调度任务日志 服务层接口
|
// 实例化服务层 SysJobLog 结构体
|
||||||
type ISysJobLog interface {
|
var NewSysJobLog = &SysJobLog{
|
||||||
// SelectJobLogPage 分页查询调度任务日志集合
|
sysJobLogRepository: repository.NewSysJobLogImpl,
|
||||||
SelectJobLogPage(query map[string]any) map[string]any
|
}
|
||||||
|
|
||||||
// SelectJobLogList 查询调度任务日志集合
|
// SysJobLog 调度任务日志 服务层处理
|
||||||
SelectJobLogList(sysJobLog model.SysJobLog) []model.SysJobLog
|
type SysJobLog struct {
|
||||||
|
// 调度任务日志数据信息
|
||||||
// SelectJobLogById 通过调度ID查询调度任务日志信息
|
sysJobLogRepository repository.ISysJobLog
|
||||||
SelectJobLogById(jobLogId string) model.SysJobLog
|
}
|
||||||
|
|
||||||
// DeleteJobLogByIds 批量删除调度任务日志信息
|
// SelectJobLogPage 分页查询调度任务日志集合
|
||||||
DeleteJobLogByIds(jobLogIds []string) int64
|
func (s *SysJobLog) SelectJobLogPage(query map[string]any) map[string]any {
|
||||||
|
return s.sysJobLogRepository.SelectJobLogPage(query)
|
||||||
// CleanJobLog 清空调度任务日志
|
}
|
||||||
CleanJobLog() error
|
|
||||||
|
// SelectJobLogList 查询调度任务日志集合
|
||||||
|
func (s *SysJobLog) SelectJobLogList(sysJobLog model.SysJobLog) []model.SysJobLog {
|
||||||
|
return s.sysJobLogRepository.SelectJobLogList(sysJobLog)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SelectJobLogById 通过调度ID查询调度任务日志信息
|
||||||
|
func (s *SysJobLog) SelectJobLogById(jobLogId string) model.SysJobLog {
|
||||||
|
return s.sysJobLogRepository.SelectJobLogById(jobLogId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteJobLogByIds 批量删除调度任务日志信息
|
||||||
|
func (s *SysJobLog) DeleteJobLogByIds(jobLogIds []string) int64 {
|
||||||
|
return s.sysJobLogRepository.DeleteJobLogByIds(jobLogIds)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CleanJobLog 清空调度任务日志
|
||||||
|
func (s *SysJobLog) CleanJobLog() error {
|
||||||
|
return s.sysJobLogRepository.CleanJobLog()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"be.ems/src/modules/monitor/model"
|
|
||||||
"be.ems/src/modules/monitor/repository"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 实例化服务层 SysJobLogImpl 结构体
|
|
||||||
var NewSysJobLogImpl = &SysJobLogImpl{
|
|
||||||
sysJobLogRepository: repository.NewSysJobLogImpl,
|
|
||||||
}
|
|
||||||
|
|
||||||
// SysJobLogImpl 调度任务日志 服务层处理
|
|
||||||
type SysJobLogImpl struct {
|
|
||||||
// 调度任务日志数据信息
|
|
||||||
sysJobLogRepository repository.ISysJobLog
|
|
||||||
}
|
|
||||||
|
|
||||||
// SelectJobLogPage 分页查询调度任务日志集合
|
|
||||||
func (s *SysJobLogImpl) SelectJobLogPage(query map[string]any) map[string]any {
|
|
||||||
return s.sysJobLogRepository.SelectJobLogPage(query)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SelectJobLogList 查询调度任务日志集合
|
|
||||||
func (s *SysJobLogImpl) SelectJobLogList(sysJobLog model.SysJobLog) []model.SysJobLog {
|
|
||||||
return s.sysJobLogRepository.SelectJobLogList(sysJobLog)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SelectJobLogById 通过调度ID查询调度任务日志信息
|
|
||||||
func (s *SysJobLogImpl) SelectJobLogById(jobLogId string) model.SysJobLog {
|
|
||||||
return s.sysJobLogRepository.SelectJobLogById(jobLogId)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteJobLogByIds 批量删除调度任务日志信息
|
|
||||||
func (s *SysJobLogImpl) DeleteJobLogByIds(jobLogIds []string) int64 {
|
|
||||||
return s.sysJobLogRepository.DeleteJobLogByIds(jobLogIds)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CleanJobLog 清空调度任务日志
|
|
||||||
func (s *SysJobLogImpl) CleanJobLog() error {
|
|
||||||
return s.sysJobLogRepository.CleanJobLog()
|
|
||||||
}
|
|
||||||
@@ -5,8 +5,29 @@ import (
|
|||||||
"be.ems/src/modules/monitor/model"
|
"be.ems/src/modules/monitor/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ISysUserOnline 在线用户 服务层接口
|
// 实例化服务层 SysUserOnline 结构体
|
||||||
type ISysUserOnline interface {
|
var NewSysUserOnline = &SysUserOnline{}
|
||||||
// LoginUserToUserOnline 设置在线用户信息
|
|
||||||
LoginUserToUserOnline(loginUser vo.LoginUser) model.SysUserOnline
|
// SysUserOnline 在线用户 服务层处理
|
||||||
|
type SysUserOnline struct{}
|
||||||
|
|
||||||
|
// LoginUserToUserOnline 设置在线用户信息
|
||||||
|
func (r *SysUserOnline) LoginUserToUserOnline(loginUser vo.LoginUser) model.SysUserOnline {
|
||||||
|
if loginUser.UserID == "" {
|
||||||
|
return model.SysUserOnline{}
|
||||||
|
}
|
||||||
|
|
||||||
|
sysUserOnline := model.SysUserOnline{
|
||||||
|
TokenID: loginUser.UUID,
|
||||||
|
UserName: loginUser.User.UserName,
|
||||||
|
IPAddr: loginUser.IPAddr,
|
||||||
|
LoginLocation: loginUser.LoginLocation,
|
||||||
|
Browser: loginUser.Browser,
|
||||||
|
OS: loginUser.OS,
|
||||||
|
LoginTime: loginUser.LoginTime,
|
||||||
|
}
|
||||||
|
if loginUser.User.DeptID != "" {
|
||||||
|
sysUserOnline.DeptName = loginUser.User.Dept.DeptName
|
||||||
|
}
|
||||||
|
return sysUserOnline
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"be.ems/src/framework/vo"
|
|
||||||
"be.ems/src/modules/monitor/model"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 实例化服务层 SysUserOnlineImpl 结构体
|
|
||||||
var NewSysUserOnlineImpl = &SysUserOnlineImpl{}
|
|
||||||
|
|
||||||
// SysUserOnlineImpl 在线用户 服务层处理
|
|
||||||
type SysUserOnlineImpl struct{}
|
|
||||||
|
|
||||||
// LoginUserToUserOnline 设置在线用户信息
|
|
||||||
func (r *SysUserOnlineImpl) LoginUserToUserOnline(loginUser vo.LoginUser) model.SysUserOnline {
|
|
||||||
if loginUser.UserID == "" {
|
|
||||||
return model.SysUserOnline{}
|
|
||||||
}
|
|
||||||
|
|
||||||
sysUserOnline := model.SysUserOnline{
|
|
||||||
TokenID: loginUser.UUID,
|
|
||||||
UserName: loginUser.User.UserName,
|
|
||||||
IPAddr: loginUser.IPAddr,
|
|
||||||
LoginLocation: loginUser.LoginLocation,
|
|
||||||
Browser: loginUser.Browser,
|
|
||||||
OS: loginUser.OS,
|
|
||||||
LoginTime: loginUser.LoginTime,
|
|
||||||
}
|
|
||||||
if loginUser.User.DeptID != "" {
|
|
||||||
sysUserOnline.DeptName = loginUser.User.Dept.DeptName
|
|
||||||
}
|
|
||||||
return sysUserOnline
|
|
||||||
}
|
|
||||||
@@ -1,22 +1,177 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
// ISystemInfo 服务器系统相关信息 服务层接口
|
import (
|
||||||
type ISystemInfo interface {
|
"context"
|
||||||
// SystemInfo 系统信息
|
"fmt"
|
||||||
SystemInfo() map[string]any
|
"os"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
// TimeInfo 系统时间信息
|
"be.ems/src/framework/config"
|
||||||
TimeInfo() map[string]string
|
"be.ems/src/framework/utils/parse"
|
||||||
|
|
||||||
// MemoryInfo 内存信息
|
"github.com/shirou/gopsutil/v4/cpu"
|
||||||
MemoryInfo() map[string]any
|
"github.com/shirou/gopsutil/v4/disk"
|
||||||
|
"github.com/shirou/gopsutil/v4/host"
|
||||||
|
"github.com/shirou/gopsutil/v4/mem"
|
||||||
|
"github.com/shirou/gopsutil/v4/net"
|
||||||
|
)
|
||||||
|
|
||||||
// CPUInfo CPU信息
|
// 实例化服务层 SystemInfo 结构体
|
||||||
CPUInfo() map[string]any
|
var NewSystemInfo = &SystemInfo{}
|
||||||
|
|
||||||
// NetworkInfo 网络信息
|
// SystemInfo 服务器系统相关信息 服务层处理
|
||||||
NetworkInfo() map[string]string
|
type SystemInfo struct{}
|
||||||
|
|
||||||
// DiskInfo 磁盘信息
|
// SystemInfo 系统信息
|
||||||
DiskInfo() []map[string]string
|
func (s *SystemInfo) SystemInfo() map[string]any {
|
||||||
|
info, err := host.Info()
|
||||||
|
if err != nil {
|
||||||
|
info.Platform = err.Error()
|
||||||
|
}
|
||||||
|
// 获取主机运行时间
|
||||||
|
bootTime := time.Since(time.Unix(int64(info.BootTime), 0)).Seconds()
|
||||||
|
// 获取程序运行时间
|
||||||
|
runTime := time.Since(config.RunTime()).Abs().Seconds()
|
||||||
|
return map[string]any{
|
||||||
|
"platform": info.Platform,
|
||||||
|
"platformVersion": info.PlatformVersion,
|
||||||
|
"arch": info.KernelArch,
|
||||||
|
"archVersion": info.KernelVersion,
|
||||||
|
"os": info.OS,
|
||||||
|
"hostname": info.Hostname,
|
||||||
|
"bootTime": int64(bootTime),
|
||||||
|
"processId": os.Getpid(),
|
||||||
|
"runArch": runtime.GOARCH,
|
||||||
|
"runVersion": runtime.Version(),
|
||||||
|
"runTime": int64(runTime),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TimeInfo 系统时间信息
|
||||||
|
func (s *SystemInfo) TimeInfo() map[string]string {
|
||||||
|
now := time.Now()
|
||||||
|
// 获取当前时间
|
||||||
|
current := now.Format("2006-01-02 15:04:05")
|
||||||
|
// 获取时区
|
||||||
|
timezone := now.Format("-0700 MST")
|
||||||
|
// 获取时区名称
|
||||||
|
timezoneName := now.Format("MST")
|
||||||
|
|
||||||
|
return map[string]string{
|
||||||
|
"current": current,
|
||||||
|
"timezone": timezone,
|
||||||
|
"timezoneName": timezoneName,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MemoryInfo 内存信息
|
||||||
|
func (s *SystemInfo) MemoryInfo() map[string]any {
|
||||||
|
memInfo, err := mem.VirtualMemory()
|
||||||
|
if err != nil {
|
||||||
|
memInfo.UsedPercent = 0
|
||||||
|
memInfo.Available = 0
|
||||||
|
memInfo.Total = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
var memStats runtime.MemStats
|
||||||
|
runtime.ReadMemStats(&memStats)
|
||||||
|
|
||||||
|
return map[string]any{
|
||||||
|
"usage": fmt.Sprintf("%.2f", memInfo.UsedPercent), // 内存利用率
|
||||||
|
"freemem": parse.Bit(float64(memInfo.Available)), // 可用内存大小(GB)
|
||||||
|
"totalmem": parse.Bit(float64(memInfo.Total)), // 总内存大小(GB)
|
||||||
|
"rss": parse.Bit(float64(memStats.Sys)), // 常驻内存大小(RSS)
|
||||||
|
"heapTotal": parse.Bit(float64(memStats.HeapSys)), // 堆总大小
|
||||||
|
"heapUsed": parse.Bit(float64(memStats.HeapAlloc)), // 堆已使用大小
|
||||||
|
"external": parse.Bit(float64(memStats.Sys - memStats.HeapSys)), // 外部内存大小(非堆)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CPUInfo CPU信息
|
||||||
|
func (s *SystemInfo) CPUInfo() map[string]any {
|
||||||
|
var core int = 0
|
||||||
|
var speed string = "未知"
|
||||||
|
var model string = "未知"
|
||||||
|
cpuInfo, err := cpu.Info()
|
||||||
|
if err == nil {
|
||||||
|
core = runtime.NumCPU()
|
||||||
|
speed = fmt.Sprintf("%.0fMHz", cpuInfo[0].Mhz)
|
||||||
|
model = strings.TrimSpace(cpuInfo[0].ModelName)
|
||||||
|
}
|
||||||
|
|
||||||
|
useds := []string{}
|
||||||
|
cpuPercent, err := cpu.Percent(0, true)
|
||||||
|
if err == nil {
|
||||||
|
for _, v := range cpuPercent {
|
||||||
|
useds = append(useds, fmt.Sprintf("%.2f", v))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return map[string]any{
|
||||||
|
"model": model,
|
||||||
|
"speed": speed,
|
||||||
|
"core": core,
|
||||||
|
"coreUsed": useds,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NetworkInfo 网络信息
|
||||||
|
func (s *SystemInfo) NetworkInfo() map[string]string {
|
||||||
|
ipAddrs := make(map[string]string)
|
||||||
|
interfaces, err := net.Interfaces()
|
||||||
|
if err == nil {
|
||||||
|
for _, iface := range interfaces {
|
||||||
|
name := iface.Name
|
||||||
|
if name[len(name)-1] == '0' {
|
||||||
|
name = name[0 : len(name)-1]
|
||||||
|
name = strings.Trim(name, "")
|
||||||
|
}
|
||||||
|
// ignore localhost
|
||||||
|
if name == "lo" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var addrs []string
|
||||||
|
for _, v := range iface.Addrs {
|
||||||
|
prefix := strings.Split(v.Addr, "/")[0]
|
||||||
|
if strings.Contains(prefix, "::") {
|
||||||
|
addrs = append(addrs, fmt.Sprintf("IPv6 %s", prefix))
|
||||||
|
}
|
||||||
|
if strings.Contains(prefix, ".") {
|
||||||
|
addrs = append(addrs, fmt.Sprintf("IPv4 %s", prefix))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ipAddrs[name] = strings.Join(addrs, " / ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ipAddrs
|
||||||
|
}
|
||||||
|
|
||||||
|
// DiskInfo 磁盘信息
|
||||||
|
func (s *SystemInfo) DiskInfo() []map[string]string {
|
||||||
|
disks := make([]map[string]string, 0)
|
||||||
|
ctx := context.Background()
|
||||||
|
ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
partitions, err := disk.PartitionsWithContext(ctx, false)
|
||||||
|
if err != nil && err != context.DeadlineExceeded {
|
||||||
|
return disks
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, partition := range partitions {
|
||||||
|
usage, err := disk.Usage(partition.Mountpoint)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
disks = append(disks, map[string]string{
|
||||||
|
"size": parse.Bit(float64(usage.Total)),
|
||||||
|
"used": parse.Bit(float64(usage.Used)),
|
||||||
|
"avail": parse.Bit(float64(usage.Free)),
|
||||||
|
"pcent": fmt.Sprintf("%.1f%%", usage.UsedPercent),
|
||||||
|
"target": partition.Device,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return disks
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,177 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"runtime"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"be.ems/src/framework/config"
|
|
||||||
"be.ems/src/framework/utils/parse"
|
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v4/cpu"
|
|
||||||
"github.com/shirou/gopsutil/v4/disk"
|
|
||||||
"github.com/shirou/gopsutil/v4/host"
|
|
||||||
"github.com/shirou/gopsutil/v4/mem"
|
|
||||||
"github.com/shirou/gopsutil/v4/net"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 实例化服务层 SystemInfoImpl 结构体
|
|
||||||
var NewSystemInfoImpl = &SystemInfoImpl{}
|
|
||||||
|
|
||||||
// SystemInfoImpl 服务器系统相关信息 服务层处理
|
|
||||||
type SystemInfoImpl struct{}
|
|
||||||
|
|
||||||
// SystemInfo 系统信息
|
|
||||||
func (s *SystemInfoImpl) SystemInfo() map[string]any {
|
|
||||||
info, err := host.Info()
|
|
||||||
if err != nil {
|
|
||||||
info.Platform = err.Error()
|
|
||||||
}
|
|
||||||
// 获取主机运行时间
|
|
||||||
bootTime := time.Since(time.Unix(int64(info.BootTime), 0)).Seconds()
|
|
||||||
// 获取程序运行时间
|
|
||||||
runTime := time.Since(config.RunTime()).Abs().Seconds()
|
|
||||||
return map[string]any{
|
|
||||||
"platform": info.Platform,
|
|
||||||
"platformVersion": info.PlatformVersion,
|
|
||||||
"arch": info.KernelArch,
|
|
||||||
"archVersion": info.KernelVersion,
|
|
||||||
"os": info.OS,
|
|
||||||
"hostname": info.Hostname,
|
|
||||||
"bootTime": int64(bootTime),
|
|
||||||
"processId": os.Getpid(),
|
|
||||||
"runArch": runtime.GOARCH,
|
|
||||||
"runVersion": runtime.Version(),
|
|
||||||
"runTime": int64(runTime),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TimeInfo 系统时间信息
|
|
||||||
func (s *SystemInfoImpl) TimeInfo() map[string]string {
|
|
||||||
now := time.Now()
|
|
||||||
// 获取当前时间
|
|
||||||
current := now.Format("2006-01-02 15:04:05")
|
|
||||||
// 获取时区
|
|
||||||
timezone := now.Format("-0700 MST")
|
|
||||||
// 获取时区名称
|
|
||||||
timezoneName := now.Format("MST")
|
|
||||||
|
|
||||||
return map[string]string{
|
|
||||||
"current": current,
|
|
||||||
"timezone": timezone,
|
|
||||||
"timezoneName": timezoneName,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MemoryInfo 内存信息
|
|
||||||
func (s *SystemInfoImpl) MemoryInfo() map[string]any {
|
|
||||||
memInfo, err := mem.VirtualMemory()
|
|
||||||
if err != nil {
|
|
||||||
memInfo.UsedPercent = 0
|
|
||||||
memInfo.Available = 0
|
|
||||||
memInfo.Total = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
var memStats runtime.MemStats
|
|
||||||
runtime.ReadMemStats(&memStats)
|
|
||||||
|
|
||||||
return map[string]any{
|
|
||||||
"usage": fmt.Sprintf("%.2f", memInfo.UsedPercent), // 内存利用率
|
|
||||||
"freemem": parse.Bit(float64(memInfo.Available)), // 可用内存大小(GB)
|
|
||||||
"totalmem": parse.Bit(float64(memInfo.Total)), // 总内存大小(GB)
|
|
||||||
"rss": parse.Bit(float64(memStats.Sys)), // 常驻内存大小(RSS)
|
|
||||||
"heapTotal": parse.Bit(float64(memStats.HeapSys)), // 堆总大小
|
|
||||||
"heapUsed": parse.Bit(float64(memStats.HeapAlloc)), // 堆已使用大小
|
|
||||||
"external": parse.Bit(float64(memStats.Sys - memStats.HeapSys)), // 外部内存大小(非堆)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CPUInfo CPU信息
|
|
||||||
func (s *SystemInfoImpl) CPUInfo() map[string]any {
|
|
||||||
var core int = 0
|
|
||||||
var speed string = "未知"
|
|
||||||
var model string = "未知"
|
|
||||||
cpuInfo, err := cpu.Info()
|
|
||||||
if err == nil {
|
|
||||||
core = runtime.NumCPU()
|
|
||||||
speed = fmt.Sprintf("%.0fMHz", cpuInfo[0].Mhz)
|
|
||||||
model = strings.TrimSpace(cpuInfo[0].ModelName)
|
|
||||||
}
|
|
||||||
|
|
||||||
useds := []string{}
|
|
||||||
cpuPercent, err := cpu.Percent(0, true)
|
|
||||||
if err == nil {
|
|
||||||
for _, v := range cpuPercent {
|
|
||||||
useds = append(useds, fmt.Sprintf("%.2f", v))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return map[string]any{
|
|
||||||
"model": model,
|
|
||||||
"speed": speed,
|
|
||||||
"core": core,
|
|
||||||
"coreUsed": useds,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NetworkInfo 网络信息
|
|
||||||
func (s *SystemInfoImpl) NetworkInfo() map[string]string {
|
|
||||||
ipAddrs := make(map[string]string)
|
|
||||||
interfaces, err := net.Interfaces()
|
|
||||||
if err == nil {
|
|
||||||
for _, iface := range interfaces {
|
|
||||||
name := iface.Name
|
|
||||||
if name[len(name)-1] == '0' {
|
|
||||||
name = name[0 : len(name)-1]
|
|
||||||
name = strings.Trim(name, "")
|
|
||||||
}
|
|
||||||
// ignore localhost
|
|
||||||
if name == "lo" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
var addrs []string
|
|
||||||
for _, v := range iface.Addrs {
|
|
||||||
prefix := strings.Split(v.Addr, "/")[0]
|
|
||||||
if strings.Contains(prefix, "::") {
|
|
||||||
addrs = append(addrs, fmt.Sprintf("IPv6 %s", prefix))
|
|
||||||
}
|
|
||||||
if strings.Contains(prefix, ".") {
|
|
||||||
addrs = append(addrs, fmt.Sprintf("IPv4 %s", prefix))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ipAddrs[name] = strings.Join(addrs, " / ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ipAddrs
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskInfo 磁盘信息
|
|
||||||
func (s *SystemInfoImpl) DiskInfo() []map[string]string {
|
|
||||||
disks := make([]map[string]string, 0)
|
|
||||||
ctx := context.Background()
|
|
||||||
ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
partitions, err := disk.PartitionsWithContext(ctx, false)
|
|
||||||
if err != nil && err != context.DeadlineExceeded {
|
|
||||||
return disks
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, partition := range partitions {
|
|
||||||
usage, err := disk.Usage(partition.Mountpoint)
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
disks = append(disks, map[string]string{
|
|
||||||
"size": parse.Bit(float64(usage.Total)),
|
|
||||||
"used": parse.Bit(float64(usage.Used)),
|
|
||||||
"avail": parse.Bit(float64(usage.Free)),
|
|
||||||
"pcent": fmt.Sprintf("%.1f%%", usage.UsedPercent),
|
|
||||||
"target": partition.Device,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return disks
|
|
||||||
}
|
|
||||||
@@ -119,11 +119,11 @@ func (s *AMFController) UEExport(c *gin.Context) {
|
|||||||
"E1": "Time",
|
"E1": "Time",
|
||||||
}
|
}
|
||||||
// 读取字典数据 UE 事件类型
|
// 读取字典数据 UE 事件类型
|
||||||
dictUEEventType := sysService.NewSysDictDataImpl.SelectDictDataByType("ue_event_type")
|
dictUEEventType := sysService.NewSysDictData.SelectDictDataByType("ue_event_type")
|
||||||
// 读取字典数据 UE 事件认证代码类型
|
// 读取字典数据 UE 事件认证代码类型
|
||||||
dictUEAauthCode := sysService.NewSysDictDataImpl.SelectDictDataByType("ue_auth_code")
|
dictUEAauthCode := sysService.NewSysDictData.SelectDictDataByType("ue_auth_code")
|
||||||
// 读取字典数据 UE 事件CM状态
|
// 读取字典数据 UE 事件CM状态
|
||||||
dictUEEventCmState := sysService.NewSysDictDataImpl.SelectDictDataByType("ue_event_cm_state")
|
dictUEEventCmState := sysService.NewSysDictData.SelectDictDataByType("ue_event_cm_state")
|
||||||
// 从第二行开始的数据
|
// 从第二行开始的数据
|
||||||
dataCells := make([]map[string]any, 0)
|
dataCells := make([]map[string]any, 0)
|
||||||
for i, row := range rows {
|
for i, row := range rows {
|
||||||
@@ -178,7 +178,7 @@ func (s *AMFController) UEExport(c *gin.Context) {
|
|||||||
timeStr = v.(string)
|
timeStr = v.(string)
|
||||||
}
|
}
|
||||||
if v, ok := eventJSON["status"]; ok && v != nil {
|
if v, ok := eventJSON["status"]; ok && v != nil {
|
||||||
eventResult = v.(string)
|
eventResult = fmt.Sprint(v)
|
||||||
for _, v := range dictUEEventCmState {
|
for _, v := range dictUEEventCmState {
|
||||||
if eventResult == v.DictValue {
|
if eventResult == v.DictValue {
|
||||||
eventResult = i18n.TKey(language, v.DictLabel)
|
eventResult = i18n.TKey(language, v.DictLabel)
|
||||||
|
|||||||
@@ -130,9 +130,9 @@ func (s *IMSController) CDRExport(c *gin.Context) {
|
|||||||
"H1": "Time",
|
"H1": "Time",
|
||||||
}
|
}
|
||||||
// 读取字典数据 CDR SIP响应代码类别类型
|
// 读取字典数据 CDR SIP响应代码类别类型
|
||||||
dictCDRSipCode := sysService.NewSysDictDataImpl.SelectDictDataByType("cdr_sip_code")
|
dictCDRSipCode := sysService.NewSysDictData.SelectDictDataByType("cdr_sip_code")
|
||||||
// 读取字典数据 CDR 呼叫类型
|
// 读取字典数据 CDR 呼叫类型
|
||||||
dictCDRCallType := sysService.NewSysDictDataImpl.SelectDictDataByType("cdr_call_type")
|
dictCDRCallType := sysService.NewSysDictData.SelectDictDataByType("cdr_call_type")
|
||||||
// 从第二行开始的数据
|
// 从第二行开始的数据
|
||||||
dataCells := make([]map[string]any, 0)
|
dataCells := make([]map[string]any, 0)
|
||||||
for i, row := range rows {
|
for i, row := range rows {
|
||||||
|
|||||||
@@ -120,11 +120,11 @@ func (s *MMEController) UEExport(c *gin.Context) {
|
|||||||
"E1": "Time",
|
"E1": "Time",
|
||||||
}
|
}
|
||||||
// 读取字典数据 UE 事件类型
|
// 读取字典数据 UE 事件类型
|
||||||
dictUEEventType := sysService.NewSysDictDataImpl.SelectDictDataByType("ue_event_type")
|
dictUEEventType := sysService.NewSysDictData.SelectDictDataByType("ue_event_type")
|
||||||
// 读取字典数据 UE 事件认证代码类型
|
// 读取字典数据 UE 事件认证代码类型
|
||||||
dictUEAauthCode := sysService.NewSysDictDataImpl.SelectDictDataByType("ue_auth_code")
|
dictUEAauthCode := sysService.NewSysDictData.SelectDictDataByType("ue_auth_code")
|
||||||
// 读取字典数据 UE 事件CM状态
|
// 读取字典数据 UE 事件CM状态
|
||||||
dictUEEventCmState := sysService.NewSysDictDataImpl.SelectDictDataByType("ue_event_cm_state")
|
dictUEEventCmState := sysService.NewSysDictData.SelectDictDataByType("ue_event_cm_state")
|
||||||
// 从第二行开始的数据
|
// 从第二行开始的数据
|
||||||
dataCells := make([]map[string]any, 0)
|
dataCells := make([]map[string]any, 0)
|
||||||
for i, row := range rows {
|
for i, row := range rows {
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ func (s *UDMAuthController) ResetData(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
neId = ""
|
|
||||||
data := s.udmAuthService.ResetData(neId)
|
data := s.udmAuthService.ResetData(neId)
|
||||||
c.JSON(200, result.OkData(data))
|
c.JSON(200, result.OkData(data))
|
||||||
}
|
}
|
||||||
@@ -56,7 +55,6 @@ func (s *UDMAuthController) ResetData(c *gin.Context) {
|
|||||||
// GET /list
|
// GET /list
|
||||||
func (s *UDMAuthController) List(c *gin.Context) {
|
func (s *UDMAuthController) List(c *gin.Context) {
|
||||||
querys := ctx.QueryMap(c)
|
querys := ctx.QueryMap(c)
|
||||||
querys["neId"] = ""
|
|
||||||
data := s.udmAuthService.SelectPage(querys)
|
data := s.udmAuthService.SelectPage(querys)
|
||||||
c.JSON(200, result.Ok(data))
|
c.JSON(200, result.Ok(data))
|
||||||
}
|
}
|
||||||
@@ -100,7 +98,6 @@ func (s *UDMAuthController) Info(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
neId = ""
|
|
||||||
// 解析返回的数据
|
// 解析返回的数据
|
||||||
u := s.udmAuthService.ParseInfo(imsi, neId, data)
|
u := s.udmAuthService.ParseInfo(imsi, neId, data)
|
||||||
s.udmAuthService.Insert(neId, u)
|
s.udmAuthService.Insert(neId, u)
|
||||||
@@ -150,7 +147,6 @@ func (s *UDMAuthController) Add(c *gin.Context) {
|
|||||||
|
|
||||||
// 命令ok时
|
// 命令ok时
|
||||||
if strings.Contains(data, "ok") {
|
if strings.Contains(data, "ok") {
|
||||||
neId = ""
|
|
||||||
s.udmAuthService.Insert(neId, body)
|
s.udmAuthService.Insert(neId, body)
|
||||||
}
|
}
|
||||||
c.JSON(200, result.OkData(data))
|
c.JSON(200, result.OkData(data))
|
||||||
@@ -200,8 +196,7 @@ func (s *UDMAuthController) Adds(c *gin.Context) {
|
|||||||
|
|
||||||
// 命令ok时
|
// 命令ok时
|
||||||
if strings.Contains(data, "ok") {
|
if strings.Contains(data, "ok") {
|
||||||
neId = ""
|
s.udmAuthService.LoadData(neId, body.IMSI, num)
|
||||||
go s.udmAuthService.LoadData(neId, body.IMSI, num)
|
|
||||||
}
|
}
|
||||||
c.JSON(200, result.OkData(data))
|
c.JSON(200, result.OkData(data))
|
||||||
}
|
}
|
||||||
@@ -249,7 +244,6 @@ func (s *UDMAuthController) Edit(c *gin.Context) {
|
|||||||
|
|
||||||
// 命令ok时
|
// 命令ok时
|
||||||
if strings.Contains(data, "ok") {
|
if strings.Contains(data, "ok") {
|
||||||
neId = ""
|
|
||||||
s.udmAuthService.Insert(neId, body)
|
s.udmAuthService.Insert(neId, body)
|
||||||
}
|
}
|
||||||
c.JSON(200, result.OkData(data))
|
c.JSON(200, result.OkData(data))
|
||||||
@@ -300,7 +294,6 @@ func (s *UDMAuthController) Remove(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
// 命令ok时
|
// 命令ok时
|
||||||
if strings.Contains(data, "ok") {
|
if strings.Contains(data, "ok") {
|
||||||
neId = ""
|
|
||||||
s.udmAuthService.Delete(imsi, neId)
|
s.udmAuthService.Delete(imsi, neId)
|
||||||
}
|
}
|
||||||
resultData[imsi] = data
|
resultData[imsi] = data
|
||||||
@@ -346,8 +339,7 @@ func (s *UDMAuthController) Removes(c *gin.Context) {
|
|||||||
|
|
||||||
// 命令ok时
|
// 命令ok时
|
||||||
if strings.Contains(data, "ok") {
|
if strings.Contains(data, "ok") {
|
||||||
neId = ""
|
s.udmAuthService.LoadData(neId, imsi, num)
|
||||||
go s.udmAuthService.LoadData(neId, imsi, num)
|
|
||||||
}
|
}
|
||||||
c.JSON(200, result.OkData(data))
|
c.JSON(200, result.OkData(data))
|
||||||
}
|
}
|
||||||
@@ -357,32 +349,45 @@ func (s *UDMAuthController) Removes(c *gin.Context) {
|
|||||||
// POST /export
|
// POST /export
|
||||||
func (s *UDMAuthController) Export(c *gin.Context) {
|
func (s *UDMAuthController) Export(c *gin.Context) {
|
||||||
language := ctx.AcceptLanguage(c)
|
language := ctx.AcceptLanguage(c)
|
||||||
var body struct {
|
// 查询结果,根据查询条件结果,单页最大值限制
|
||||||
NeId string `json:"neId" binding:"required"`
|
querys := ctx.BodyJSONMap(c)
|
||||||
Type string `json:"type" binding:"required"`
|
neId := querys["neId"].(string)
|
||||||
}
|
fileType := querys["type"].(string)
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
if neId == "" || fileType == "" {
|
||||||
if err != nil {
|
|
||||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if !(fileType == "csv" || fileType == "txt") {
|
||||||
if !(body.Type == "csv" || body.Type == "txt") {
|
c.JSON(200, result.ErrMsg(i18n.TKey(language, "ne.udm.errImportUserSubFileFormat")))
|
||||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "ne.udm.errExportType")))
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
querys["pageNum"] = 1
|
||||||
|
querys["pageSize"] = 10000
|
||||||
|
data := s.udmAuthService.SelectPage(querys)
|
||||||
|
if parse.Number(data["total"]) == 0 {
|
||||||
|
// 导出数据记录为空
|
||||||
|
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rows := data["rows"].([]model.UDMAuthUser)
|
||||||
|
|
||||||
|
// rows := s.udmAuthService.SelectList(model.UDMAuthUser{NeId: neId})
|
||||||
|
if len(rows) <= 0 {
|
||||||
|
// 导出数据记录为空
|
||||||
|
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
neId := ""
|
|
||||||
list := s.udmAuthService.SelectList(model.UDMAuthUser{NeId: neId})
|
|
||||||
// 文件名
|
// 文件名
|
||||||
fileName := fmt.Sprintf("udm_auth_user_export_%s_%d.%s", neId, time.Now().UnixMilli(), body.Type)
|
fileName := fmt.Sprintf("udm_auth_user_export_%s_%d.%s", neId, time.Now().UnixMilli(), fileType)
|
||||||
filePath := fmt.Sprintf("%s/%s", file.ParseUploadFileDir(uploadsubpath.EXPORT), fileName)
|
filePath := fmt.Sprintf("%s/%s", file.ParseUploadFileDir(uploadsubpath.EXPORT), fileName)
|
||||||
|
|
||||||
if body.Type == "csv" {
|
if fileType == "csv" {
|
||||||
// 转换数据
|
// 转换数据
|
||||||
data := [][]string{}
|
data := [][]string{}
|
||||||
data = append(data, []string{"imsi", "ki", "algo", "amf", "opc"})
|
data = append(data, []string{"imsi", "ki", "algo", "amf", "opc"})
|
||||||
for _, v := range list {
|
for _, v := range rows {
|
||||||
opc := v.Opc
|
opc := v.Opc
|
||||||
if opc == "-" {
|
if opc == "-" {
|
||||||
opc = ""
|
opc = ""
|
||||||
@@ -397,10 +402,10 @@ func (s *UDMAuthController) Export(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if body.Type == "txt" {
|
if fileType == "txt" {
|
||||||
// 转换数据
|
// 转换数据
|
||||||
data := [][]string{}
|
data := [][]string{}
|
||||||
for _, v := range list {
|
for _, v := range rows {
|
||||||
opc := v.Opc
|
opc := v.Opc
|
||||||
if opc == "-" {
|
if opc == "-" {
|
||||||
opc = ""
|
opc = ""
|
||||||
@@ -408,8 +413,8 @@ func (s *UDMAuthController) Export(c *gin.Context) {
|
|||||||
data = append(data, []string{v.IMSI, v.Ki, v.AlgoIndex, v.Amf, opc})
|
data = append(data, []string{v.IMSI, v.Ki, v.AlgoIndex, v.Amf, opc})
|
||||||
}
|
}
|
||||||
// 输出到文件
|
// 输出到文件
|
||||||
err = file.WriterFileTXT(data, ",", filePath)
|
|
||||||
if err != nil {
|
if err := file.WriterFileTXT(data, ",", filePath); err != nil {
|
||||||
c.JSON(200, result.ErrMsg(err.Error()))
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -505,13 +510,11 @@ func (s *UDMAuthController) Import(c *gin.Context) {
|
|||||||
if strings.Contains(resultMsg, "ok") {
|
if strings.Contains(resultMsg, "ok") {
|
||||||
if strings.HasSuffix(body.UploadPath, ".csv") {
|
if strings.HasSuffix(body.UploadPath, ".csv") {
|
||||||
data := file.ReadFileCSV(localFilePath)
|
data := file.ReadFileCSV(localFilePath)
|
||||||
neId := ""
|
go s.udmAuthService.InsertData(neInfo.NeId, "csv", data)
|
||||||
go s.udmAuthService.InsertData(neId, "csv", data)
|
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(body.UploadPath, ".txt") {
|
if strings.HasSuffix(body.UploadPath, ".txt") {
|
||||||
data := file.ReadFileTXT(",", localFilePath)
|
data := file.ReadFileTXT(",", localFilePath)
|
||||||
neId := ""
|
go s.udmAuthService.InsertData(neInfo.NeId, "txt", data)
|
||||||
go s.udmAuthService.InsertData(neId, "txt", data)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.JSON(200, result.OkMsg(resultMsg))
|
c.JSON(200, result.OkMsg(resultMsg))
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ func (s *UDMSubController) ResetData(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
neId = ""
|
|
||||||
data := s.udmSubService.ResetData(neId)
|
data := s.udmSubService.ResetData(neId)
|
||||||
c.JSON(200, result.OkData(data))
|
c.JSON(200, result.OkData(data))
|
||||||
}
|
}
|
||||||
@@ -55,7 +54,6 @@ func (s *UDMSubController) ResetData(c *gin.Context) {
|
|||||||
// GET /list
|
// GET /list
|
||||||
func (s *UDMSubController) List(c *gin.Context) {
|
func (s *UDMSubController) List(c *gin.Context) {
|
||||||
querys := ctx.QueryMap(c)
|
querys := ctx.QueryMap(c)
|
||||||
querys["neId"] = ""
|
|
||||||
data := s.udmSubService.SelectPage(querys)
|
data := s.udmSubService.SelectPage(querys)
|
||||||
c.JSON(200, result.Ok(data))
|
c.JSON(200, result.Ok(data))
|
||||||
}
|
}
|
||||||
@@ -99,7 +97,6 @@ func (s *UDMSubController) Info(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
neId = ""
|
|
||||||
// 解析返回的数据
|
// 解析返回的数据
|
||||||
u := s.udmSubService.ParseInfo(imsi, neId, data)
|
u := s.udmSubService.ParseInfo(imsi, neId, data)
|
||||||
s.udmSubService.Insert(neId, u)
|
s.udmSubService.Insert(neId, u)
|
||||||
@@ -149,7 +146,6 @@ func (s *UDMSubController) Add(c *gin.Context) {
|
|||||||
|
|
||||||
// 命令ok时
|
// 命令ok时
|
||||||
if strings.Contains(data, "ok") {
|
if strings.Contains(data, "ok") {
|
||||||
neId = ""
|
|
||||||
body.NeId = neId
|
body.NeId = neId
|
||||||
s.udmSubService.Insert(neId, body)
|
s.udmSubService.Insert(neId, body)
|
||||||
}
|
}
|
||||||
@@ -204,8 +200,7 @@ func (s *UDMSubController) Adds(c *gin.Context) {
|
|||||||
|
|
||||||
// 命令ok时
|
// 命令ok时
|
||||||
if strings.Contains(data, "ok") {
|
if strings.Contains(data, "ok") {
|
||||||
neId = ""
|
s.udmSubService.LoadData(neId, body.IMSI, num, body.Remark)
|
||||||
go s.udmSubService.LoadData(neId, body.IMSI, num, body.Remark)
|
|
||||||
}
|
}
|
||||||
c.JSON(200, result.OkData(data))
|
c.JSON(200, result.OkData(data))
|
||||||
}
|
}
|
||||||
@@ -253,7 +248,6 @@ func (s *UDMSubController) Edit(c *gin.Context) {
|
|||||||
|
|
||||||
// 命令ok时
|
// 命令ok时
|
||||||
if strings.Contains(data, "ok") {
|
if strings.Contains(data, "ok") {
|
||||||
neId = ""
|
|
||||||
body.NeId = neId
|
body.NeId = neId
|
||||||
s.udmSubService.Insert(neId, body)
|
s.udmSubService.Insert(neId, body)
|
||||||
}
|
}
|
||||||
@@ -305,7 +299,6 @@ func (s *UDMSubController) Remove(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
// 命令ok时
|
// 命令ok时
|
||||||
if strings.Contains(data, "ok") {
|
if strings.Contains(data, "ok") {
|
||||||
neId = ""
|
|
||||||
s.udmSubService.Delete(neId, imsi)
|
s.udmSubService.Delete(neId, imsi)
|
||||||
}
|
}
|
||||||
resultData[imsi] = data
|
resultData[imsi] = data
|
||||||
@@ -351,9 +344,7 @@ func (s *UDMSubController) Removes(c *gin.Context) {
|
|||||||
|
|
||||||
// 命令ok时
|
// 命令ok时
|
||||||
if strings.Contains(data, "ok") {
|
if strings.Contains(data, "ok") {
|
||||||
neId = ""
|
s.udmSubService.LoadData(neId, imsi, num, "-(Deleted)-")
|
||||||
go s.udmSubService.LoadData(neId, imsi, num, "-(Deleted)-")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
c.JSON(200, result.OkData(data))
|
c.JSON(200, result.OkData(data))
|
||||||
}
|
}
|
||||||
@@ -363,53 +354,64 @@ func (s *UDMSubController) Removes(c *gin.Context) {
|
|||||||
// POST /export
|
// POST /export
|
||||||
func (s *UDMSubController) Export(c *gin.Context) {
|
func (s *UDMSubController) Export(c *gin.Context) {
|
||||||
language := ctx.AcceptLanguage(c)
|
language := ctx.AcceptLanguage(c)
|
||||||
var body struct {
|
// 查询结果,根据查询条件结果,单页最大值限制
|
||||||
NeId string `json:"neId" binding:"required"`
|
querys := ctx.BodyJSONMap(c)
|
||||||
Type string `json:"type" binding:"required"`
|
neId := querys["neId"].(string)
|
||||||
}
|
fileType := querys["type"].(string)
|
||||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
if neId == "" || fileType == "" {
|
||||||
if err != nil {
|
|
||||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if !(fileType == "csv" || fileType == "txt") {
|
||||||
if !(body.Type == "csv" || body.Type == "txt") {
|
|
||||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "ne.udm.errImportUserSubFileFormat")))
|
c.JSON(200, result.ErrMsg(i18n.TKey(language, "ne.udm.errImportUserSubFileFormat")))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
neId := ""
|
querys["pageNum"] = 1
|
||||||
list := s.udmSubService.SelectList(model.UDMSubUser{NeId: neId})
|
querys["pageSize"] = 10000
|
||||||
|
data := s.udmSubService.SelectPage(querys)
|
||||||
|
if parse.Number(data["total"]) == 0 {
|
||||||
|
// 导出数据记录为空
|
||||||
|
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rows := data["rows"].([]model.UDMSubUser)
|
||||||
|
|
||||||
|
// rows := s.udmSubService.SelectList(model.UDMSubUser{NeId: neId})
|
||||||
|
if len(rows) <= 0 {
|
||||||
|
// 导出数据记录为空
|
||||||
|
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 文件名
|
// 文件名
|
||||||
fileName := fmt.Sprintf("udm_sub_user_export_%s_%d.%s", neId, time.Now().UnixMilli(), body.Type)
|
fileName := fmt.Sprintf("udm_sub_user_export_%s_%d.%s", neId, time.Now().UnixMilli(), fileType)
|
||||||
filePath := fmt.Sprintf("%s/%s", file.ParseUploadFileDir(uploadsubpath.EXPORT), fileName)
|
filePath := fmt.Sprintf("%s/%s", file.ParseUploadFileDir(uploadsubpath.EXPORT), fileName)
|
||||||
|
|
||||||
if body.Type == "csv" {
|
if fileType == "csv" {
|
||||||
// 转换数据
|
// 转换数据
|
||||||
data := [][]string{}
|
data := [][]string{}
|
||||||
data = append(data, []string{"IMSI", "MSISDN", "UeAmbrTpl", "NssaiTpl", "AreaForbiddenTpl", "ServiceAreaRestrictionTpl", "RatRestrictions", "CnTypeRestrictions", "SmfSel", "SmData", "EPSDat"})
|
data = append(data, []string{"IMSI", "MSISDN", "UeAmbrTpl", "NssaiTpl", "AreaForbiddenTpl", "ServiceAreaRestrictionTpl", "RatRestrictions", "CnTypeRestrictions", "SmfSel", "SmData", "EPSDat"})
|
||||||
for _, v := range list {
|
for _, v := range rows {
|
||||||
epsDat := fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s,%s", v.EpsFlag, v.EpsOdb, v.HplmnOdb, v.Ard, v.Epstpl, v.ContextId, v.ApnContext, v.StaticIp)
|
epsDat := fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s,%s", v.EpsFlag, v.EpsOdb, v.HplmnOdb, v.Ard, v.Epstpl, v.ContextId, v.ApnContext, v.StaticIp)
|
||||||
data = append(data, []string{v.IMSI, v.MSISDN, v.UeAmbrTpl, v.NssaiTpl, v.AreaForbiddenTpl, v.ServiceAreaRestrictionTpl, v.RatRestrictions, v.CnTypeRestrictions, v.SmfSel, v.SmData, epsDat})
|
data = append(data, []string{v.IMSI, v.MSISDN, v.UeAmbrTpl, v.NssaiTpl, v.AreaForbiddenTpl, v.ServiceAreaRestrictionTpl, v.RatRestrictions, v.CnTypeRestrictions, v.SmfSel, v.SmData, epsDat})
|
||||||
}
|
}
|
||||||
// 输出到文件
|
// 输出到文件
|
||||||
err = file.WriterFileCSV(data, filePath)
|
if err := file.WriterFileCSV(data, filePath); err != nil {
|
||||||
if err != nil {
|
|
||||||
c.JSON(200, result.ErrMsg(err.Error()))
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if body.Type == "txt" {
|
if fileType == "txt" {
|
||||||
// 转换数据
|
// 转换数据
|
||||||
data := [][]string{}
|
data := [][]string{}
|
||||||
for _, v := range list {
|
for _, v := range rows {
|
||||||
epsDat := fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s,%s", v.EpsFlag, v.EpsOdb, v.HplmnOdb, v.Ard, v.Epstpl, v.ContextId, v.ApnContext, v.StaticIp)
|
epsDat := fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s,%s", v.EpsFlag, v.EpsOdb, v.HplmnOdb, v.Ard, v.Epstpl, v.ContextId, v.ApnContext, v.StaticIp)
|
||||||
data = append(data, []string{v.IMSI, v.MSISDN, v.UeAmbrTpl, v.NssaiTpl, v.AreaForbiddenTpl, v.ServiceAreaRestrictionTpl, v.RatRestrictions, v.CnTypeRestrictions, v.SmfSel, v.SmData, epsDat})
|
data = append(data, []string{v.IMSI, v.MSISDN, v.UeAmbrTpl, v.NssaiTpl, v.AreaForbiddenTpl, v.ServiceAreaRestrictionTpl, v.RatRestrictions, v.CnTypeRestrictions, v.SmfSel, v.SmData, epsDat})
|
||||||
}
|
}
|
||||||
// 输出到文件
|
// 输出到文件
|
||||||
err = file.WriterFileTXT(data, ",", filePath)
|
if err := file.WriterFileTXT(data, ",", filePath); err != nil {
|
||||||
if err != nil {
|
|
||||||
c.JSON(200, result.ErrMsg(err.Error()))
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -489,13 +491,11 @@ func (s *UDMSubController) Import(c *gin.Context) {
|
|||||||
if strings.Contains(data, "ok") {
|
if strings.Contains(data, "ok") {
|
||||||
if strings.HasSuffix(body.UploadPath, ".csv") {
|
if strings.HasSuffix(body.UploadPath, ".csv") {
|
||||||
data := file.ReadFileCSV(localFilePath)
|
data := file.ReadFileCSV(localFilePath)
|
||||||
neId := ""
|
go s.udmSubService.InsertData(neInfo.NeId, "csv", data)
|
||||||
go s.udmSubService.InsertData(neId, "csv", data)
|
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(body.UploadPath, ".txt") {
|
if strings.HasSuffix(body.UploadPath, ".txt") {
|
||||||
data := file.ReadFileTXT(",", localFilePath)
|
data := file.ReadFileTXT(",", localFilePath)
|
||||||
neId := ""
|
go s.udmSubService.InsertData(neInfo.NeId, "txt", data)
|
||||||
go s.udmSubService.InsertData(neId, "txt", data)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.JSON(200, result.OkMsg(data))
|
c.JSON(200, result.OkMsg(data))
|
||||||
|
|||||||
@@ -53,7 +53,8 @@ func (r *UDMAuthUser) convertResultRows(rows []map[string]any) []model.UDMAuthUs
|
|||||||
// ClearAndInsert 清空ne_id后新增实体
|
// ClearAndInsert 清空ne_id后新增实体
|
||||||
func (r *UDMAuthUser) ClearAndInsert(neId string, uArr []model.UDMAuthUser) int64 {
|
func (r *UDMAuthUser) ClearAndInsert(neId string, uArr []model.UDMAuthUser) int64 {
|
||||||
// 不指定neID时,用 TRUNCATE 清空表快
|
// 不指定neID时,用 TRUNCATE 清空表快
|
||||||
_, err := datasource.ExecDB("", "TRUNCATE TABLE u_auth_user", nil)
|
// _, err := datasource.ExecDB("", "TRUNCATE TABLE u_auth_user", nil)
|
||||||
|
_, err := datasource.ExecDB("", "DELETE FROM u_auth_user WHERE ne_id = ?", []any{neId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("TRUNCATE err => %v", err)
|
logger.Errorf("TRUNCATE err => %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,9 +82,10 @@ func (r *UDMSubUser) convertResultRows(rows []map[string]any) []model.UDMSubUser
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ClearAndInsert 清空ne_id后新增实体
|
// ClearAndInsert 清空ne_id后新增实体
|
||||||
func (r *UDMSubUser) ClearAndInsert(neID string, u []model.UDMSubUser) int64 {
|
func (r *UDMSubUser) ClearAndInsert(neId string, u []model.UDMSubUser) int64 {
|
||||||
// 不指定neID时,用 TRUNCATE 清空表快
|
// 不指定neID时,用 TRUNCATE 清空表快
|
||||||
_, err := datasource.ExecDB("", "TRUNCATE TABLE u_sub_user", nil)
|
// _, err := datasource.ExecDB("", "TRUNCATE TABLE u_sub_user", nil)
|
||||||
|
_, err := datasource.ExecDB("", "DELETE FROM u_sub_user WHERE ne_id = ?", []any{neId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("TRUNCATE err => %v", err)
|
logger.Errorf("TRUNCATE err => %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"be.ems/src/framework/redis"
|
"be.ems/src/framework/redis"
|
||||||
"be.ems/src/modules/network_data/model"
|
"be.ems/src/modules/network_data/model"
|
||||||
"be.ems/src/modules/network_data/repository"
|
"be.ems/src/modules/network_data/repository"
|
||||||
|
neService "be.ems/src/modules/network_element/service"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 实例化服务层 UDMAuthUser 结构体
|
// 实例化服务层 UDMAuthUser 结构体
|
||||||
@@ -25,12 +26,25 @@ type UDMAuthUser struct {
|
|||||||
func (r *UDMAuthUser) dataByRedis(imsi, neId string) []model.UDMAuthUser {
|
func (r *UDMAuthUser) dataByRedis(imsi, neId string) []model.UDMAuthUser {
|
||||||
arr := []model.UDMAuthUser{}
|
arr := []model.UDMAuthUser{}
|
||||||
key := fmt.Sprintf("ausf:%s", imsi)
|
key := fmt.Sprintf("ausf:%s", imsi)
|
||||||
ausfArr, err := redis.GetKeys("udmuser", key)
|
source := fmt.Sprintf("UDM_%s", neId)
|
||||||
|
|
||||||
|
// 网元主机的Redis客户端
|
||||||
|
redisClient, err := neService.NewNeInfo.NeRunRedisClient("UDM", neId)
|
||||||
|
if err != nil {
|
||||||
|
return arr
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
redisClient.Close()
|
||||||
|
redis.ConnectPush(source, nil)
|
||||||
|
}()
|
||||||
|
redis.ConnectPush(source, redisClient.Client)
|
||||||
|
|
||||||
|
ausfArr, err := redis.GetKeys(source, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return arr
|
return arr
|
||||||
}
|
}
|
||||||
for _, key := range ausfArr {
|
for _, key := range ausfArr {
|
||||||
m, err := redis.GetHash("udmuser", key)
|
m, err := redis.GetHash(source, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"be.ems/src/framework/redis"
|
"be.ems/src/framework/redis"
|
||||||
"be.ems/src/modules/network_data/model"
|
"be.ems/src/modules/network_data/model"
|
||||||
"be.ems/src/modules/network_data/repository"
|
"be.ems/src/modules/network_data/repository"
|
||||||
|
neService "be.ems/src/modules/network_element/service"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 实例化服务层 UDMSubUser 结构体
|
// 实例化服务层 UDMSubUser 结构体
|
||||||
@@ -18,22 +19,33 @@ var NewUDMSub = &UDMSubUser{
|
|||||||
|
|
||||||
// UDM签约信息 服务层处理
|
// UDM签约信息 服务层处理
|
||||||
type UDMSubUser struct {
|
type UDMSubUser struct {
|
||||||
// UDM签约信息数据信息
|
udmSubRepository *repository.UDMSubUser // UDM签约信息数据信息
|
||||||
udmSubRepository *repository.UDMSubUser
|
udmUserInfoRepository *repository.UDMUserInfo // UDM用户IMSI信息数据信息
|
||||||
// UDM用户IMSI信息数据信息
|
|
||||||
udmUserInfoRepository *repository.UDMUserInfo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// dataByRedis UDM签约用户 db:0 中 udm-sd:*
|
// dataByRedis UDM签约用户 db:0 中 udm-sd:*
|
||||||
func (r *UDMSubUser) dataByRedis(imsi, neId string) []model.UDMSubUser {
|
func (r *UDMSubUser) dataByRedis(imsi, neId string) []model.UDMSubUser {
|
||||||
arr := []model.UDMSubUser{}
|
arr := []model.UDMSubUser{}
|
||||||
key := fmt.Sprintf("udm-sd:%s", imsi)
|
key := fmt.Sprintf("udm-sd:%s", imsi)
|
||||||
udmsdArr, err := redis.GetKeys("udmuser", key)
|
source := fmt.Sprintf("UDM_%s", neId)
|
||||||
|
|
||||||
|
// 网元主机的Redis客户端
|
||||||
|
redisClient, err := neService.NewNeInfo.NeRunRedisClient("UDM", neId)
|
||||||
|
if err != nil {
|
||||||
|
return arr
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
redisClient.Close()
|
||||||
|
redis.ConnectPush(source, nil)
|
||||||
|
}()
|
||||||
|
redis.ConnectPush(source, redisClient.Client)
|
||||||
|
|
||||||
|
udmsdArr, err := redis.GetKeys(source, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return arr
|
return arr
|
||||||
}
|
}
|
||||||
for _, key := range udmsdArr {
|
for _, key := range udmsdArr {
|
||||||
m, err := redis.GetHash("udmuser", key)
|
m, err := redis.GetHash(source, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ type NeActionController struct {
|
|||||||
neInfoService *neService.NeInfo
|
neInfoService *neService.NeInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送文件从本地到网元
|
// 从本地到网元发送文件
|
||||||
//
|
//
|
||||||
// POST /pushFile
|
// POST /pushFile
|
||||||
func (s *NeActionController) PushFile(c *gin.Context) {
|
func (s *NeActionController) PushFile(c *gin.Context) {
|
||||||
@@ -88,7 +88,7 @@ func (s *NeActionController) PushFile(c *gin.Context) {
|
|||||||
c.JSON(200, result.OkData(filepath.ToSlash(neFilePath)))
|
c.JSON(200, result.OkData(filepath.ToSlash(neFilePath)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取文件从网元到本地
|
// 从网元到本地获取文件
|
||||||
//
|
//
|
||||||
// GET /pullFile
|
// GET /pullFile
|
||||||
func (s *NeActionController) PullFile(c *gin.Context) {
|
func (s *NeActionController) PullFile(c *gin.Context) {
|
||||||
@@ -147,6 +147,116 @@ func (s *NeActionController) PullFile(c *gin.Context) {
|
|||||||
c.FileAttachment(localFilePath, fileName)
|
c.FileAttachment(localFilePath, fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 从网元到本地获取目录压缩为ZIP
|
||||||
|
//
|
||||||
|
// GET /pullDirZip
|
||||||
|
func (s *NeActionController) PullDirZip(c *gin.Context) {
|
||||||
|
language := ctx.AcceptLanguage(c)
|
||||||
|
var querys struct {
|
||||||
|
NeType string `form:"neType" binding:"required"`
|
||||||
|
NeID string `form:"neId" binding:"required"`
|
||||||
|
Path string `form:"path" binding:"required"`
|
||||||
|
DelTemp bool `form:"delTemp"` // 删除本地临时文件
|
||||||
|
}
|
||||||
|
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||||
|
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询网元获取IP
|
||||||
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(querys.NeType, querys.NeID)
|
||||||
|
if neInfo.NeId != querys.NeID || neInfo.IP == "" {
|
||||||
|
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 网元主机的SSH客户端
|
||||||
|
sshClient, err := s.neInfoService.NeRunSSHClient(neInfo.NeType, neInfo.NeId)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer sshClient.Close()
|
||||||
|
// 网元主机的SSH客户端进行文件传输
|
||||||
|
sftpClient, err := sshClient.NewClientSFTP()
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer sftpClient.Close()
|
||||||
|
|
||||||
|
nePath := querys.Path
|
||||||
|
dirName := generate.Code(6)
|
||||||
|
localFilePath := filepath.Join("/tmp/omc/pull/", dirName)
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
localFilePath = fmt.Sprintf("C:%s", localFilePath)
|
||||||
|
}
|
||||||
|
// 复制到本地
|
||||||
|
localDirFilePath := filepath.Join(localFilePath, "zip")
|
||||||
|
if err = sftpClient.CopyDirRemoteToLocal(nePath, localDirFilePath); err != nil {
|
||||||
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 压缩zip文件名
|
||||||
|
zipFileName := fmt.Sprintf("%s-%s-%s.zip", neInfo.NeType, neInfo.NeId, dirName)
|
||||||
|
zipFilePath := filepath.Join(localFilePath, zipFileName)
|
||||||
|
if err := file.CompressZipByDir(zipFilePath, localDirFilePath); err != nil {
|
||||||
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if querys.DelTemp {
|
||||||
|
_ = os.RemoveAll(localFilePath)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
c.FileAttachment(zipFilePath, zipFileName)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查看网元端文件内容
|
||||||
|
//
|
||||||
|
// GET /viewFile
|
||||||
|
func (s *NeActionController) ViewFile(c *gin.Context) {
|
||||||
|
language := ctx.AcceptLanguage(c)
|
||||||
|
var querys struct {
|
||||||
|
NeType string `form:"neType" binding:"required"`
|
||||||
|
NeID string `form:"neId" binding:"required"`
|
||||||
|
Path string `form:"path" binding:"required"`
|
||||||
|
FileName string `form:"fileName" binding:"required"`
|
||||||
|
}
|
||||||
|
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||||
|
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询网元获取IP
|
||||||
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(querys.NeType, querys.NeID)
|
||||||
|
if neInfo.NeId != querys.NeID || neInfo.IP == "" {
|
||||||
|
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 网元主机的SSH客户端
|
||||||
|
sshClient, err := s.neInfoService.NeRunSSHClient(neInfo.NeType, neInfo.NeId)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(200, result.ErrMsg(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer sshClient.Close()
|
||||||
|
|
||||||
|
// 网元端文件
|
||||||
|
nePath := filepath.ToSlash(filepath.Join(querys.Path, querys.FileName))
|
||||||
|
// 网元端临时目录
|
||||||
|
output, err := sshClient.RunCMD(fmt.Sprintf("cat %s", nePath))
|
||||||
|
output = strings.TrimSpace(output)
|
||||||
|
if err != nil || strings.HasPrefix(output, "ls: ") {
|
||||||
|
c.JSON(200, result.ErrMsg(i18n.TKey(language, "file view cat error")))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(200, result.OkData(output))
|
||||||
|
}
|
||||||
|
|
||||||
// 网元端文件列表
|
// 网元端文件列表
|
||||||
//
|
//
|
||||||
// GET /files
|
// GET /files
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"be.ems/src/framework/i18n"
|
"be.ems/src/framework/i18n"
|
||||||
|
"be.ems/src/framework/redis"
|
||||||
"be.ems/src/framework/telnet"
|
"be.ems/src/framework/telnet"
|
||||||
"be.ems/src/framework/utils/ctx"
|
"be.ems/src/framework/utils/ctx"
|
||||||
"be.ems/src/framework/utils/parse"
|
"be.ems/src/framework/utils/parse"
|
||||||
@@ -211,6 +212,21 @@ func (s *NeHostController) Test(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if body.HostType == "redis" {
|
||||||
|
var connRedis redis.ConnRedis
|
||||||
|
body.CopyTo(&connRedis)
|
||||||
|
|
||||||
|
client, err := connRedis.NewClient()
|
||||||
|
if err != nil {
|
||||||
|
// 连接主机失败,请检查连接参数后重试
|
||||||
|
c.JSON(200, result.ErrMsg(i18n.TKey(language, "neHost.errByHostInfo")))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer client.Close()
|
||||||
|
c.JSON(200, result.Ok(nil))
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 网元主机发送命令
|
// 网元主机发送命令
|
||||||
|
|||||||
@@ -5,16 +5,17 @@ import "encoding/json"
|
|||||||
// NeHost 网元主机表 ne_host
|
// NeHost 网元主机表 ne_host
|
||||||
type NeHost struct {
|
type NeHost struct {
|
||||||
HostID string `json:"hostId" gorm:"column:host_id"` // 主机主键
|
HostID string `json:"hostId" gorm:"column:host_id"` // 主机主键
|
||||||
HostType string `json:"hostType" gorm:"column:host_type" binding:"oneof=ssh telnet"` // 主机类型 ssh telnet redis
|
HostType string `json:"hostType" gorm:"column:host_type" binding:"oneof=ssh telnet redis"` // 连接类型 ssh telnet redis
|
||||||
GroupID string `json:"groupId" gorm:"column:group_id"` // 分组(0默认 1网元 2系统)
|
GroupID string `json:"groupId" gorm:"column:group_id"` // 分组(0默认 1网元 2系统)
|
||||||
Title string `json:"title" gorm:"column:title"` // 标题名称
|
Title string `json:"title" gorm:"column:title"` // 标题名称
|
||||||
Addr string `json:"addr" gorm:"column:addr" binding:"required"` // 主机地址
|
Addr string `json:"addr" gorm:"column:addr" binding:"required"` // 主机地址
|
||||||
Port int64 `json:"port" gorm:"column:port" binding:"required,number,max=65535,min=1"` // 主机端口 22 4100
|
Port int64 `json:"port" gorm:"column:port" binding:"required,number,max=65535,min=1"` // 端口 22 4100 6379
|
||||||
User string `json:"user" gorm:"column:user" binding:"required"` // 主机用户名
|
User string `json:"user" gorm:"column:user" binding:"required"` // 认证用户名
|
||||||
AuthMode string `json:"authMode" gorm:"column:auth_mode" binding:"oneof=0 1 2"` // 认证模式(0密码 1主机私钥 2已免密)
|
AuthMode string `json:"authMode" gorm:"column:auth_mode" binding:"oneof=0 1 2"` // 认证模式(0密码 1主机私钥 2已免密)
|
||||||
Password string `json:"password" gorm:"column:password"` // 认证密码
|
Password string `json:"password" gorm:"column:password"` // 认证密码
|
||||||
PrivateKey string `json:"privateKey" gorm:"column:private_key"` // 认证私钥
|
PrivateKey string `json:"privateKey" gorm:"column:private_key"` // 认证私钥
|
||||||
PassPhrase string `json:"passPhrase" gorm:"column:pass_phrase"` // 认证私钥密码
|
PassPhrase string `json:"passPhrase" gorm:"column:pass_phrase"` // 认证私钥密码
|
||||||
|
DBName string `json:"dbName" gorm:"column:db_name"` // 数据库名称
|
||||||
Remark string `json:"remark" gorm:"column:remark"` // 备注
|
Remark string `json:"remark" gorm:"column:remark"` // 备注
|
||||||
CreateBy string `json:"createBy" gorm:"column:create_by"` // 创建者
|
CreateBy string `json:"createBy" gorm:"column:create_by"` // 创建者
|
||||||
CreateTime int64 `json:"createTime" gorm:"column:create_time"` // 创建时间
|
CreateTime int64 `json:"createTime" gorm:"column:create_time"` // 创建时间
|
||||||
@@ -23,7 +24,7 @@ type NeHost struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TableName 表名称
|
// TableName 表名称
|
||||||
func (NeHost) TableName() string {
|
func (*NeHost) TableName() string {
|
||||||
return "ne_host"
|
return "ne_host"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ type NeInfo struct {
|
|||||||
VendorName string `json:"vendorName" gorm:"vendor_name"`
|
VendorName string `json:"vendorName" gorm:"vendor_name"`
|
||||||
Dn string `json:"dn" gorm:"dn"`
|
Dn string `json:"dn" gorm:"dn"`
|
||||||
NeAddress string `json:"neAddress" gorm:"ne_address"` // MAC地址
|
NeAddress string `json:"neAddress" gorm:"ne_address"` // MAC地址
|
||||||
HostIDs string `json:"hostIds" gorm:"host_ids"` // 网元主机ID组 数据格式(ssh,telnet,telnet)
|
HostIDs string `json:"hostIds" gorm:"host_ids"` // 网元主机ID组 数据格式(ssh,telnet) UDM(ssh,telnet,redis) UPF(ssh,telnet,telnet)
|
||||||
Status string `json:"status" gorm:"status"` // 0离线 1在线 2配置待下发
|
Status string `json:"status" gorm:"status"` // 0离线 1在线 2配置待下发
|
||||||
Remark string `json:"remark" gorm:"remark"` // 备注
|
Remark string `json:"remark" gorm:"remark"` // 备注
|
||||||
CreateBy string `json:"createBy" gorm:"create_by"` // 创建者
|
CreateBy string `json:"createBy" gorm:"create_by"` // 创建者
|
||||||
|
|||||||
@@ -17,10 +17,8 @@ func Setup(router *gin.Engine) {
|
|||||||
// 启动时需要的初始参数
|
// 启动时需要的初始参数
|
||||||
InitLoad()
|
InitLoad()
|
||||||
|
|
||||||
neGroup := router.Group("/ne")
|
|
||||||
|
|
||||||
// 网元操作处理
|
// 网元操作处理
|
||||||
neActionGroup := neGroup.Group("/action")
|
neActionGroup := router.Group("/ne/action")
|
||||||
{
|
{
|
||||||
neActionGroup.GET("/files",
|
neActionGroup.GET("/files",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
@@ -35,6 +33,14 @@ func Setup(router *gin.Engine) {
|
|||||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.neAction", collectlogs.BUSINESS_TYPE_IMPORT)),
|
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.neAction", collectlogs.BUSINESS_TYPE_IMPORT)),
|
||||||
controller.NewNeAction.PushFile,
|
controller.NewNeAction.PushFile,
|
||||||
)
|
)
|
||||||
|
neActionGroup.GET("/pullDirZip",
|
||||||
|
middleware.PreAuthorize(nil),
|
||||||
|
controller.NewNeAction.PullDirZip,
|
||||||
|
)
|
||||||
|
neActionGroup.GET("/viewFile",
|
||||||
|
middleware.PreAuthorize(nil),
|
||||||
|
controller.NewNeAction.ViewFile,
|
||||||
|
)
|
||||||
neActionGroup.PUT("/service",
|
neActionGroup.PUT("/service",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.neAction", collectlogs.BUSINESS_TYPE_OTHER)),
|
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.neAction", collectlogs.BUSINESS_TYPE_OTHER)),
|
||||||
@@ -43,7 +49,7 @@ func Setup(router *gin.Engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 网元信息
|
// 网元信息
|
||||||
neInfoGroup := neGroup.Group("/info")
|
neInfoGroup := router.Group("/ne/info")
|
||||||
{
|
{
|
||||||
neInfoGroup.GET("/state",
|
neInfoGroup.GET("/state",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
@@ -104,7 +110,7 @@ func Setup(router *gin.Engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 网元主机
|
// 网元主机
|
||||||
neHostGroup := neGroup.Group("/host")
|
neHostGroup := router.Group("/ne/host")
|
||||||
{
|
{
|
||||||
neHostGroup.GET("/list",
|
neHostGroup.GET("/list",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
@@ -153,7 +159,7 @@ func Setup(router *gin.Engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 网元主机命令
|
// 网元主机命令
|
||||||
neHostCmdGroup := neGroup.Group("/hostCmd")
|
neHostCmdGroup := router.Group("/ne/hostCmd")
|
||||||
{
|
{
|
||||||
neHostCmdGroup.GET("/list",
|
neHostCmdGroup.GET("/list",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
@@ -181,7 +187,7 @@ func Setup(router *gin.Engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 网元版本信息
|
// 网元版本信息
|
||||||
neVersionGroup := neGroup.Group("/version")
|
neVersionGroup := router.Group("/ne/version")
|
||||||
{
|
{
|
||||||
neVersionGroup.GET("/list",
|
neVersionGroup.GET("/list",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
@@ -199,7 +205,7 @@ func Setup(router *gin.Engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 网元软件包信息
|
// 网元软件包信息
|
||||||
neSoftwareGroup := neGroup.Group("/software")
|
neSoftwareGroup := router.Group("/ne/software")
|
||||||
{
|
{
|
||||||
neSoftwareGroup.GET("/list",
|
neSoftwareGroup.GET("/list",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
@@ -232,7 +238,7 @@ func Setup(router *gin.Engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 网元授权激活信息
|
// 网元授权激活信息
|
||||||
neLicenseGroup := neGroup.Group("/license")
|
neLicenseGroup := router.Group("/ne/license")
|
||||||
{
|
{
|
||||||
neLicenseGroup.GET("/list",
|
neLicenseGroup.GET("/list",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
@@ -262,7 +268,7 @@ func Setup(router *gin.Engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 网元参数配置
|
// 网元参数配置
|
||||||
neConfigGroup := neGroup.Group("/config")
|
neConfigGroup := router.Group("/ne/config")
|
||||||
{
|
{
|
||||||
// 网元参数配置可用属性值
|
// 网元参数配置可用属性值
|
||||||
neConfigGroup.GET("/list",
|
neConfigGroup.GET("/list",
|
||||||
@@ -315,7 +321,7 @@ func Setup(router *gin.Engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 网元配置文件备份记录
|
// 网元配置文件备份记录
|
||||||
neConfigBackupGroup := neGroup.Group("/config/backup")
|
neConfigBackupGroup := router.Group("/ne/config/backup")
|
||||||
{
|
{
|
||||||
neConfigBackupGroup.GET("/list",
|
neConfigBackupGroup.GET("/list",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
// 实例化数据层 NeHost 结构体
|
// 实例化数据层 NeHost 结构体
|
||||||
var NewNeHost = &NeHost{
|
var NewNeHost = &NeHost{
|
||||||
selectSql: `select
|
selectSql: `select
|
||||||
host_id, host_type, group_id, title, addr, port, user, auth_mode, password, private_key, pass_phrase, remark, create_by, create_time, update_by, update_time
|
host_id, host_type, group_id, title, addr, port, user, auth_mode, password, private_key, pass_phrase, db_name, remark, create_by, create_time, update_by, update_time
|
||||||
from ne_host`,
|
from ne_host`,
|
||||||
|
|
||||||
resultMap: map[string]string{
|
resultMap: map[string]string{
|
||||||
@@ -30,6 +30,7 @@ var NewNeHost = &NeHost{
|
|||||||
"password": "Password",
|
"password": "Password",
|
||||||
"private_key": "PrivateKey",
|
"private_key": "PrivateKey",
|
||||||
"private_password": "PassPhrase",
|
"private_password": "PassPhrase",
|
||||||
|
"db_name": "DBName",
|
||||||
"remark": "Remark",
|
"remark": "Remark",
|
||||||
"create_by": "CreateBy",
|
"create_by": "CreateBy",
|
||||||
"create_time": "CreateTime",
|
"create_time": "CreateTime",
|
||||||
@@ -245,6 +246,9 @@ func (r *NeHost) Insert(neHost model.NeHost) string {
|
|||||||
if neHost.PassPhrase != "" {
|
if neHost.PassPhrase != "" {
|
||||||
params["pass_phrase"] = neHost.PassPhrase
|
params["pass_phrase"] = neHost.PassPhrase
|
||||||
}
|
}
|
||||||
|
if neHost.DBName != "" {
|
||||||
|
params["db_name"] = neHost.DBName
|
||||||
|
}
|
||||||
if neHost.Remark != "" {
|
if neHost.Remark != "" {
|
||||||
params["remark"] = neHost.Remark
|
params["remark"] = neHost.Remark
|
||||||
}
|
}
|
||||||
@@ -328,6 +332,9 @@ func (r *NeHost) Update(neHost model.NeHost) int64 {
|
|||||||
if neHost.PassPhrase != "" {
|
if neHost.PassPhrase != "" {
|
||||||
params["pass_phrase"] = neHost.PassPhrase
|
params["pass_phrase"] = neHost.PassPhrase
|
||||||
}
|
}
|
||||||
|
if neHost.DBName != "" {
|
||||||
|
params["db_name"] = neHost.DBName
|
||||||
|
}
|
||||||
params["remark"] = neHost.Remark
|
params["remark"] = neHost.Remark
|
||||||
if neHost.UpdateBy != "" {
|
if neHost.UpdateBy != "" {
|
||||||
params["update_by"] = neHost.UpdateBy
|
params["update_by"] = neHost.UpdateBy
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ var neListSort = []string{
|
|||||||
"N3IWF",
|
"N3IWF",
|
||||||
"MOCNGW",
|
"MOCNGW",
|
||||||
"SMSC",
|
"SMSC",
|
||||||
|
"SMSF",
|
||||||
"CBC",
|
"CBC",
|
||||||
|
"CHF",
|
||||||
}
|
}
|
||||||
|
|
||||||
// 实例化数据层 NeInfo 结构体
|
// 实例化数据层 NeInfo 结构体
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ var NewNeInfo = &NeInfo{
|
|||||||
|
|
||||||
// 网元信息 服务层处理
|
// 网元信息 服务层处理
|
||||||
type NeInfo struct {
|
type NeInfo struct {
|
||||||
// 网元信息数据信息
|
neInfoRepository *repository.NeInfo // 网元信息数据信息
|
||||||
neInfoRepository *repository.NeInfo
|
|
||||||
Para5GData map[string]string
|
Para5GData map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,6 +225,7 @@ func (r *NeInfo) Insert(neInfo model.NeInfo) string {
|
|||||||
for _, host := range neInfo.Hosts {
|
for _, host := range neInfo.Hosts {
|
||||||
host.Title = fmt.Sprintf("%s_%s_%d", strings.ToUpper(neInfo.NeType), neInfo.NeId, host.Port)
|
host.Title = fmt.Sprintf("%s_%s_%d", strings.ToUpper(neInfo.NeType), neInfo.NeId, host.Port)
|
||||||
host.GroupID = "1"
|
host.GroupID = "1"
|
||||||
|
host.CreateBy = neInfo.CreateBy
|
||||||
hostId := NewNeHost.Insert(host)
|
hostId := NewNeHost.Insert(host)
|
||||||
if hostId != "" {
|
if hostId != "" {
|
||||||
hostIDs = append(hostIDs, hostId)
|
hostIDs = append(hostIDs, hostId)
|
||||||
@@ -250,6 +250,7 @@ func (r *NeInfo) Update(neInfo model.NeInfo) int64 {
|
|||||||
if host.HostID != "" {
|
if host.HostID != "" {
|
||||||
host.Title = fmt.Sprintf("%s_%s_%d", strings.ToUpper(neInfo.NeType), neInfo.NeId, host.Port)
|
host.Title = fmt.Sprintf("%s_%s_%d", strings.ToUpper(neInfo.NeType), neInfo.NeId, host.Port)
|
||||||
host.GroupID = "1"
|
host.GroupID = "1"
|
||||||
|
host.UpdateBy = neInfo.UpdateBy
|
||||||
NewNeHost.Update(host)
|
NewNeHost.Update(host)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -371,7 +372,7 @@ func (r *NeInfo) NeRunSSHCmd(neType, neId, cmd string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NeRunTelnetClient 网元主机的Telnet客户端-为创建相关连接,注意结束后 Close()
|
// NeRunTelnetClient 网元主机的Telnet客户端-为创建相关连接,注意结束后 Close()
|
||||||
// num 是网元主机telnet 1:4100 2:5200
|
// num 是网元主机telnet 1:4100 2:5200(UPF标准版)
|
||||||
func (r *NeInfo) NeRunTelnetClient(neType, neId string, num int) (*telnet.ConnTelnet, error) {
|
func (r *NeInfo) NeRunTelnetClient(neType, neId string, num int) (*telnet.ConnTelnet, error) {
|
||||||
neInfo := r.SelectNeInfoByNeTypeAndNeID(neType, neId)
|
neInfo := r.SelectNeInfoByNeTypeAndNeID(neType, neId)
|
||||||
if neInfo.NeId != neId {
|
if neInfo.NeId != neId {
|
||||||
@@ -406,6 +407,42 @@ func (r *NeInfo) NeRunTelnetClient(neType, neId string, num int) (*telnet.ConnTe
|
|||||||
return telnetClient, nil
|
return telnetClient, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NeRunRedisClient 网元主机的Redis客户端-为创建相关连接,注意结束后 Close()
|
||||||
|
// 暂时只有UDM有Redis配置项
|
||||||
|
func (r *NeInfo) NeRunRedisClient(neType, neId string) (*redis.ConnRedis, error) {
|
||||||
|
neInfo := r.SelectNeInfoByNeTypeAndNeID(neType, neId)
|
||||||
|
if neInfo.NeId != neId {
|
||||||
|
logger.Errorf("NeRunRedisClient NeType:%s NeID:%s not found", neType, neId)
|
||||||
|
return nil, fmt.Errorf("neinfo not found")
|
||||||
|
}
|
||||||
|
// 取主机信息
|
||||||
|
if neInfo.HostIDs == "" {
|
||||||
|
logger.Errorf("NeRunRedisClient NeType:%s NeID:%s hostId not found", neType, neId)
|
||||||
|
return nil, fmt.Errorf("neinfo hostId not found")
|
||||||
|
}
|
||||||
|
hostIds := strings.Split(neInfo.HostIDs, ",")
|
||||||
|
if len(hostIds) <= 2 {
|
||||||
|
logger.Errorf("NeRunRedisClient hosts id %s not found", neInfo.HostIDs)
|
||||||
|
return nil, fmt.Errorf("neinfo host id not found")
|
||||||
|
}
|
||||||
|
hostId := hostIds[2]
|
||||||
|
neHost := NewNeHost.SelectById(hostId)
|
||||||
|
if neHost.HostID == "" || neHost.HostID != hostId {
|
||||||
|
logger.Errorf("NeRunRedisClient Hosts %s not found", neInfo.HostIDs)
|
||||||
|
return nil, fmt.Errorf("neinfo host not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建链接Redis客户端
|
||||||
|
var connRedis redis.ConnRedis
|
||||||
|
neHost.CopyTo(&connRedis)
|
||||||
|
redisClient, err := connRedis.NewClient()
|
||||||
|
if err != nil {
|
||||||
|
logger.Errorf("NeRunRedisClient NewClient err => %s", err.Error())
|
||||||
|
return nil, fmt.Errorf("neinfo redis client new err")
|
||||||
|
}
|
||||||
|
return redisClient, nil
|
||||||
|
}
|
||||||
|
|
||||||
// NeConfOAMReadSync 网元OAM配置文件读取
|
// NeConfOAMReadSync 网元OAM配置文件读取
|
||||||
func (r *NeInfo) NeConfOAMReadSync(neType, neId string) (map[string]any, error) {
|
func (r *NeInfo) NeConfOAMReadSync(neType, neId string) (map[string]any, error) {
|
||||||
oamData, err := r.neConfOAMRead(neType, neId, true)
|
oamData, err := r.neConfOAMRead(neType, neId, true)
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ func (s *SysConfigController) ConfigKey(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
key := s.sysConfigService.SelectConfigValueByKey(configKey)
|
key := s.sysConfigService.SelectConfigValueByKey(configKey)
|
||||||
if key != "" {
|
if key != "" {
|
||||||
c.JSON(200, result.OkData(key))
|
c.JSON(200, result.OkData(i18n.TKey(language, key)))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(200, result.Err(nil))
|
c.JSON(200, result.Err(nil))
|
||||||
|
|||||||
@@ -20,18 +20,16 @@ import (
|
|||||||
|
|
||||||
// 实例化控制层 SysDictDataController 结构体
|
// 实例化控制层 SysDictDataController 结构体
|
||||||
var NewSysDictData = &SysDictDataController{
|
var NewSysDictData = &SysDictDataController{
|
||||||
sysDictDataService: service.NewSysDictDataImpl,
|
sysDictDataService: service.NewSysDictData,
|
||||||
sysDictTypeService: service.NewSysDictTypeImpl,
|
sysDictTypeService: service.NewSysDictType,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 字典类型对应的字典数据信息
|
// 字典类型对应的字典数据信息
|
||||||
//
|
//
|
||||||
// PATH /system/dict/data
|
// PATH /system/dict/data
|
||||||
type SysDictDataController struct {
|
type SysDictDataController struct {
|
||||||
// 字典数据服务
|
sysDictDataService *service.SysDictData // 字典数据服务
|
||||||
sysDictDataService service.ISysDictData
|
sysDictTypeService *service.SysDictType // 字典类型服务
|
||||||
// 字典类型服务
|
|
||||||
sysDictTypeService service.ISysDictType
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 字典数据列表
|
// 字典数据列表
|
||||||
|
|||||||
@@ -21,15 +21,14 @@ import (
|
|||||||
|
|
||||||
// 实例化控制层 SysDictTypeController 结构体
|
// 实例化控制层 SysDictTypeController 结构体
|
||||||
var NewSysDictType = &SysDictTypeController{
|
var NewSysDictType = &SysDictTypeController{
|
||||||
sysDictTypeService: service.NewSysDictTypeImpl,
|
sysDictTypeService: service.NewSysDictType,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 字典类型信息
|
// 字典类型信息
|
||||||
//
|
//
|
||||||
// PATH /system/dict/type
|
// PATH /system/dict/type
|
||||||
type SysDictTypeController struct {
|
type SysDictTypeController struct {
|
||||||
// 字典类型服务
|
sysDictTypeService *service.SysDictType // 字典类型服务
|
||||||
sysDictTypeService service.ISysDictType
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 字典类型列表
|
// 字典类型列表
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import (
|
|||||||
// 实例化控制层 SysLogLoginController 结构体
|
// 实例化控制层 SysLogLoginController 结构体
|
||||||
var NewSysLogLogin = &SysLogLoginController{
|
var NewSysLogLogin = &SysLogLoginController{
|
||||||
sysLogLoginService: service.NewSysLogLoginImpl,
|
sysLogLoginService: service.NewSysLogLoginImpl,
|
||||||
accountService: commonService.NewAccountImpl,
|
accountService: commonService.NewAccount,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 系统登录日志信息
|
// 系统登录日志信息
|
||||||
@@ -31,8 +31,7 @@ var NewSysLogLogin = &SysLogLoginController{
|
|||||||
type SysLogLoginController struct {
|
type SysLogLoginController struct {
|
||||||
// 系统登录日志服务
|
// 系统登录日志服务
|
||||||
sysLogLoginService service.ISysLogLogin
|
sysLogLoginService service.ISysLogLogin
|
||||||
// 账号身份操作服务
|
accountService *commonService.Account // 账号身份操作服务
|
||||||
accountService commonService.IAccount
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 系统登录日志列表
|
// 系统登录日志列表
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ func (s *SysProfileController) UpdateProfile(c *gin.Context) {
|
|||||||
PhoneNumber: body.PhoneNumber,
|
PhoneNumber: body.PhoneNumber,
|
||||||
Email: body.Email,
|
Email: body.Email,
|
||||||
Sex: body.Sex,
|
Sex: body.Sex,
|
||||||
|
Remark: loginUser.User.Remark,
|
||||||
}
|
}
|
||||||
rows := s.sysUserService.UpdateUser(sysUser)
|
rows := s.sysUserService.UpdateUser(sysUser)
|
||||||
if rows > 0 {
|
if rows > 0 {
|
||||||
@@ -229,9 +230,13 @@ func (s *SysProfileController) UpdatePwd(c *gin.Context) {
|
|||||||
|
|
||||||
// 修改新密码
|
// 修改新密码
|
||||||
sysUser := model.SysUser{
|
sysUser := model.SysUser{
|
||||||
UserID: userId,
|
UserID: userId,
|
||||||
UpdateBy: userName,
|
UpdateBy: userName,
|
||||||
Password: body.NewPassword,
|
Password: body.NewPassword,
|
||||||
|
Sex: user.Sex,
|
||||||
|
PhoneNumber: user.PhoneNumber,
|
||||||
|
Email: user.Email,
|
||||||
|
Remark: user.Remark,
|
||||||
}
|
}
|
||||||
rows := s.sysUserService.UpdateUser(sysUser)
|
rows := s.sysUserService.UpdateUser(sysUser)
|
||||||
if rows > 0 {
|
if rows > 0 {
|
||||||
@@ -268,9 +273,13 @@ func (s *SysProfileController) Avatar(c *gin.Context) {
|
|||||||
|
|
||||||
// 更新头像地址
|
// 更新头像地址
|
||||||
sysUser := model.SysUser{
|
sysUser := model.SysUser{
|
||||||
UserID: loginUser.UserID,
|
UserID: loginUser.UserID,
|
||||||
UpdateBy: loginUser.User.UserName,
|
UpdateBy: loginUser.User.UserName,
|
||||||
Avatar: filePath,
|
Avatar: filePath,
|
||||||
|
Sex: loginUser.User.Sex,
|
||||||
|
PhoneNumber: loginUser.User.PhoneNumber,
|
||||||
|
Email: loginUser.User.Email,
|
||||||
|
Remark: loginUser.User.Remark,
|
||||||
}
|
}
|
||||||
rows := s.sysUserService.UpdateUser(sysUser)
|
rows := s.sysUserService.UpdateUser(sysUser)
|
||||||
if rows > 0 {
|
if rows > 0 {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
var NewSysRole = &SysRoleController{
|
var NewSysRole = &SysRoleController{
|
||||||
sysRoleService: service.NewSysRoleImpl,
|
sysRoleService: service.NewSysRoleImpl,
|
||||||
sysUserService: service.NewSysUserImpl,
|
sysUserService: service.NewSysUserImpl,
|
||||||
sysDictDataService: service.NewSysDictDataImpl,
|
sysDictDataService: service.NewSysDictData,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 角色信息
|
// 角色信息
|
||||||
@@ -34,9 +34,8 @@ type SysRoleController struct {
|
|||||||
// 角色服务
|
// 角色服务
|
||||||
sysRoleService service.ISysRole
|
sysRoleService service.ISysRole
|
||||||
// 用户服务
|
// 用户服务
|
||||||
sysUserService service.ISysUser
|
sysUserService service.ISysUser
|
||||||
// 字典数据服务
|
sysDictDataService *service.SysDictData // 字典数据服务
|
||||||
sysDictDataService service.ISysDictData
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 角色列表
|
// 角色列表
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ var NewSysUser = &SysUserController{
|
|||||||
sysUserService: service.NewSysUserImpl,
|
sysUserService: service.NewSysUserImpl,
|
||||||
sysRoleService: service.NewSysRoleImpl,
|
sysRoleService: service.NewSysRoleImpl,
|
||||||
sysPostService: service.NewSysPostImpl,
|
sysPostService: service.NewSysPostImpl,
|
||||||
sysDictDataService: service.NewSysDictDataImpl,
|
sysDictDataService: service.NewSysDictData,
|
||||||
sysConfigService: service.NewSysConfigImpl,
|
sysConfigService: service.NewSysConfigImpl,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,9 +41,8 @@ type SysUserController struct {
|
|||||||
// 角色服务
|
// 角色服务
|
||||||
sysRoleService service.ISysRole
|
sysRoleService service.ISysRole
|
||||||
// 岗位服务
|
// 岗位服务
|
||||||
sysPostService service.ISysPost
|
sysPostService service.ISysPost
|
||||||
// 字典数据服务
|
sysDictDataService *service.SysDictData // 字典数据服务
|
||||||
sysDictDataService service.ISysDictData
|
|
||||||
// 参数配置服务
|
// 参数配置服务
|
||||||
sysConfigService service.ISysConfig
|
sysConfigService service.ISysConfig
|
||||||
}
|
}
|
||||||
@@ -412,9 +411,13 @@ func (s *SysUserController) ResetPwd(c *gin.Context) {
|
|||||||
|
|
||||||
userName := ctx.LoginUserToUserName(c)
|
userName := ctx.LoginUserToUserName(c)
|
||||||
info := model.SysUser{
|
info := model.SysUser{
|
||||||
UserID: body.UserID,
|
UserID: body.UserID,
|
||||||
Password: body.Password,
|
Password: body.Password,
|
||||||
UpdateBy: userName,
|
UpdateBy: userName,
|
||||||
|
Sex: user.Sex,
|
||||||
|
PhoneNumber: user.PhoneNumber,
|
||||||
|
Email: user.Email,
|
||||||
|
Remark: user.Remark,
|
||||||
}
|
}
|
||||||
rows := s.sysUserService.UpdateUser(info)
|
rows := s.sysUserService.UpdateUser(info)
|
||||||
if rows > 0 {
|
if rows > 0 {
|
||||||
@@ -455,9 +458,13 @@ func (s *SysUserController) Status(c *gin.Context) {
|
|||||||
|
|
||||||
userName := ctx.LoginUserToUserName(c)
|
userName := ctx.LoginUserToUserName(c)
|
||||||
info := model.SysUser{
|
info := model.SysUser{
|
||||||
UserID: body.UserID,
|
UserID: body.UserID,
|
||||||
Status: body.Status,
|
Status: body.Status,
|
||||||
UpdateBy: userName,
|
UpdateBy: userName,
|
||||||
|
Sex: user.Sex,
|
||||||
|
PhoneNumber: user.PhoneNumber,
|
||||||
|
Email: user.Email,
|
||||||
|
Remark: user.Remark,
|
||||||
}
|
}
|
||||||
rows := s.sysUserService.UpdateUser(info)
|
rows := s.sysUserService.UpdateUser(info)
|
||||||
if rows > 0 {
|
if rows > 0 {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// 实例化数据层 SysDictDataImpl 结构体
|
// 实例化数据层 SysDictDataImpl 结构体
|
||||||
var NewSysDictDataImpl = &SysDictDataImpl{
|
var NewSysDictData = &SysDictDataImpl{
|
||||||
selectSql: `select
|
selectSql: `select
|
||||||
dict_code, dict_sort, dict_label, dict_value, dict_type, tag_class, tag_type, status, create_by, create_time, remark
|
dict_code, dict_sort, dict_label, dict_value, dict_type, tag_class, tag_type, status, create_by, create_time, remark
|
||||||
from sys_dict_data`,
|
from sys_dict_data`,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// 实例化数据层 SysDictTypeImpl 结构体
|
// 实例化数据层 SysDictTypeImpl 结构体
|
||||||
var NewSysDictTypeImpl = &SysDictTypeImpl{
|
var NewSysDictType = &SysDictTypeImpl{
|
||||||
selectSql: `select
|
selectSql: `select
|
||||||
dict_id, dict_name, dict_type, status, create_by, create_time, remark
|
dict_id, dict_name, dict_type, status, create_by, create_time, remark
|
||||||
from sys_dict_type`,
|
from sys_dict_type`,
|
||||||
|
|||||||
@@ -1,33 +1,114 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import "be.ems/src/modules/system/model"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
// ISysDictData 字典类型数据 服务层接口
|
"be.ems/src/modules/system/model"
|
||||||
type ISysDictData interface {
|
"be.ems/src/modules/system/repository"
|
||||||
// SelectDictDataPage 根据条件分页查询字典数据
|
)
|
||||||
SelectDictDataPage(query map[string]any) map[string]any
|
|
||||||
|
|
||||||
// SelectDictDataList 根据条件查询字典数据
|
// 实例化服务层 SysDictData 结构体
|
||||||
SelectDictDataList(sysDictData model.SysDictData) []model.SysDictData
|
var NewSysDictData = &SysDictData{
|
||||||
|
sysDictDataRepository: repository.NewSysDictData,
|
||||||
// SelectDictDataByCode 根据字典数据编码查询信息
|
sysDictTypeService: NewSysDictType,
|
||||||
SelectDictDataByCode(dictCode string) model.SysDictData
|
}
|
||||||
|
|
||||||
// SelectDictDataByType 根据字典类型查询信息
|
// SysDictData 字典类型数据 服务层处理
|
||||||
SelectDictDataByType(dictType string) []model.SysDictData
|
type SysDictData struct {
|
||||||
|
sysDictDataRepository repository.ISysDictData // 字典数据服务
|
||||||
// CheckUniqueDictLabel 校验字典标签是否唯一
|
sysDictTypeService *SysDictType // 字典类型服务
|
||||||
CheckUniqueDictLabel(dictType, dictLabel, dictCode string) bool
|
}
|
||||||
|
|
||||||
// CheckUniqueDictValue 校验字典键值是否唯一
|
// SelectDictDataPage 根据条件分页查询字典数据
|
||||||
CheckUniqueDictValue(dictType, dictValue, dictCode string) bool
|
func (r *SysDictData) SelectDictDataPage(query map[string]any) map[string]any {
|
||||||
|
return r.sysDictDataRepository.SelectDictDataPage(query)
|
||||||
// DeleteDictDataByCodes 批量删除字典数据信息
|
}
|
||||||
DeleteDictDataByCodes(dictCodes []string) (int64, error)
|
|
||||||
|
// SelectDictDataList 根据条件查询字典数据
|
||||||
// InsertDictData 新增字典数据信息
|
func (r *SysDictData) SelectDictDataList(sysDictData model.SysDictData) []model.SysDictData {
|
||||||
InsertDictData(sysDictData model.SysDictData) string
|
return r.sysDictDataRepository.SelectDictDataList(sysDictData)
|
||||||
|
}
|
||||||
// UpdateDictData 修改字典数据信息
|
|
||||||
UpdateDictData(sysDictData model.SysDictData) int64
|
// SelectDictDataByCode 根据字典数据编码查询信息
|
||||||
|
func (r *SysDictData) SelectDictDataByCode(dictCode string) model.SysDictData {
|
||||||
|
if dictCode == "" {
|
||||||
|
return model.SysDictData{}
|
||||||
|
}
|
||||||
|
dictCodes := r.sysDictDataRepository.SelectDictDataByCodes([]string{dictCode})
|
||||||
|
if len(dictCodes) > 0 {
|
||||||
|
return dictCodes[0]
|
||||||
|
}
|
||||||
|
return model.SysDictData{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SelectDictDataByType 根据字典类型查询信息
|
||||||
|
func (r *SysDictData) SelectDictDataByType(dictType string) []model.SysDictData {
|
||||||
|
return r.sysDictTypeService.DictDataCache(dictType)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckUniqueDictLabel 校验字典标签是否唯一
|
||||||
|
func (r *SysDictData) CheckUniqueDictLabel(dictType, dictLabel, dictCode string) bool {
|
||||||
|
uniqueId := r.sysDictDataRepository.CheckUniqueDictData(model.SysDictData{
|
||||||
|
DictType: dictType,
|
||||||
|
DictLabel: dictLabel,
|
||||||
|
})
|
||||||
|
if uniqueId == dictCode {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return uniqueId == ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckUniqueDictValue 校验字典键值是否唯一
|
||||||
|
func (r *SysDictData) CheckUniqueDictValue(dictType, dictValue, dictCode string) bool {
|
||||||
|
uniqueId := r.sysDictDataRepository.CheckUniqueDictData(model.SysDictData{
|
||||||
|
DictType: dictType,
|
||||||
|
DictValue: dictValue,
|
||||||
|
})
|
||||||
|
if uniqueId == dictCode {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return uniqueId == ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteDictDataByCodes 批量删除字典数据信息
|
||||||
|
func (r *SysDictData) DeleteDictDataByCodes(dictCodes []string) (int64, error) {
|
||||||
|
// 检查是否存在
|
||||||
|
dictDatas := r.sysDictDataRepository.SelectDictDataByCodes(dictCodes)
|
||||||
|
if len(dictDatas) <= 0 {
|
||||||
|
// 没有可访问字典编码数据!
|
||||||
|
return 0, fmt.Errorf("there is no accessible dictionary-encoded data")
|
||||||
|
}
|
||||||
|
if len(dictDatas) == len(dictCodes) {
|
||||||
|
for _, v := range dictDatas {
|
||||||
|
// 刷新缓存
|
||||||
|
r.sysDictTypeService.ClearDictCache(v.DictType)
|
||||||
|
r.sysDictTypeService.LoadingDictCache(v.DictType)
|
||||||
|
}
|
||||||
|
rows := r.sysDictDataRepository.DeleteDictDataByCodes(dictCodes)
|
||||||
|
return rows, nil
|
||||||
|
}
|
||||||
|
// 删除字典数据信息失败!
|
||||||
|
return 0, fmt.Errorf("failed to delete dictionary data information")
|
||||||
|
}
|
||||||
|
|
||||||
|
// InsertDictData 新增字典数据信息
|
||||||
|
func (r *SysDictData) InsertDictData(sysDictData model.SysDictData) string {
|
||||||
|
insertId := r.sysDictDataRepository.InsertDictData(sysDictData)
|
||||||
|
if insertId != "" {
|
||||||
|
// 刷新缓存
|
||||||
|
r.sysDictTypeService.ClearDictCache(sysDictData.DictType)
|
||||||
|
r.sysDictTypeService.LoadingDictCache(sysDictData.DictType)
|
||||||
|
}
|
||||||
|
return insertId
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateDictData 修改字典数据信息
|
||||||
|
func (r *SysDictData) UpdateDictData(sysDictData model.SysDictData) int64 {
|
||||||
|
rows := r.sysDictDataRepository.UpdateDictData(sysDictData)
|
||||||
|
if rows > 0 {
|
||||||
|
// 刷新缓存
|
||||||
|
r.sysDictTypeService.ClearDictCache(sysDictData.DictType)
|
||||||
|
r.sysDictTypeService.LoadingDictCache(sysDictData.DictType)
|
||||||
|
}
|
||||||
|
return rows
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,116 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"be.ems/src/modules/system/model"
|
|
||||||
"be.ems/src/modules/system/repository"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 实例化服务层 SysDictDataImpl 结构体
|
|
||||||
var NewSysDictDataImpl = &SysDictDataImpl{
|
|
||||||
sysDictDataRepository: repository.NewSysDictDataImpl,
|
|
||||||
sysDictTypeService: NewSysDictTypeImpl,
|
|
||||||
}
|
|
||||||
|
|
||||||
// SysDictDataImpl 字典类型数据 服务层处理
|
|
||||||
type SysDictDataImpl struct {
|
|
||||||
// 字典数据服务
|
|
||||||
sysDictDataRepository repository.ISysDictData
|
|
||||||
// 字典类型服务
|
|
||||||
sysDictTypeService ISysDictType
|
|
||||||
}
|
|
||||||
|
|
||||||
// SelectDictDataPage 根据条件分页查询字典数据
|
|
||||||
func (r *SysDictDataImpl) SelectDictDataPage(query map[string]any) map[string]any {
|
|
||||||
return r.sysDictDataRepository.SelectDictDataPage(query)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SelectDictDataList 根据条件查询字典数据
|
|
||||||
func (r *SysDictDataImpl) SelectDictDataList(sysDictData model.SysDictData) []model.SysDictData {
|
|
||||||
return r.sysDictDataRepository.SelectDictDataList(sysDictData)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SelectDictDataByCode 根据字典数据编码查询信息
|
|
||||||
func (r *SysDictDataImpl) SelectDictDataByCode(dictCode string) model.SysDictData {
|
|
||||||
if dictCode == "" {
|
|
||||||
return model.SysDictData{}
|
|
||||||
}
|
|
||||||
dictCodes := r.sysDictDataRepository.SelectDictDataByCodes([]string{dictCode})
|
|
||||||
if len(dictCodes) > 0 {
|
|
||||||
return dictCodes[0]
|
|
||||||
}
|
|
||||||
return model.SysDictData{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SelectDictDataByType 根据字典类型查询信息
|
|
||||||
func (r *SysDictDataImpl) SelectDictDataByType(dictType string) []model.SysDictData {
|
|
||||||
return r.sysDictTypeService.DictDataCache(dictType)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckUniqueDictLabel 校验字典标签是否唯一
|
|
||||||
func (r *SysDictDataImpl) CheckUniqueDictLabel(dictType, dictLabel, dictCode string) bool {
|
|
||||||
uniqueId := r.sysDictDataRepository.CheckUniqueDictData(model.SysDictData{
|
|
||||||
DictType: dictType,
|
|
||||||
DictLabel: dictLabel,
|
|
||||||
})
|
|
||||||
if uniqueId == dictCode {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return uniqueId == ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckUniqueDictValue 校验字典键值是否唯一
|
|
||||||
func (r *SysDictDataImpl) CheckUniqueDictValue(dictType, dictValue, dictCode string) bool {
|
|
||||||
uniqueId := r.sysDictDataRepository.CheckUniqueDictData(model.SysDictData{
|
|
||||||
DictType: dictType,
|
|
||||||
DictValue: dictValue,
|
|
||||||
})
|
|
||||||
if uniqueId == dictCode {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return uniqueId == ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteDictDataByCodes 批量删除字典数据信息
|
|
||||||
func (r *SysDictDataImpl) DeleteDictDataByCodes(dictCodes []string) (int64, error) {
|
|
||||||
// 检查是否存在
|
|
||||||
dictDatas := r.sysDictDataRepository.SelectDictDataByCodes(dictCodes)
|
|
||||||
if len(dictDatas) <= 0 {
|
|
||||||
// 没有可访问字典编码数据!
|
|
||||||
return 0, fmt.Errorf("there is no accessible dictionary-encoded data")
|
|
||||||
}
|
|
||||||
if len(dictDatas) == len(dictCodes) {
|
|
||||||
for _, v := range dictDatas {
|
|
||||||
// 刷新缓存
|
|
||||||
r.sysDictTypeService.ClearDictCache(v.DictType)
|
|
||||||
r.sysDictTypeService.LoadingDictCache(v.DictType)
|
|
||||||
}
|
|
||||||
rows := r.sysDictDataRepository.DeleteDictDataByCodes(dictCodes)
|
|
||||||
return rows, nil
|
|
||||||
}
|
|
||||||
// 删除字典数据信息失败!
|
|
||||||
return 0, fmt.Errorf("failed to delete dictionary data information")
|
|
||||||
}
|
|
||||||
|
|
||||||
// InsertDictData 新增字典数据信息
|
|
||||||
func (r *SysDictDataImpl) InsertDictData(sysDictData model.SysDictData) string {
|
|
||||||
insertId := r.sysDictDataRepository.InsertDictData(sysDictData)
|
|
||||||
if insertId != "" {
|
|
||||||
// 刷新缓存
|
|
||||||
r.sysDictTypeService.ClearDictCache(sysDictData.DictType)
|
|
||||||
r.sysDictTypeService.LoadingDictCache(sysDictData.DictType)
|
|
||||||
}
|
|
||||||
return insertId
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateDictData 修改字典数据信息
|
|
||||||
func (r *SysDictDataImpl) UpdateDictData(sysDictData model.SysDictData) int64 {
|
|
||||||
rows := r.sysDictDataRepository.UpdateDictData(sysDictData)
|
|
||||||
if rows > 0 {
|
|
||||||
// 刷新缓存
|
|
||||||
r.sysDictTypeService.ClearDictCache(sysDictData.DictType)
|
|
||||||
r.sysDictTypeService.LoadingDictCache(sysDictData.DictType)
|
|
||||||
}
|
|
||||||
return rows
|
|
||||||
}
|
|
||||||
@@ -1,45 +1,212 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import "be.ems/src/modules/system/model"
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
// ISysDictType 字典类型 服务层接口
|
"be.ems/src/framework/constants/cachekey"
|
||||||
type ISysDictType interface {
|
"be.ems/src/framework/constants/common"
|
||||||
// SelectDictTypePage 根据条件分页查询字典类型
|
"be.ems/src/framework/redis"
|
||||||
SelectDictTypePage(query map[string]any) map[string]any
|
"be.ems/src/modules/system/model"
|
||||||
|
"be.ems/src/modules/system/repository"
|
||||||
|
)
|
||||||
|
|
||||||
// SelectDictTypeList 根据条件查询字典类型
|
// 实例化服务层 SysDictType 结构体
|
||||||
SelectDictTypeList(sysDictType model.SysDictType) []model.SysDictType
|
var NewSysDictType = &SysDictType{
|
||||||
|
sysDictTypeRepository: repository.NewSysDictType,
|
||||||
// SelectDictTypeByID 根据字典类型ID查询信息
|
sysDictDataRepository: repository.NewSysDictData,
|
||||||
SelectDictTypeByID(dictID string) model.SysDictType
|
}
|
||||||
|
|
||||||
// SelectDictTypeByType 根据字典类型查询信息
|
// SysDictType 字典类型 服务层处理
|
||||||
SelectDictTypeByType(dictType string) model.SysDictType
|
type SysDictType struct {
|
||||||
|
// 字典类型服务
|
||||||
// CheckUniqueDictName 校验字典名称是否唯一
|
sysDictTypeRepository repository.ISysDictType
|
||||||
CheckUniqueDictName(dictName, dictID string) bool
|
// 字典数据服务
|
||||||
|
sysDictDataRepository repository.ISysDictData
|
||||||
// CheckUniqueDictType 校验字典类型是否唯一
|
}
|
||||||
CheckUniqueDictType(dictType, dictID string) bool
|
|
||||||
|
// SelectDictTypePage 根据条件分页查询字典类型
|
||||||
// InsertDictType 新增字典类型信息
|
func (r *SysDictType) SelectDictTypePage(query map[string]any) map[string]any {
|
||||||
InsertDictType(sysDictType model.SysDictType) string
|
return r.sysDictTypeRepository.SelectDictTypePage(query)
|
||||||
|
}
|
||||||
// UpdateDictType 修改字典类型信息
|
|
||||||
UpdateDictType(sysDictType model.SysDictType) int64
|
// SelectDictTypeList 根据条件查询字典类型
|
||||||
|
func (r *SysDictType) SelectDictTypeList(sysDictType model.SysDictType) []model.SysDictType {
|
||||||
// DeleteDictTypeByIDs 批量删除字典类型信息
|
return r.sysDictTypeRepository.SelectDictTypeList(sysDictType)
|
||||||
DeleteDictTypeByIDs(dictIDs []string) (int64, error)
|
}
|
||||||
|
|
||||||
// ResetDictCache 重置字典缓存数据
|
// SelectDictTypeByID 根据字典类型ID查询信息
|
||||||
ResetDictCache()
|
func (r *SysDictType) SelectDictTypeByID(dictID string) model.SysDictType {
|
||||||
|
if dictID == "" {
|
||||||
// 加载字典缓存数据
|
return model.SysDictType{}
|
||||||
LoadingDictCache(dictType string)
|
}
|
||||||
|
dictTypes := r.sysDictTypeRepository.SelectDictTypeByIDs([]string{dictID})
|
||||||
// 清空字典缓存数据
|
if len(dictTypes) > 0 {
|
||||||
ClearDictCache(dictType string) bool
|
return dictTypes[0]
|
||||||
|
}
|
||||||
// DictDataCache 获取字典数据缓存数据
|
return model.SysDictType{}
|
||||||
DictDataCache(dictType string) []model.SysDictData
|
}
|
||||||
|
|
||||||
|
// SelectDictTypeByType 根据字典类型查询信息
|
||||||
|
func (r *SysDictType) SelectDictTypeByType(dictType string) model.SysDictType {
|
||||||
|
return r.sysDictTypeRepository.SelectDictTypeByType(dictType)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckUniqueDictName 校验字典名称是否唯一
|
||||||
|
func (r *SysDictType) CheckUniqueDictName(dictName, dictID string) bool {
|
||||||
|
uniqueId := r.sysDictTypeRepository.CheckUniqueDictType(model.SysDictType{
|
||||||
|
DictName: dictName,
|
||||||
|
})
|
||||||
|
if uniqueId == dictID {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return uniqueId == ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckUniqueDictType 校验字典类型是否唯一
|
||||||
|
func (r *SysDictType) CheckUniqueDictType(dictType, dictID string) bool {
|
||||||
|
uniqueId := r.sysDictTypeRepository.CheckUniqueDictType(model.SysDictType{
|
||||||
|
DictType: dictType,
|
||||||
|
})
|
||||||
|
if uniqueId == dictID {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return uniqueId == ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// InsertDictType 新增字典类型信息
|
||||||
|
func (r *SysDictType) InsertDictType(sysDictType model.SysDictType) string {
|
||||||
|
insertId := r.sysDictTypeRepository.InsertDictType(sysDictType)
|
||||||
|
if insertId != "" {
|
||||||
|
r.LoadingDictCache(sysDictType.DictType)
|
||||||
|
}
|
||||||
|
return insertId
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateDictType 修改字典类型信息
|
||||||
|
func (r *SysDictType) UpdateDictType(sysDictType model.SysDictType) int64 {
|
||||||
|
data := r.sysDictTypeRepository.SelectDictTypeByIDs([]string{sysDictType.DictID})
|
||||||
|
if len(data) == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
// 修改字典类型key时同步更新其字典数据的类型key
|
||||||
|
oldDictType := data[0].DictType
|
||||||
|
rows := r.sysDictTypeRepository.UpdateDictType(sysDictType)
|
||||||
|
if rows > 0 && oldDictType != "" && oldDictType != sysDictType.DictType {
|
||||||
|
r.sysDictDataRepository.UpdateDictDataType(oldDictType, sysDictType.DictType)
|
||||||
|
}
|
||||||
|
// 刷新缓存
|
||||||
|
r.ClearDictCache(oldDictType)
|
||||||
|
r.LoadingDictCache(sysDictType.DictType)
|
||||||
|
return rows
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteDictTypeByIDs 批量删除字典类型信息
|
||||||
|
func (r *SysDictType) DeleteDictTypeByIDs(dictIDs []string) (int64, error) {
|
||||||
|
// 检查是否存在
|
||||||
|
dictTypes := r.sysDictTypeRepository.SelectDictTypeByIDs(dictIDs)
|
||||||
|
if len(dictTypes) <= 0 {
|
||||||
|
// 没有可访问字典类型数据!
|
||||||
|
return 0, fmt.Errorf("there is no accessible dictionary type data")
|
||||||
|
}
|
||||||
|
for _, v := range dictTypes {
|
||||||
|
// 字典类型下级含有数据
|
||||||
|
useCount := r.sysDictDataRepository.CountDictDataByType(v.DictType)
|
||||||
|
if useCount > 0 {
|
||||||
|
// 【%s】存在字典数据,不能删除
|
||||||
|
return 0, fmt.Errorf("[%s] dictionary data exists and cannot be deleted", v.DictName)
|
||||||
|
}
|
||||||
|
// 清除缓存
|
||||||
|
r.ClearDictCache(v.DictType)
|
||||||
|
}
|
||||||
|
if len(dictTypes) == len(dictIDs) {
|
||||||
|
rows := r.sysDictTypeRepository.DeleteDictTypeByIDs(dictIDs)
|
||||||
|
return rows, nil
|
||||||
|
}
|
||||||
|
// 删除字典数据信息失败!
|
||||||
|
return 0, fmt.Errorf("failed to delete dictionary data information")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetDictCache 重置字典缓存数据
|
||||||
|
func (r *SysDictType) ResetDictCache() {
|
||||||
|
r.ClearDictCache("*")
|
||||||
|
r.LoadingDictCache("")
|
||||||
|
}
|
||||||
|
|
||||||
|
// getCacheKey 组装缓存key
|
||||||
|
func (r *SysDictType) getDictCache(dictType string) string {
|
||||||
|
return cachekey.SYS_DICT_KEY + dictType
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadingDictCache 加载字典缓存数据
|
||||||
|
func (r *SysDictType) LoadingDictCache(dictType string) {
|
||||||
|
sysDictData := model.SysDictData{
|
||||||
|
Status: common.STATUS_YES,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 指定字典类型
|
||||||
|
if dictType != "" {
|
||||||
|
sysDictData.DictType = dictType
|
||||||
|
// 删除缓存
|
||||||
|
key := r.getDictCache(dictType)
|
||||||
|
redis.Del("", key)
|
||||||
|
}
|
||||||
|
|
||||||
|
sysDictDataList := r.sysDictDataRepository.SelectDictDataList(sysDictData)
|
||||||
|
if len(sysDictDataList) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将字典数据按类型分组
|
||||||
|
m := make(map[string][]model.SysDictData, 0)
|
||||||
|
for _, v := range sysDictDataList {
|
||||||
|
key := v.DictType
|
||||||
|
if item, ok := m[key]; ok {
|
||||||
|
m[key] = append(item, v)
|
||||||
|
} else {
|
||||||
|
m[key] = []model.SysDictData{v}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 放入缓存
|
||||||
|
for k, v := range m {
|
||||||
|
key := r.getDictCache(k)
|
||||||
|
values, _ := json.Marshal(v)
|
||||||
|
redis.Set("", key, string(values))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearDictCache 清空字典缓存数据
|
||||||
|
func (r *SysDictType) ClearDictCache(dictType string) bool {
|
||||||
|
key := r.getDictCache(dictType)
|
||||||
|
keys, err := redis.GetKeys("", key)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
delOk, _ := redis.DelKeys("", keys)
|
||||||
|
return delOk
|
||||||
|
}
|
||||||
|
|
||||||
|
// DictDataCache 获取字典数据缓存数据
|
||||||
|
func (r *SysDictType) DictDataCache(dictType string) []model.SysDictData {
|
||||||
|
data := []model.SysDictData{}
|
||||||
|
key := r.getDictCache(dictType)
|
||||||
|
jsonStr, _ := redis.Get("", key)
|
||||||
|
if len(jsonStr) > 7 {
|
||||||
|
err := json.Unmarshal([]byte(jsonStr), &data)
|
||||||
|
if err != nil {
|
||||||
|
data = []model.SysDictData{}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data = r.sysDictDataRepository.SelectDictDataList(model.SysDictData{
|
||||||
|
Status: common.STATUS_YES,
|
||||||
|
DictType: dictType,
|
||||||
|
})
|
||||||
|
if len(data) > 0 {
|
||||||
|
redis.Del("", key)
|
||||||
|
values, _ := json.Marshal(data)
|
||||||
|
redis.Set("", key, string(values))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,212 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"be.ems/src/framework/constants/cachekey"
|
|
||||||
"be.ems/src/framework/constants/common"
|
|
||||||
"be.ems/src/framework/redis"
|
|
||||||
"be.ems/src/modules/system/model"
|
|
||||||
"be.ems/src/modules/system/repository"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 实例化服务层 SysDictTypeImpl 结构体
|
|
||||||
var NewSysDictTypeImpl = &SysDictTypeImpl{
|
|
||||||
sysDictTypeRepository: repository.NewSysDictTypeImpl,
|
|
||||||
sysDictDataRepository: repository.NewSysDictDataImpl,
|
|
||||||
}
|
|
||||||
|
|
||||||
// SysDictTypeImpl 字典类型 服务层处理
|
|
||||||
type SysDictTypeImpl struct {
|
|
||||||
// 字典类型服务
|
|
||||||
sysDictTypeRepository repository.ISysDictType
|
|
||||||
// 字典数据服务
|
|
||||||
sysDictDataRepository repository.ISysDictData
|
|
||||||
}
|
|
||||||
|
|
||||||
// SelectDictTypePage 根据条件分页查询字典类型
|
|
||||||
func (r *SysDictTypeImpl) SelectDictTypePage(query map[string]any) map[string]any {
|
|
||||||
return r.sysDictTypeRepository.SelectDictTypePage(query)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SelectDictTypeList 根据条件查询字典类型
|
|
||||||
func (r *SysDictTypeImpl) SelectDictTypeList(sysDictType model.SysDictType) []model.SysDictType {
|
|
||||||
return r.sysDictTypeRepository.SelectDictTypeList(sysDictType)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SelectDictTypeByID 根据字典类型ID查询信息
|
|
||||||
func (r *SysDictTypeImpl) SelectDictTypeByID(dictID string) model.SysDictType {
|
|
||||||
if dictID == "" {
|
|
||||||
return model.SysDictType{}
|
|
||||||
}
|
|
||||||
dictTypes := r.sysDictTypeRepository.SelectDictTypeByIDs([]string{dictID})
|
|
||||||
if len(dictTypes) > 0 {
|
|
||||||
return dictTypes[0]
|
|
||||||
}
|
|
||||||
return model.SysDictType{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SelectDictTypeByType 根据字典类型查询信息
|
|
||||||
func (r *SysDictTypeImpl) SelectDictTypeByType(dictType string) model.SysDictType {
|
|
||||||
return r.sysDictTypeRepository.SelectDictTypeByType(dictType)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckUniqueDictName 校验字典名称是否唯一
|
|
||||||
func (r *SysDictTypeImpl) CheckUniqueDictName(dictName, dictID string) bool {
|
|
||||||
uniqueId := r.sysDictTypeRepository.CheckUniqueDictType(model.SysDictType{
|
|
||||||
DictName: dictName,
|
|
||||||
})
|
|
||||||
if uniqueId == dictID {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return uniqueId == ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckUniqueDictType 校验字典类型是否唯一
|
|
||||||
func (r *SysDictTypeImpl) CheckUniqueDictType(dictType, dictID string) bool {
|
|
||||||
uniqueId := r.sysDictTypeRepository.CheckUniqueDictType(model.SysDictType{
|
|
||||||
DictType: dictType,
|
|
||||||
})
|
|
||||||
if uniqueId == dictID {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return uniqueId == ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// InsertDictType 新增字典类型信息
|
|
||||||
func (r *SysDictTypeImpl) InsertDictType(sysDictType model.SysDictType) string {
|
|
||||||
insertId := r.sysDictTypeRepository.InsertDictType(sysDictType)
|
|
||||||
if insertId != "" {
|
|
||||||
r.LoadingDictCache(sysDictType.DictType)
|
|
||||||
}
|
|
||||||
return insertId
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateDictType 修改字典类型信息
|
|
||||||
func (r *SysDictTypeImpl) UpdateDictType(sysDictType model.SysDictType) int64 {
|
|
||||||
data := r.sysDictTypeRepository.SelectDictTypeByIDs([]string{sysDictType.DictID})
|
|
||||||
if len(data) == 0 {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
// 修改字典类型key时同步更新其字典数据的类型key
|
|
||||||
oldDictType := data[0].DictType
|
|
||||||
rows := r.sysDictTypeRepository.UpdateDictType(sysDictType)
|
|
||||||
if rows > 0 && oldDictType != "" && oldDictType != sysDictType.DictType {
|
|
||||||
r.sysDictDataRepository.UpdateDictDataType(oldDictType, sysDictType.DictType)
|
|
||||||
}
|
|
||||||
// 刷新缓存
|
|
||||||
r.ClearDictCache(oldDictType)
|
|
||||||
r.LoadingDictCache(sysDictType.DictType)
|
|
||||||
return rows
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteDictTypeByIDs 批量删除字典类型信息
|
|
||||||
func (r *SysDictTypeImpl) DeleteDictTypeByIDs(dictIDs []string) (int64, error) {
|
|
||||||
// 检查是否存在
|
|
||||||
dictTypes := r.sysDictTypeRepository.SelectDictTypeByIDs(dictIDs)
|
|
||||||
if len(dictTypes) <= 0 {
|
|
||||||
// 没有可访问字典类型数据!
|
|
||||||
return 0, fmt.Errorf("there is no accessible dictionary type data")
|
|
||||||
}
|
|
||||||
for _, v := range dictTypes {
|
|
||||||
// 字典类型下级含有数据
|
|
||||||
useCount := r.sysDictDataRepository.CountDictDataByType(v.DictType)
|
|
||||||
if useCount > 0 {
|
|
||||||
// 【%s】存在字典数据,不能删除
|
|
||||||
return 0, fmt.Errorf("[%s] dictionary data exists and cannot be deleted", v.DictName)
|
|
||||||
}
|
|
||||||
// 清除缓存
|
|
||||||
r.ClearDictCache(v.DictType)
|
|
||||||
}
|
|
||||||
if len(dictTypes) == len(dictIDs) {
|
|
||||||
rows := r.sysDictTypeRepository.DeleteDictTypeByIDs(dictIDs)
|
|
||||||
return rows, nil
|
|
||||||
}
|
|
||||||
// 删除字典数据信息失败!
|
|
||||||
return 0, fmt.Errorf("failed to delete dictionary data information")
|
|
||||||
}
|
|
||||||
|
|
||||||
// ResetDictCache 重置字典缓存数据
|
|
||||||
func (r *SysDictTypeImpl) ResetDictCache() {
|
|
||||||
r.ClearDictCache("*")
|
|
||||||
r.LoadingDictCache("")
|
|
||||||
}
|
|
||||||
|
|
||||||
// getCacheKey 组装缓存key
|
|
||||||
func (r *SysDictTypeImpl) getDictCache(dictType string) string {
|
|
||||||
return cachekey.SYS_DICT_KEY + dictType
|
|
||||||
}
|
|
||||||
|
|
||||||
// LoadingDictCache 加载字典缓存数据
|
|
||||||
func (r *SysDictTypeImpl) LoadingDictCache(dictType string) {
|
|
||||||
sysDictData := model.SysDictData{
|
|
||||||
Status: common.STATUS_YES,
|
|
||||||
}
|
|
||||||
|
|
||||||
// 指定字典类型
|
|
||||||
if dictType != "" {
|
|
||||||
sysDictData.DictType = dictType
|
|
||||||
// 删除缓存
|
|
||||||
key := r.getDictCache(dictType)
|
|
||||||
redis.Del("", key)
|
|
||||||
}
|
|
||||||
|
|
||||||
sysDictDataList := r.sysDictDataRepository.SelectDictDataList(sysDictData)
|
|
||||||
if len(sysDictDataList) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 将字典数据按类型分组
|
|
||||||
m := make(map[string][]model.SysDictData, 0)
|
|
||||||
for _, v := range sysDictDataList {
|
|
||||||
key := v.DictType
|
|
||||||
if item, ok := m[key]; ok {
|
|
||||||
m[key] = append(item, v)
|
|
||||||
} else {
|
|
||||||
m[key] = []model.SysDictData{v}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 放入缓存
|
|
||||||
for k, v := range m {
|
|
||||||
key := r.getDictCache(k)
|
|
||||||
values, _ := json.Marshal(v)
|
|
||||||
redis.Set("", key, string(values))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearDictCache 清空字典缓存数据
|
|
||||||
func (r *SysDictTypeImpl) ClearDictCache(dictType string) bool {
|
|
||||||
key := r.getDictCache(dictType)
|
|
||||||
keys, err := redis.GetKeys("", key)
|
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
delOk, _ := redis.DelKeys("", keys)
|
|
||||||
return delOk
|
|
||||||
}
|
|
||||||
|
|
||||||
// DictDataCache 获取字典数据缓存数据
|
|
||||||
func (r *SysDictTypeImpl) DictDataCache(dictType string) []model.SysDictData {
|
|
||||||
data := []model.SysDictData{}
|
|
||||||
key := r.getDictCache(dictType)
|
|
||||||
jsonStr, _ := redis.Get("", key)
|
|
||||||
if len(jsonStr) > 7 {
|
|
||||||
err := json.Unmarshal([]byte(jsonStr), &data)
|
|
||||||
if err != nil {
|
|
||||||
data = []model.SysDictData{}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
data = r.sysDictDataRepository.SelectDictDataList(model.SysDictData{
|
|
||||||
Status: common.STATUS_YES,
|
|
||||||
DictType: dictType,
|
|
||||||
})
|
|
||||||
if len(data) > 0 {
|
|
||||||
redis.Del("", key)
|
|
||||||
values, _ := json.Marshal(data)
|
|
||||||
redis.Set("", key, string(values))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
@@ -439,5 +439,5 @@ func InitLoad() {
|
|||||||
// 启动时,刷新缓存-参数配置
|
// 启动时,刷新缓存-参数配置
|
||||||
service.NewSysConfigImpl.ResetConfigCache()
|
service.NewSysConfigImpl.ResetConfigCache()
|
||||||
// 启动时,刷新缓存-字典类型数据
|
// 启动时,刷新缓存-字典类型数据
|
||||||
service.NewSysDictTypeImpl.ResetDictCache()
|
service.NewSysDictType.ResetDictCache()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,6 +81,28 @@ func (s *PingController) StatisticsOn(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ping 网元端版本信息
|
||||||
|
//
|
||||||
|
// GET /v
|
||||||
|
func (s *PingController) Version(c *gin.Context) {
|
||||||
|
language := ctx.AcceptLanguage(c)
|
||||||
|
var query struct {
|
||||||
|
NeType string `form:"neType" binding:"required"` // 网元类型
|
||||||
|
NeID string `form:"neId" binding:"required"` // 网元ID
|
||||||
|
}
|
||||||
|
if err := c.ShouldBindQuery(&query); err != nil {
|
||||||
|
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
output, err := s.pingService.Version(query.NeType, query.NeID)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(200, result.ErrMsg(i18n.TKey(language, err.Error())))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(200, result.OkData(output))
|
||||||
|
}
|
||||||
|
|
||||||
// ping 网元端UNIX运行
|
// ping 网元端UNIX运行
|
||||||
//
|
//
|
||||||
// GET /run
|
// GET /run
|
||||||
@@ -128,7 +150,7 @@ func (s *PingController) Run(c *gin.Context) {
|
|||||||
|
|
||||||
wsClient := s.wsService.ClientCreate(loginUser.UserID, nil, wsConn, clientSession)
|
wsClient := s.wsService.ClientCreate(loginUser.UserID, nil, wsConn, clientSession)
|
||||||
go s.wsService.ClientWriteListen(wsClient)
|
go s.wsService.ClientWriteListen(wsClient)
|
||||||
go s.wsService.ClientReadListen(wsClient, s.pingService.RunNE)
|
go s.wsService.ClientReadListen(wsClient, s.pingService.Run)
|
||||||
|
|
||||||
// 等待1秒,排空首次消息
|
// 等待1秒,排空首次消息
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|||||||
@@ -23,15 +23,8 @@ type IPerf struct{}
|
|||||||
|
|
||||||
// Version 查询版本信息
|
// Version 查询版本信息
|
||||||
func (s *IPerf) Version(meType, neId string) (string, error) {
|
func (s *IPerf) Version(meType, neId string) (string, error) {
|
||||||
// 网元主机的SSH客户端
|
|
||||||
sshClient, err := neService.NewNeInfo.NeRunSSHClient(meType, neId)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
defer sshClient.Close()
|
|
||||||
|
|
||||||
// 检查是否安装iperf3
|
// 检查是否安装iperf3
|
||||||
output, err := sshClient.RunCMD("iperf3 --version")
|
output, err := neService.NewNeInfo.NeRunSSHCmd(meType, neId, "iperf3 --version")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("iperf3 not installed")
|
return "", fmt.Errorf("iperf3 not installed")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"be.ems/src/framework/logger"
|
"be.ems/src/framework/logger"
|
||||||
"be.ems/src/framework/utils/ssh"
|
"be.ems/src/framework/utils/ssh"
|
||||||
"be.ems/src/framework/vo/result"
|
"be.ems/src/framework/vo/result"
|
||||||
|
neService "be.ems/src/modules/network_element/service"
|
||||||
"be.ems/src/modules/tool/model"
|
"be.ems/src/modules/tool/model"
|
||||||
wsModel "be.ems/src/modules/ws/model"
|
wsModel "be.ems/src/modules/ws/model"
|
||||||
probing "github.com/prometheus-community/pro-bing"
|
probing "github.com/prometheus-community/pro-bing"
|
||||||
@@ -134,8 +135,18 @@ func (s *Ping) StatisticsOn(client *wsModel.WSClient, reqMsg wsModel.WSRequest)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunNE 接收ping终端交互业务处理
|
// Version 查询版本信息
|
||||||
func (s *Ping) RunNE(client *wsModel.WSClient, reqMsg wsModel.WSRequest) {
|
func (s *Ping) Version(meType, neId string) (string, error) {
|
||||||
|
// 检查是否安装ping
|
||||||
|
output, err := neService.NewNeInfo.NeRunSSHCmd(meType, neId, "ping -V")
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("ping not installed")
|
||||||
|
}
|
||||||
|
return strings.TrimSpace(output), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run 接收ping终端交互业务处理
|
||||||
|
func (s *Ping) Run(client *wsModel.WSClient, reqMsg wsModel.WSRequest) {
|
||||||
// 必传requestId确认消息
|
// 必传requestId确认消息
|
||||||
if reqMsg.RequestID == "" {
|
if reqMsg.RequestID == "" {
|
||||||
msg := "message requestId is required"
|
msg := "message requestId is required"
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ func Setup(router *gin.Engine) {
|
|||||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.ping", collectlogs.BUSINESS_TYPE_OTHER)),
|
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.ping", collectlogs.BUSINESS_TYPE_OTHER)),
|
||||||
controller.NewPing.StatisticsOn,
|
controller.NewPing.StatisticsOn,
|
||||||
)
|
)
|
||||||
|
pingGroup.GET("/v",
|
||||||
|
middleware.PreAuthorize(nil),
|
||||||
|
controller.NewPing.Version,
|
||||||
|
)
|
||||||
pingGroup.GET("/run",
|
pingGroup.GET("/run",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.ping", collectlogs.BUSINESS_TYPE_OTHER)),
|
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.ping", collectlogs.BUSINESS_TYPE_OTHER)),
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
"be.ems/src/framework/i18n"
|
"be.ems/src/framework/i18n"
|
||||||
"be.ems/src/framework/utils/ctx"
|
"be.ems/src/framework/utils/ctx"
|
||||||
"be.ems/src/framework/vo/result"
|
"be.ems/src/framework/vo/result"
|
||||||
@@ -67,42 +64,12 @@ func (s *TCPdumpController) DumpStop(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
taskLog, err := s.tcpdumpService.DumpStop(body.NeType, body.NeId, body.TaskCode)
|
logFiles, err := s.tcpdumpService.DumpStop(body.NeType, body.NeId, body.TaskCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, err.Error())))
|
c.JSON(200, result.ErrMsg(i18n.TKey(language, err.Error())))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(200, result.OkMsg(taskLog))
|
c.JSON(200, result.OkData(logFiles))
|
||||||
}
|
|
||||||
|
|
||||||
// 网元抓包PACP 下载
|
|
||||||
//
|
|
||||||
// GET /download
|
|
||||||
func (s *TCPdumpController) DumpDownload(c *gin.Context) {
|
|
||||||
language := ctx.AcceptLanguage(c)
|
|
||||||
var query struct {
|
|
||||||
NeType string `form:"neType" binding:"required"` // 网元类型
|
|
||||||
NeID string `form:"neId" binding:"required"` // 网元ID
|
|
||||||
TaskCode string `form:"taskCode" binding:"required"` // 任务码,停止任务并查看日志信息
|
|
||||||
DelTemp bool `form:"delTemp"` // 完成后是否删除本地临时zip文件
|
|
||||||
}
|
|
||||||
if err := c.ShouldBindQuery(&query); err != nil {
|
|
||||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
zipFilePath, err := s.tcpdumpService.DumpDownload(query.NeType, query.NeID, query.TaskCode)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, err.Error())))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
defer func() {
|
|
||||||
if query.DelTemp {
|
|
||||||
_ = os.Remove(zipFilePath)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
c.FileAttachment(zipFilePath, filepath.Base(zipFilePath))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UPF标准版内部抓包
|
// UPF标准版内部抓包
|
||||||
|
|||||||
@@ -2,16 +2,13 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"be.ems/src/framework/logger"
|
"be.ems/src/framework/logger"
|
||||||
"be.ems/src/framework/utils/file"
|
|
||||||
"be.ems/src/framework/utils/ssh"
|
"be.ems/src/framework/utils/ssh"
|
||||||
neService "be.ems/src/modules/network_element/service"
|
neService "be.ems/src/modules/network_element/service"
|
||||||
)
|
)
|
||||||
@@ -97,16 +94,16 @@ func (s *TCPdump) DumpStart(neType, neId, cmdStr string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DumpStop 停止已存在抓包句柄
|
// DumpStop 停止已存在抓包句柄
|
||||||
func (s *TCPdump) DumpStop(neType, neId, taskCode string) (string, error) {
|
func (s *TCPdump) DumpStop(neType, neId, taskCode string) ([]string, error) {
|
||||||
// 查询网元获取IP
|
// 查询网元获取IP
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(neType, neId)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(neType, neId)
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
if neInfo.NeId != neId || neInfo.IP == "" {
|
||||||
return "", fmt.Errorf("app.common.noNEInfo")
|
return []string{}, fmt.Errorf("app.common.noNEInfo")
|
||||||
}
|
}
|
||||||
// 网元主机的SSH客户端
|
// 网元主机的SSH客户端
|
||||||
sshClient, err := s.neInfoService.NeRunSSHClient(neInfo.NeType, neInfo.NeId)
|
sshClient, err := s.neInfoService.NeRunSSHClient(neInfo.NeType, neInfo.NeId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return []string{}, err
|
||||||
}
|
}
|
||||||
defer sshClient.Close()
|
defer sshClient.Close()
|
||||||
|
|
||||||
@@ -114,26 +111,28 @@ func (s *TCPdump) DumpStop(neType, neId, taskCode string) (string, error) {
|
|||||||
pidKey := fmt.Sprintf("%s_%s_%s", strings.ToLower(neInfo.NeType), neInfo.NeId, taskCode)
|
pidKey := fmt.Sprintf("%s_%s_%s", strings.ToLower(neInfo.NeType), neInfo.NeId, taskCode)
|
||||||
PIDMap, ok := dumpPIDMap.Load(pidKey)
|
PIDMap, ok := dumpPIDMap.Load(pidKey)
|
||||||
if !ok || PIDMap == nil {
|
if !ok || PIDMap == nil {
|
||||||
return "", fmt.Errorf("tcpdump is not running")
|
return []string{}, fmt.Errorf("tcpdump is not running")
|
||||||
}
|
}
|
||||||
pid, ok := PIDMap.(map[string]string)["pid"]
|
pid, ok := PIDMap.(map[string]string)["pid"]
|
||||||
if !ok || pid == "" {
|
if !ok || pid == "" {
|
||||||
return "", fmt.Errorf("tcpdump is not running")
|
return []string{}, fmt.Errorf("tcpdump is not running")
|
||||||
}
|
}
|
||||||
|
s.logFileLastLineToFile(PIDMap.(map[string]string), sshClient)
|
||||||
|
|
||||||
// 存放文件目录 /tmp/omc/tcpdump/udm/001/20240817104241
|
// 存放文件目录 /tmp/omc/tcpdump/udm/001/20240817104241
|
||||||
neDirTemp := fmt.Sprintf("/tmp/omc/tcpdump/%s/%s/%s", strings.ToLower(neInfo.NeType), neInfo.NeId, taskCode)
|
neDirTemp := fmt.Sprintf("/tmp/omc/tcpdump/%s/%s/%s", strings.ToLower(neInfo.NeType), neInfo.NeId, taskCode)
|
||||||
// 命令拼装
|
// 命令拼装
|
||||||
sendCmd := fmt.Sprintf("pids=$(pgrep -P %s) && [ -n \"$pids\" ] && sudo kill $pids;sudo timeout 2s cat %s/tcpdump.log", pid, neDirTemp)
|
sendCmd := fmt.Sprintf("pids=$(pgrep -P %s) && [ -n \"$pids\" ] && sudo kill $pids;sudo timeout 2s ls %s", pid, neDirTemp)
|
||||||
// pids=$(pgrep -P 1914341) && [ -n "$pids" ] && sudo kill $pids;sudo timeout 2s cat tcpdump.log
|
// pids=$(pgrep -P 1914341) && [ -n "$pids" ] && sudo kill $pids;sudo timeout 2s ls /tmp/omc/tcpdump/udm/001/20240817104241
|
||||||
output, err := sshClient.RunCMD(sendCmd)
|
output, err := sshClient.RunCMD(sendCmd)
|
||||||
if err != nil || strings.HasPrefix(output, "stderr:") {
|
output = strings.TrimSpace(output)
|
||||||
logger.Errorf("DumpStop err: %s => %s", strings.TrimSpace(output), err.Error())
|
if err != nil || strings.HasPrefix(output, "ls: ") {
|
||||||
return "", err
|
logger.Errorf("DumpStop err: %s => %s", output, err.Error())
|
||||||
|
return []string{}, err
|
||||||
}
|
}
|
||||||
|
files := strings.Split(output, "\n")
|
||||||
s.logFileLastLineToFile(PIDMap.(map[string]string), sshClient)
|
|
||||||
dumpPIDMap.Delete(pidKey)
|
dumpPIDMap.Delete(pidKey)
|
||||||
return output, nil
|
return files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// logFileLastLine 日志文件最后行号
|
// logFileLastLine 日志文件最后行号
|
||||||
@@ -207,53 +206,6 @@ func (s *TCPdump) logFileLastLineToFile(PIDMap map[string]string, sshClient *ssh
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DumpDownload 抓包文件网元端复制到本地输出zip文件
|
|
||||||
func (s *TCPdump) DumpDownload(neType, neId, taskCode string) (string, error) {
|
|
||||||
// 查询网元获取IP
|
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(neType, neId)
|
|
||||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
|
||||||
return "", fmt.Errorf("app.common.noNEInfo")
|
|
||||||
}
|
|
||||||
// 网元主机的SSH客户端
|
|
||||||
sshClient, err := s.neInfoService.NeRunSSHClient(neInfo.NeType, neInfo.NeId)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
defer sshClient.Close()
|
|
||||||
// 网元主机的SSH客户端进行文件传输
|
|
||||||
sftpClient, err := sshClient.NewClientSFTP()
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("ne info sftp client err")
|
|
||||||
}
|
|
||||||
defer sftpClient.Close()
|
|
||||||
|
|
||||||
neTypeLower := strings.ToLower(neInfo.NeType)
|
|
||||||
// 网管本地路径
|
|
||||||
localDirPath := fmt.Sprintf("/tmp/omc/tcpdump/zip/%s/%s", neTypeLower, neInfo.NeId)
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
localDirPath = fmt.Sprintf("C:%s", localDirPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 网元pcap目录 /tmp/omc/tcpdump/udm/001/20240817104241
|
|
||||||
sshClient.RunCMD("mkdir -p /tmp/omc && sudo chmod 777 -R /tmp/omc")
|
|
||||||
neDirTemp := fmt.Sprintf("/tmp/omc/tcpdump/%s/%s/%s", neTypeLower, neInfo.NeId, taskCode)
|
|
||||||
// 网元端复制到本地
|
|
||||||
localDirFilePath := filepath.Join(localDirPath, taskCode)
|
|
||||||
if err = sftpClient.CopyDirRemoteToLocal(neDirTemp, localDirFilePath); err != nil {
|
|
||||||
return "", fmt.Errorf("copy tcpdump file err")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 压缩zip文件名
|
|
||||||
zipFileName := fmt.Sprintf("%s-%s-pcap-%s.zip", neTypeLower, neInfo.NeId, taskCode)
|
|
||||||
zipFilePath := filepath.Join(localDirPath, zipFileName)
|
|
||||||
if err := file.CompressZipByDir(zipFilePath, localDirFilePath); err != nil {
|
|
||||||
return "", fmt.Errorf("compress zip err")
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = os.RemoveAll(localDirFilePath) // 删除本地临时目录
|
|
||||||
return zipFilePath, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UPFTrace UPF标准版内部抓包
|
// UPFTrace UPF标准版内部抓包
|
||||||
func (s *TCPdump) UPFTrace(neType, neId, cmdStr string) (string, error) {
|
func (s *TCPdump) UPFTrace(neType, neId, cmdStr string) (string, error) {
|
||||||
// 命令检查
|
// 命令检查
|
||||||
|
|||||||
@@ -60,12 +60,17 @@ func (r *TraceTask) CreateUDP() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 接收处理UDP数据
|
// 接收处理UDP数据
|
||||||
go r.udpService.Resolve(func(conn *net.UDPConn) {
|
go r.udpService.Resolve(func(conn *net.UDPConn, err error) {
|
||||||
|
if err != nil {
|
||||||
|
logger.Errorf("UDP Resolve %s", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 读取数据
|
// 读取数据
|
||||||
buf := make([]byte, 2048)
|
buf := make([]byte, 2048)
|
||||||
n, err := conn.Read(buf)
|
n, addr, err := conn.ReadFromUDPAddrPort(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("error reading from UDP connection: %s", err.Error())
|
logger.Errorf("UDP Resolve ReadFromUDPAddrPort Error: %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +78,7 @@ func (r *TraceTask) CreateUDP() error {
|
|||||||
// logger.Infof("socket UDP Base64: %s", base64.StdEncoding.EncodeToString(buf[:n]))
|
// logger.Infof("socket UDP Base64: %s", base64.StdEncoding.EncodeToString(buf[:n]))
|
||||||
mData, err := UDPDataHandler(buf, n)
|
mData, err := UDPDataHandler(buf, n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("udp resolve data fail: %s", err.Error())
|
logger.Errorf("UDP Resolve UDPDataHandler Error: %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
taskId := parse.Number(mData["taskId"])
|
taskId := parse.Number(mData["taskId"])
|
||||||
@@ -98,6 +103,11 @@ func (r *TraceTask) CreateUDP() error {
|
|||||||
logger.Infof("pcapFile: %s", v)
|
logger.Infof("pcapFile: %s", v)
|
||||||
wsService.NewWSSend.ByGroupID(fmt.Sprintf("%s%d", wsService.GROUP_TRACE_NE, taskId), taskId)
|
wsService.NewWSSend.ByGroupID(fmt.Sprintf("%s%d", wsService.GROUP_TRACE_NE, taskId), taskId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 发送响应
|
||||||
|
if _, err := conn.WriteToUDPAddrPort([]byte("udp>"), addr); err != nil {
|
||||||
|
logger.Errorf("UDP Resolve WriteToUDPAddrPort Error: %s", err.Error())
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// ============ 测试接收网元UDP发过来的数据
|
// ============ 测试接收网元UDP发过来的数据
|
||||||
@@ -107,13 +117,18 @@ func (r *TraceTask) CreateUDP() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// 接收处理TCP数据
|
// 接收处理TCP数据
|
||||||
go tcpService.Resolve(func(conn *net.Conn) {
|
go tcpService.Resolve(func(conn *net.Conn, err error) {
|
||||||
|
if err != nil {
|
||||||
|
logger.Errorf("TCP Resolve %s", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
c := (*conn)
|
c := (*conn)
|
||||||
// 读取数据
|
// 读取数据
|
||||||
buf := make([]byte, 2048)
|
buf := make([]byte, 2048)
|
||||||
n, err := c.Read(buf)
|
n, err := c.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("error reading from TCP connection: %s", err.Error())
|
logger.Errorf("TCP Resolve Read Error: %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +137,7 @@ func (r *TraceTask) CreateUDP() error {
|
|||||||
logger.Infof("socket TCP Base64: %s", deData)
|
logger.Infof("socket TCP Base64: %s", deData)
|
||||||
mData, err := UDPDataHandler(deData, len(deData))
|
mData, err := UDPDataHandler(deData, len(deData))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("tcp resolve data fail: %s", err.Error())
|
logger.Errorf("TCP Resolve UDPDataHandler Error: %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
taskId := parse.Number(mData["taskId"])
|
taskId := parse.Number(mData["taskId"])
|
||||||
@@ -147,6 +162,11 @@ func (r *TraceTask) CreateUDP() error {
|
|||||||
logger.Infof("pcapFile: %s", v)
|
logger.Infof("pcapFile: %s", v)
|
||||||
wsService.NewWSSend.ByGroupID(fmt.Sprintf("%s%d", wsService.GROUP_TRACE_NE, taskId), taskId)
|
wsService.NewWSSend.ByGroupID(fmt.Sprintf("%s%d", wsService.GROUP_TRACE_NE, taskId), taskId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 发送响应
|
||||||
|
if _, err = c.Write([]byte("tcp>")); err != nil {
|
||||||
|
logger.Errorf("TCP Resolve Write Error: %s", err.Error())
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,10 +30,6 @@ func Setup(router *gin.Engine) {
|
|||||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.tcpdump", collectlogs.BUSINESS_TYPE_OTHER)),
|
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.tcpdump", collectlogs.BUSINESS_TYPE_OTHER)),
|
||||||
controller.NewTCPdump.DumpStop,
|
controller.NewTCPdump.DumpStop,
|
||||||
)
|
)
|
||||||
tcpdumpGroup.GET("/download",
|
|
||||||
middleware.PreAuthorize(nil),
|
|
||||||
controller.NewTCPdump.DumpDownload,
|
|
||||||
)
|
|
||||||
tcpdumpGroup.POST("/upf",
|
tcpdumpGroup.POST("/upf",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.tcpdump", collectlogs.BUSINESS_TYPE_OTHER)),
|
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.tcpdump", collectlogs.BUSINESS_TYPE_OTHER)),
|
||||||
|
|||||||
Reference in New Issue
Block a user