Răsfoiți Sursa

20230717-新增表结构、测试数据

iaun 3 ani în urmă
părinte
comite
6ce471b2a6
2 a modificat fișierele cu 128 adăugiri și 8 ștergeri
  1. 69 1
      src/main/resources/db/data.sql
  2. 59 7
      src/main/resources/db/schema.sql

+ 69 - 1
src/main/resources/db/data.sql

@@ -49,4 +49,72 @@ values (1, 1),
        (3, 2),
        (3, 2),
        (3, 3),
        (3, 3),
        (3, 4)
        (3, 4)
-;
+;
+
+delete
+from `it_resource_group`;
+insert into `it_resource_group` (group_id, group_name)
+values (1, '服务器'),
+       (2, '交换机'),
+       (3, '存储')
+;
+
+delete
+from `it_resource_attribute`;
+insert into `it_resource_attribute`
+(attribute_id, group_id, attribute_name, display_name, attribute_type, value_type, default_value, options)
+values (1, 1, 'name', '服务器名称', 0, 0, null, null),
+       (2, 1, 'model', '型号', 0, 0, null, null),
+       (3, 1, 'location', '服务器位置', 0, 0, null, null),
+       (4, 1, 'hostname', '主机名', 0, 0, null, null),
+       (5, 1, 'cpu', 'CPU型号', 0, 0, null, null),
+       (6, 1, 'cpu_cores', 'CPU核心数量', 0, 1, null, null),
+       (7, 1, 'memory', '内存大小(GB)', 0, 1, null, null),
+       (9, 2, 'name', '交换机名称', 0, 0, null, null),
+       (10, 2, 'model', '交换机型号', 0, 0, null, null),
+       (11, 2, 'port', '端口', 1, null, null, null),
+       (12, 3, 'name', '存储名称', 0, 0, null, null),
+       (13, 3, 'company', '厂商', 2, null, null, 'DELL,HP,HUAWEI'),
+       (14, 3, 'expire', '是否过保', 2, null, '否', '是,否'),
+       (15, 3, 'disk', '磁盘', 1, null, null, null)
+;
+
+delete
+from `it_resource_type`;
+insert into `it_resource_type` (type_id, type_name, parent_type_id)
+values (1, '基础设备', null),
+       (2, '服务器', 1),
+       (3, '交换机', 1),
+       (4, '存储设备', null),
+       (5, '分布式存储', 4)
+;
+
+delete
+from `it_resource`;
+insert into `it_resource` (resource_id, resource_name, type_id, group_id, remark)
+values (1, '服务器001', 2, 1, ''),
+       (2, '服务器002', 2, 1, ''),
+       (3, '服务器003', 2, 1, ''),
+       (4, '交换机001', 3, 2, '全万兆交换机'),
+       (5, '存储001', 5, 3, '1P'),
+       (6, '存储002', 5, 3, '18T')
+;
+
+delete
+from `it_resource_value`;
+insert into `it_resource_value` (resource_id, attribute_id, attribute_value)
+values (1, 1, '服务器111'),
+       (1, 2, 'HP'),
+       (1, 3, '北京'),
+       (1, 4, 'server-001'),
+       (2, 1, '服务器222'),
+       (2, 2, 'DELL'),
+       (2, 3, '北京'),
+       (2, 4, 'server-002'),
+       (2, 5, 'Intel'),
+       (3, 9, '交换机111'),
+       (3, 10, 'HUAWEI'),
+       (3, 11, '{"head":["端口","可用"],"data":[["COM1","是"],["COM2","否"]]}'),
+       (3, 12, '存储111'),
+       (3, 13, 'H3C')
+;

+ 59 - 7
src/main/resources/db/schema.sql

@@ -10,11 +10,10 @@ CREATE TABLE `it_user`
     PRIMARY KEY (`user_id`)
     PRIMARY KEY (`user_id`)
 ) COMMENT ='用户表';
 ) COMMENT ='用户表';
 
 
-
 drop table if exists it_role;
 drop table if exists it_role;
 CREATE TABLE `it_role`
 CREATE TABLE `it_role`
 (
 (
-    `role_id` BIGINT(20)   NOT NULL COMMENT '角色ID',
+    `role_id` BIGINT(20)   NOT NULL AUTO_INCREMENT COMMENT '角色ID',
     `name`    VARCHAR(255) NOT NULL COMMENT '角色名称',
     `name`    VARCHAR(255) NOT NULL COMMENT '角色名称',
     PRIMARY KEY (`role_id`)
     PRIMARY KEY (`role_id`)
 ) COMMENT ='角色表';
 ) COMMENT ='角色表';
@@ -22,15 +21,68 @@ CREATE TABLE `it_role`
 drop table if exists it_sys;
 drop table if exists it_sys;
 CREATE TABLE `it_sys`
 CREATE TABLE `it_sys`
 (
 (
-    `sys_id` BIGINT(20)   NOT NULL COMMENT '系统ID',
-    `name`   VARCHAR(255) NULL DEFAULT NULL COMMENT '系统名称',
-    PRIMARY KEY (`sys_id`) USING BTREE
+    `sys_id` BIGINT(20)   NOT NULL AUTO_INCREMENT COMMENT '系统ID',
+    `name`   VARCHAR(255) NOT NULL COMMENT '系统名称',
+    PRIMARY KEY (`sys_id`)
 ) COMMENT ='系统表';
 ) COMMENT ='系统表';
 
 
 drop table if exists it_role_permission;
 drop table if exists it_role_permission;
 CREATE TABLE `it_role_permission`
 CREATE TABLE `it_role_permission`
 (
 (
-    `role_id` BIGINT(20) NOT NULL COMMENT '角色ID',
+    `role_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '角色ID',
     `sys_id`  BIGINT(20) NOT NULL COMMENT '系统ID',
     `sys_id`  BIGINT(20) NOT NULL COMMENT '系统ID',
     PRIMARY KEY (`role_id`, `sys_id`)
     PRIMARY KEY (`role_id`, `sys_id`)
-) COMMENT ='角色权限表';
+) COMMENT ='角色权限表';
+
+drop table if exists it_resource_group;
+create table `it_resource_group`
+(
+    `group_id`   bigint(20)   not null AUTO_INCREMENT comment '资源组ID',
+    `group_name` varchar(255) not null comment '资源组名称',
+    primary key (`group_id`)
+) comment ='资源组';
+
+
+drop table if exists it_resource_attribute;
+create table `it_resource_attribute`
+(
+    `attribute_id`   bigint(20)   not null AUTO_INCREMENT comment '属性ID',
+    `group_id`       bigint(20)   not null comment '资源组ID',
+    `attribute_name` varchar(255) not null comment '属性名称',
+    `display_name`   varchar(255) not null comment '显示名称',
+    `attribute_type` tinyint      not null comment '资源属性类型:0普通(文本、数字等),1表格,2下拉选项',
+    `value_type`     tinyint      null default 0 comment '值类型;仅属性类型=0有效:0文本,1数字',
+    `default_value`  varchar(255) null default '' comment '默认值;仅属性类型=0或2有效',
+    `options`        varchar(255) null default null comment '下拉选项;仅属性类型=2有效',
+    primary key (`attribute_id`)
+) comment ='资源属性';
+
+drop table if exists it_resource_type;
+create table `it_resource_type`
+(
+    `type_id`        bigint(20)   not null auto_increment comment '资源类型ID',
+    `type_name`      varchar(255) not null comment '资源名称',
+    `parent_type_id` bigint(20)   null default null comment '父类型ID',
+    primary key (`type_id`)
+) comment ='资源类型';
+
+
+drop table if exists it_resource;
+create table `it_resource`
+(
+    `resource_id`   bigint(20)   not null auto_increment comment '资源ID',
+    `resource_name` varchar(255) not null comment '资源名称',
+    `type_id`       bigint(20)   not null comment '资源类型ID',
+    `group_id`      bigint(20)   not null comment '资源组ID',
+    `remark`        varchar(255) not null default '' comment '资源备注',
+    primary key (`resource_id`)
+) comment ='资源';
+
+drop table if exists it_resource_value;
+create table `it_resource_value`
+(
+    `resource_id`     bigint(20) not null comment '资源ID',
+    `attribute_id`    bigint(20) not null comment '属性ID',
+    `attribute_value` text       not null comment '资源属性的值',
+    primary key (`resource_id`, `attribute_id`)
+) comment ='资源属性的值';