insert into dictionary(name, value, pvalue)
select '防火墙', 'FIREWALL', '0'
from dictionary
where not exists(select value from dictionary where value = 'FIREWALL')
limit 0, 1;
insert into dictionary(name, value, pvalue)
select '山石防火墙', 'HILLSTONE', 'FIREWALL'
from dictionary
where not exists(select value from dictionary where value = 'HILLSTONE')
limit 0, 1;

DROP TABLE IF EXISTS `hillstone_address_book`;
CREATE TABLE `hillstone_address_book`
(
    `id`          bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`   bigint       DEFAULT NULL COMMENT '平台id',
    `name`        varchar(100) DEFAULT NULL COMMENT '名称',
    `description` text         DEFAULT NULL COMMENT '描述',
    `type`        int          DEFAULT NULL COMMENT '类型，页面上暂未展示，当前都是0',
    `is_ipv6`     tinyint      DEFAULT NULL COMMENT '是否ipv6，页面上暂未展示，当前都是false',
    `ip_masks`    text         DEFAULT NULL COMMENT 'ip掩码，格式：JSON，包含字段：flag：0该成员为被包含的地址成员 1该成员为被排除的地址成员，ip：ip地址，mask：子网掩码',
    `ip_unmasks`  text         DEFAULT NULL COMMENT 'ip反掩码，格式：JSON，包含字段：ip：ip地址，mask：反掩码',
    `ip_ranges`   text         DEFAULT NULL COMMENT 'ip范围，格式：JSON，包含字段：flag：0该成员为被包含的地址成员 1该成员为被排除的地址成员，min：起始ip地址，max：结束ip地址',
    `host_json`   text         DEFAULT NULL COMMENT '主机名称，格式：JSON',
    PRIMARY KEY (`id`)
) COMMENT '地址本' ENGINE = InnoDB
                DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_black_ip`;
CREATE TABLE `hillstone_black_ip`
(
    `id`                bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`         bigint      DEFAULT NULL COMMENT '平台id',
    `virtual_router_id` bigint      DEFAULT NULL COMMENT '所属虚拟路由器id',
    `ip`                char(12)    DEFAULT NULL COMMENT 'ip地址',
    `age`               int         DEFAULT NULL COMMENT '剩余阻断时长，该字段会随着时间变化而变化，60-3600秒',
    `reason`            varchar(20) DEFAULT NULL COMMENT '加入原因： Manual 手工加入 其他可取值暂时未知',
    PRIMARY KEY (`id`)
) COMMENT 'IP黑名单' ENGINE = InnoDB
                  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_black_service`;
CREATE TABLE `hillstone_black_service`
(
    `id`                bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`         bigint      DEFAULT NULL COMMENT '平台id',
    `virtual_router_id` bigint      DEFAULT NULL COMMENT '所属虚拟路由器id',
    `src_ip`            char(12)    DEFAULT NULL COMMENT '源ip地址',
    `des_ip`            char(12)    DEFAULT NULL COMMENT '目的ip地址',
    `des_port`          int         DEFAULT NULL COMMENT '目的端口',
    `protocol`          varchar(20) DEFAULT NULL COMMENT '协议：TCP、UDP',
    `age`               int         DEFAULT NULL COMMENT '剩余阻断时长，该字段会随着时间变化而变化，60-3600秒',
    `reason`            varchar(20) DEFAULT NULL COMMENT '加入原因： Manual 手工加入 其他可取值暂时未知',
    PRIMARY KEY (`id`)
) COMMENT '服务黑名单' ENGINE = InnoDB
                  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_config_backup`;
CREATE TABLE `hillstone_config_backup`
(
    `id`          bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`   bigint       DEFAULT NULL COMMENT '平台id',
    `name`        varchar(100) DEFAULT NULL COMMENT '名称',
    `description` text         DEFAULT NULL COMMENT '描述',
    `timestamp`   char(25)     DEFAULT NULL COMMENT '保存时间',
    `size`        bigint       DEFAULT NULL COMMENT '大小，字节',
    `version`     varchar(100) DEFAULT NULL COMMENT '软件版本',
    `author`      varchar(100) DEFAULT NULL COMMENT '用户',
    `way`         varchar(100) DEFAULT NULL COMMENT '备份源',
    PRIMARY KEY (`id`)
) COMMENT '系统配置的备份文件' ENGINE = InnoDB
                      DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_country_book`;
CREATE TABLE `hillstone_country_book`
(
    `id`        bigint NOT NULL AUTO_INCREMENT,
    `vendor_id` bigint       DEFAULT NULL COMMENT '平台id',
    `code`      char(2)      DEFAULT NULL COMMENT '编码',
    `name`      varchar(100) DEFAULT NULL COMMENT '名称',
    PRIMARY KEY (`id`)
) COMMENT '国家地区本' ENGINE = InnoDB
                  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_interface`;
CREATE TABLE `hillstone_interface`
(
    `id`                         bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`                  bigint       DEFAULT NULL COMMENT '平台id',
    `name`                       varchar(50)  DEFAULT NULL COMMENT '名称',
    `description`                text         DEFAULT NULL COMMENT '描述',
    `zone_id`                    bigint       DEFAULT NULL COMMENT '绑定的安全域id',
    `tap_addr_id`                bigint       DEFAULT NULL COMMENT 'TAP内网地址Id',
    `dhcp`                       tinyint      DEFAULT NULL COMMENT 'dhcp',
    `set_route`                  tinyint      DEFAULT NULL COMMENT '将DHCP服务器提供的网关信息设置为默认网关路由',
    `ip`                         bigint       DEFAULT NULL COMMENT 'ip地址',
    `mask`                       bigint       DEFAULT NULL COMMENT '子网掩码',
    `local_ip`                   tinyint      DEFAULT NULL COMMENT '配置为localIp',
    `dns_proxy`                  int          DEFAULT NULL COMMENT 'dns代理，0不启用，1启用代理，2启用透明代理',
    `dns_pass`                   int          DEFAULT NULL COMMENT 'dns穿透，3不启用，4启用',
    `telnet_nable`               tinyint      DEFAULT NULL COMMENT '开启telnet管理方式',
    `ssh_nable`                  tinyint      DEFAULT NULL COMMENT '开启ssh管理方式',
    `ping_nable`                 tinyint      DEFAULT NULL COMMENT '开启ping',
    `http_nable`                 tinyint      DEFAULT NULL COMMENT '开启http协议访问',
    `https_nable`                tinyint      DEFAULT NULL COMMENT '开启https协议访问',
    `snmp_nable`                 tinyint      DEFAULT NULL COMMENT '开启smnp协议访问',
    `revs_route`                 int          DEFAULT NULL COMMENT '逆向路由，1关闭，2自动，null启用',
    `host_route`                 tinyint      DEFAULT NULL COMMENT 'WAP智能分流',
    `dst_ip_replace`             tinyint      DEFAULT NULL COMMENT '目的IP替换',
    `host_route_log`             int          DEFAULT NULL COMMENT 'WAP日志记录方式，1记录所有日志，0记录被替换的目的ip的日志',
    `dst_port1`                  int          DEFAULT NULL COMMENT '目的服务器端口1',
    `dst_port2`                  int          DEFAULT NULL COMMENT '目的服务器端口2',
    `route_dist`                 int          DEFAULT NULL COMMENT '路由距离',
    `route_weight`               int          DEFAULT NULL COMMENT '路由权重',
    `dns_pri`                    int          DEFAULT NULL COMMENT 'dns管理优先级',
    `manage_ip`                  bigint       DEFAULT NULL COMMENT '管理ip',
    `second_ips`                 text         DEFAULT NULL COMMENT '二级IP列表，按照1.1.1.1/24的格式保存，英文逗号隔开',
    `arp`                        tinyint      DEFAULT NULL COMMENT '开启arp',
    `arp_timeout`                int          DEFAULT NULL COMMENT 'arp超时时间，秒',
    `mtu`                        int          DEFAULT NULL COMMENT 'mtu，字节',
    `keepalive_ip`               bigint       DEFAULT NULL COMMENT '开启keepalive IP',
    `mirror`                     tinyint      DEFAULT NULL COMMENT '开启流量镜像',
    `mirror_type`                varchar(5)   DEFAULT NULL COMMENT '流量镜像类型：both所有流量，tx发送流量，rx接收流量',
    `shutdown`                   tinyint      DEFAULT NULL COMMENT '立即关闭',
    `shutdown_track_id`          bigint       DEFAULT NULL COMMENT '在此id的监控对象失败时，接口自动关闭',
    `shutdown_schedule_id`       bigint       DEFAULT NULL COMMENT '在此id的时间表内，接口自动关闭',
    `monitor_backup_track_Id`    bigint       DEFAULT NULL COMMENT '在此id的监控对象失败时，执行监控与备份',
    `monitor_backup_schedule_Id` bigint       DEFAULT NULL COMMENT '在此id的时间表内，执行监控与备份',
    `mb_monitor`                 tinyint      DEFAULT NULL COMMENT '在时间表内或监控对象失败时，是否执行监控',
    `mb_backup_if_id`            bigint       DEFAULT NULL COMMENT '在时间表内或监控对象失败事，将流量备份到此id的接口',
    `mb_backup_over_lap`         int          DEFAULT NULL COMMENT '在过渡时间内，流量从主接口平滑转到备份接口',
    `rip_auth_mode`              varchar(5)   DEFAULT NULL COMMENT 'rip认证方式，text：明文，md5：MD5',
    `rip_auth_string`            varchar(255) DEFAULT NULL COMMENT 'rip认证码',
    `rip_send_version`           int          DEFAULT NULL COMMENT 'rip发送版本，1：V1,2：V2，3：V1&V2',
    `rip_recv_version`           int          DEFAULT NULL COMMENT 'rip接收版本，1：V1,2：V2，3：V1&V2',
    `rip_split_horizon`          tinyint      DEFAULT NULL COMMENT 'rip水平分割',
    `duplex`                     varchar(10)  DEFAULT NULL COMMENT '双工，full全双工，半双工取值未知',
    `speed`                      int          DEFAULT NULL COMMENT '速率，米',
    `lacp_aggregate`             tinyint      DEFAULT NULL COMMENT '聚合方式：true：LACP动态传输，false：强制模式',
    `agg_sys_priority`           int          DEFAULT NULL COMMENT '系统优先级',
    `agg_max_bundle`             int          DEFAULT NULL COMMENT '最大链路数',
    `agg_min_bundle`             int          DEFAULT NULL COMMENT '最小链路数',
    `agg_if_id`                  bigint       DEFAULT NULL COMMENT '绑定的聚集接口id',
    `lb_stream`                  tinyint      DEFAULT NULL COMMENT '负载均衡方式: 基于流',
    `lb_src_mac`                 tinyint      DEFAULT NULL COMMENT '负载均衡方式：源MAC',
    `lb_des_mac`                 tinyint      DEFAULT NULL COMMENT '负载均衡方式：目的MAC',
    `lb_src_ip`                  tinyint      DEFAULT NULL COMMENT '负载均衡方式：源IP',
    `lb_des_ip`                  tinyint      DEFAULT NULL COMMENT '负载均衡方式：目的IP',
    `lb_src_port`                tinyint      DEFAULT NULL COMMENT '负载均衡方式：源端口',
    `lb_des_port`                tinyint      DEFAULT NULL COMMENT '负载均衡方式：目的端口',
    `lb_protocol`                tinyint      DEFAULT NULL COMMENT '负载均衡方式：协议类型',
    PRIMARY KEY (`id`)
) COMMENT '接口' ENGINE = InnoDB
               DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_isp_info`;
CREATE TABLE `hillstone_isp_info`
(
    `id`        bigint NOT NULL AUTO_INCREMENT,
    `vendor_id` bigint       DEFAULT NULL COMMENT '平台id',
    `name`      varchar(100) DEFAULT NULL COMMENT '名称',
    `isp_type`  int          DEFAULT NULL COMMENT '类型：0->自定义；1->预定义',
    `isp_used`  tinyint      DEFAULT NULL COMMENT '是否绑定',
    `subnets`   text         DEFAULT NULL COMMENT '子网列表，格式：1.1.1.1/24,2.2.2.2/24',
    PRIMARY KEY (`id`)
) COMMENT 'ISP信息' ENGINE = InnoDB
                  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_monitor_book`;
CREATE TABLE `hillstone_monitor_book`
(
    `id`        bigint NOT NULL AUTO_INCREMENT,
    `vendor_id` bigint       DEFAULT NULL COMMENT '平台id',
    `name`      varchar(100) DEFAULT NULL COMMENT '名称',
    `threshold` int          DEFAULT NULL COMMENT '警戒值，默认255',
    PRIMARY KEY (`id`)
) COMMENT '监控对象' ENGINE = InnoDB
                 DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_monitor_book_interface`;
CREATE TABLE `hillstone_monitor_book_interface`
(
    `id`              bigint NOT NULL AUTO_INCREMENT,
    `monitor_book_id` bigint DEFAULT NULL COMMENT '所属监控对象id',
    `intf_id`         bigint DEFAULT NULL COMMENT '接口Id',
    `weight`          int    DEFAULT NULL COMMENT '权重',
    PRIMARY KEY (`id`)
) COMMENT '监控对象监控的接口' ENGINE = InnoDB
                      DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_monitor_book_ipaddr`;
CREATE TABLE `hillstone_monitor_book_ipaddr`
(
    `id`              bigint NOT NULL AUTO_INCREMENT,
    `monitor_book_id` bigint       DEFAULT NULL COMMENT '所属监控对象id',
    `type`            int          DEFAULT NULL COMMENT '类型：0 ping, 1 http, 2 arp, 3 dns, 4 tcp',
    `host`            varchar(100) DEFAULT NULL COMMENT 'IP/主机',
    `port`            int          DEFAULT NULL COMMENT '端口',
    `weight`          int          DEFAULT NULL COMMENT '权重，默认255',
    `threshold`       int          DEFAULT NULL COMMENT '重试次数，默认3',
    `interval_second` int          DEFAULT NULL COMMENT '发送报文间隔，默认3',
    `send_intf_id`    bigint       DEFAULT NULL COMMENT '发送报文接口id',
    `recv_intf_id`    bigint       DEFAULT NULL COMMENT '接受报文接口id',
    PRIMARY KEY (`id`)
) COMMENT '监控对象监控的地址' ENGINE = InnoDB
                      DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_policy_route`;
CREATE TABLE `hillstone_policy_route`
(
    `id`                    bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`             bigint       DEFAULT NULL COMMENT '平台id',
    `name`                  varchar(100) DEFAULT NULL COMMENT '名称',
    `virtual_route_id`      bigint       DEFAULT NULL COMMENT '所属虚拟路由器id',
    `bind_virtual_route_id` bigint       DEFAULT NULL COMMENT '绑定到虚拟路由器id',
    `bind_interface_id`     bigint       DEFAULT NULL COMMENT '绑定到接口id',
    `bind_zone_id`          bigint       DEFAULT NULL COMMENT '绑定到安全域id',
    PRIMARY KEY (`id`)
) COMMENT '策略路由' ENGINE = InnoDB
                 DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_policy_route_rule`;
CREATE TABLE `hillstone_policy_route_rule`
(
    `id`              bigint NOT NULL AUTO_INCREMENT,
    `policy_route_id` bigint       DEFAULT NULL COMMENT '所属策略路由id',
    `child_id`        bigint       DEFAULT NULL COMMENT '规则ID ',
    `name`            varchar(100) DEFAULT NULL COMMENT '策略路由名称',
    `enable`          tinyint      DEFAULT NULL COMMENT '0->禁用；1->启用',
    `description`     text         DEFAULT NULL COMMENT '描述',
    PRIMARY KEY (`id`)
) COMMENT '策略路由规则' ENGINE = InnoDB
                   DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_policy_route_rule_next_hop`;
CREATE TABLE `hillstone_policy_route_rule_next_hop`
(
    `id`                   bigint NOT NULL AUTO_INCREMENT,
    `policy_route_rule_id` bigint DEFAULT NULL COMMENT '所属策略路由规则id',
    `intf_id`              bigint DEFAULT NULL COMMENT '接口id',
    `ip`                   bigint DEFAULT NULL COMMENT 'ip地址',
    `track_id`             bigint DEFAULT NULL COMMENT '检测对象id',
    `weight`               int    DEFAULT NULL COMMENT '路由权值,1-255,缺省1',
    PRIMARY KEY (`id`)
) COMMENT '策略路由规则--下一跳' ENGINE = InnoDB
                        DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_relation`;
CREATE TABLE `hillstone_relation`
(
    `id`        bigint NOT NULL AUTO_INCREMENT,
    `src_id`    bigint      DEFAULT NULL COMMENT '源id',
    `dst_id`    bigint      DEFAULT NULL COMMENT '目标id',
    `type`      int         DEFAULT NULL COMMENT '关联类型',
    `data_type` varchar(64) DEFAULT NULL COMMENT '数据类型',
    `dst_value` varchar(64) DEFAULT NULL COMMENT '展示数据',
    PRIMARY KEY (`id`)
) COMMENT '关联关系' ENGINE = InnoDB
                 DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_safe_zone`;
CREATE TABLE `hillstone_safe_zone`
(
    `id`                bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`         bigint       DEFAULT NULL COMMENT '平台id',
    `name`              varchar(100) DEFAULT NULL COMMENT '名称',
    `description`       text         DEFAULT NULL COMMENT '描述',
    `type`              int          DEFAULT NULL COMMENT '类型：1 二层安全域 0 三层安全域 2 tap安全域',
    `virtual_switch_id` bigint       DEFAULT NULL COMMENT '虚拟交换机id--二层安全域',
    `virtual_router_id` bigint       DEFAULT NULL COMMENT '虚拟路由器--三层安全域和tap安全域',
    `ident`             tinyint      DEFAULT NULL COMMENT '应用识别',
    `wan`               tinyint      DEFAULT NULL COMMENT 'WAN安全域',
    `nbt`               tinyint      DEFAULT NULL COMMENT 'NBT缓存',
    `syn_proxy`         tinyint      DEFAULT NULL COMMENT '开启SYN代理',
    `syn_min_rate`      int          DEFAULT NULL COMMENT '最小代理速率',
    `syn_max_rate`      int          DEFAULT NULL COMMENT '最大代理速率',
    `syn_timeout`       int          DEFAULT NULL COMMENT '代理超时，秒',
    `syn_cookie`        tinyint      DEFAULT NULL COMMENT 'SYN代理--cookie',
    `tf_enable`         tinyint      DEFAULT NULL COMMENT 'SYN代理--cookie',
    `tf_cap`            tinyint      DEFAULT NULL COMMENT '边界流量过滤--抓包',
    `tf_user`           int          DEFAULT NULL COMMENT '边界流量过滤--自定义，0关闭 1 丢弃 2 记录日志',
    `tf_pre`            int          DEFAULT NULL COMMENT '边界流量过滤--预定义，0关闭 1 丢弃 2 记录日志',
    `tf_trend`          int          DEFAULT NULL COMMENT '边界流量过滤--TDA，0关闭 1 丢弃 2 记录日志',
    PRIMARY KEY (`id`)
) COMMENT '安全域' ENGINE = InnoDB
                DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_safe_zone_rule`;
CREATE TABLE `hillstone_safe_zone_rule`
(
    `id`                 bigint NOT NULL AUTO_INCREMENT,
    `safe_zone_id`       bigint  DEFAULT NULL COMMENT '所属安全域id',
    `item`               int     DEFAULT NULL COMMENT '防护类型',
    `enable`             tinyint DEFAULT NULL COMMENT '是否开启，当item!=24时，operation为100关闭，101和102开启，别的值暂未见到；当item=24,则取enable',
    `action`             int     DEFAULT NULL COMMENT '应对行为：1 告警 0 丢弃',
    `threshold`          int     DEFAULT NULL COMMENT '警戒值/源警戒值',
    `des_threshold`      int     DEFAULT NULL COMMENT '目的警戒值/目的警戒值--基于IP',
    `des_threshold_port` int     DEFAULT NULL COMMENT '目的警戒值/目的警戒值--基于端口',
    `base_type`          int     DEFAULT NULL COMMENT '目的警戒值：1 基于IP 2 基于端口',
    `addr_type`          int     DEFAULT NULL COMMENT '目的警戒值--基于端口：1 IP地址 2 地址条目（地址本）',
    `ip`                 bigint  DEFAULT NULL COMMENT '目的警戒值--基于端口--IP地址--地址',
    `mask`               bigint  DEFAULT NULL COMMENT '目的警戒值--基于端口--IP地址--掩码',
    `address_book_id`    bigint  DEFAULT NULL COMMENT '目的警戒值--基于端口--地址条目id',
    PRIMARY KEY (`id`)
) COMMENT '安全域--威胁防护' ENGINE = InnoDB
                      DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_safe_zone_white`;
CREATE TABLE `hillstone_safe_zone_white`
(
    `id`              bigint NOT NULL AUTO_INCREMENT,
    `safe_zone_id`    bigint DEFAULT NULL COMMENT '所属安全域id',
    `type`            int    DEFAULT NULL COMMENT '类型，1 IP掩码 2 地址条目（地址本）',
    `ip`              bigint DEFAULT NULL COMMENT 'IP地址',
    `mask`            bigint DEFAULT NULL COMMENT '子网掩码',
    `address_book_id` bigint DEFAULT NULL COMMENT '地址条目名称id',
    PRIMARY KEY (`id`)
) COMMENT '安全域--白名单' ENGINE = InnoDB
                     DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_security_policy`;
CREATE TABLE `hillstone_security_policy`
(
    `id`          bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`   bigint       DEFAULT NULL COMMENT '平台id',
    `src_zone_id` bigint       DEFAULT NULL COMMENT '源安全域id',
    `src_subnets` text         DEFAULT NULL COMMENT '源地址--IP/掩码，格式：1.1.1.1/24,2.2.2.2/24',
    `src_ranges`  text         DEFAULT NULL COMMENT '源地址--IP范围，格式：1.1.1.1-1.1.1.254,1.1.2.1-1.1.2.254',
    `src_hosts`   text         DEFAULT NULL COMMENT '源地址--主机名称，格式：json，String[]',
    `dst_zone_id` bigint       DEFAULT NULL COMMENT '目的安全域id',
    `dst_subnets` text         DEFAULT NULL COMMENT '目的地址--IP/掩码，格式：1.1.1.1/24,2.2.2.2/24',
    `dst_ranges`  text         DEFAULT NULL COMMENT '目的地址--IP范围，格式：1.1.1.1-1.1.1.254,1.1.2.1-1.1.2.254',
    `dst_hosts`   text         DEFAULT NULL COMMENT '目的地址--主机名称，格式：json，String[]',
    `policy_id`   bigint       DEFAULT NULL COMMENT '策略id',
    `name`        varchar(100) DEFAULT NULL COMMENT '名称',
    `description` text         DEFAULT NULL COMMENT '描述',
    `action`      int          DEFAULT NULL COMMENT '操作 1->拒绝；2->允许；5->安全连接',
    `hit_count`   bigint       DEFAULT NULL COMMENT '命中数',
    PRIMARY KEY (`id`)
) COMMENT '安全策略' ENGINE = InnoDB
                 DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_service_book`;
CREATE TABLE `hillstone_service_book`
(
    `id`          bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`   bigint       DEFAULT NULL COMMENT '平台id',
    `name`        varchar(100) DEFAULT NULL COMMENT '名称',
    `description` text         DEFAULT NULL COMMENT '描述',
    `tcp_udp`     text         DEFAULT NULL COMMENT 'tcp 和 udp，格式：JSON',
    `icmps`       text         DEFAULT NULL COMMENT 'icmp，格式：JSON',
    `others`      text         DEFAULT NULL COMMENT '其他协议号，格式：多个数据英文逗号隔开',
    PRIMARY KEY (`id`)
) COMMENT '服务本' ENGINE = InnoDB
                DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_service_group`;
CREATE TABLE `hillstone_service_group`
(
    `id`          bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`   bigint       DEFAULT NULL COMMENT '平台id',
    `name`        varchar(100) DEFAULT NULL COMMENT '名称',
    `description` text         DEFAULT NULL COMMENT '描述',
    PRIMARY KEY (`id`)
) COMMENT '服务组' ENGINE = InnoDB
                DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_signature_trust_domain`;
CREATE TABLE `hillstone_signature_trust_domain`
(
    `id`        bigint NOT NULL AUTO_INCREMENT,
    `vendor_id` bigint       DEFAULT NULL COMMENT '平台id',
    `name`      varchar(100) DEFAULT NULL COMMENT '名称',
    `keyPair`   varchar(100) DEFAULT NULL COMMENT '密钥对',
    PRIMARY KEY (`id`)
) COMMENT '签名信任域' ENGINE = InnoDB
                  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_slb_service_type`;
CREATE TABLE `hillstone_slb_service_type`
(
    `id`                bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`         bigint      DEFAULT NULL COMMENT '平台id',
    `ip`                bigint      DEFAULT NULL COMMENT '服务器IP地址',
    `virtual_router_id` bigint      DEFAULT NULL COMMENT '所属虚拟路由器id',
    `port`              varchar(50) DEFAULT NULL COMMENT '端口',
    `status`            varchar(50) DEFAULT NULL COMMENT '状态',
    `curr_connection`   int         DEFAULT NULL COMMENT '当前连接数',
    `ha_group`          int         DEFAULT NULL COMMENT 'HA组',
    `dest_nat_rule_id`  bigint      DEFAULT NULL COMMENT '目的NAT的id',
    PRIMARY KEY (`id`)
) COMMENT 'SLB服务器状态' ENGINE = InnoDB
                     DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_system_role`;
CREATE TABLE `hillstone_system_role`
(
    `id`          bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`   bigint       DEFAULT NULL COMMENT '平台id',
    `name`        varchar(100) DEFAULT NULL COMMENT '名称',
    `description` text         DEFAULT NULL COMMENT '描述',
    `cli`         tinyint      DEFAULT NULL COMMENT '是否拥有cli权限',
    PRIMARY KEY (`id`)
) COMMENT '系统角色' ENGINE = InnoDB
                 DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_system_user`;
CREATE TABLE `hillstone_system_user`
(
    `id`          bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`   bigint       DEFAULT NULL COMMENT '平台id',
    `name`        varchar(100) DEFAULT NULL COMMENT '用户名',
    `password`    varchar(100) DEFAULT NULL COMMENT '密码，接口返回是加密后的，具体加解密算法未知',
    `role_id`     bigint       DEFAULT NULL COMMENT '角色id',
    `description` text         DEFAULT NULL COMMENT '描述',
    `console`     tinyint      DEFAULT NULL COMMENT '允许Console登录',
    `telnet`      tinyint      DEFAULT NULL COMMENT '允许Telnet登录',
    `ssh`         tinyint      DEFAULT NULL COMMENT '允许SSH登录',
    `http`        tinyint      DEFAULT NULL COMMENT '允许Http登录',
    `https`       tinyint      DEFAULT NULL COMMENT '允许Https登录',
    PRIMARY KEY (`id`)
) COMMENT '系统用户' ENGINE = InnoDB
                 DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_time_book`;
CREATE TABLE `hillstone_time_book`
(
    `id`         bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`  bigint       DEFAULT NULL COMMENT '平台id',
    `name`       varchar(100) DEFAULT NULL COMMENT '名称',
    `valid`      int          DEFAULT NULL COMMENT '活跃状态',
    `absolute`   text         DEFAULT NULL COMMENT '绝对计划',
    `every_days` text         DEFAULT NULL COMMENT '周期计划--每天',
    `some_weeks` text         DEFAULT NULL COMMENT '周期计划--每周的某几天',
    `some_times` text         DEFAULT NULL COMMENT '周期计划--每周的一段时间',
    PRIMARY KEY (`id`)
) COMMENT '时间表' ENGINE = InnoDB
                DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_virtual_route`;
CREATE TABLE `hillstone_virtual_route`
(
    `id`        bigint NOT NULL AUTO_INCREMENT,
    `vendor_id` bigint       DEFAULT NULL COMMENT '平台id',
    `name`      varchar(100) DEFAULT NULL COMMENT '名称',
    PRIMARY KEY (`id`)
) COMMENT '虚拟路由' ENGINE = InnoDB
                 DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_virtual_route_dst_nat`;
CREATE TABLE `hillstone_virtual_route_dst_nat`
(
    `id`               bigint NOT NULL AUTO_INCREMENT,
    `virtual_route_id` bigint       DEFAULT NULL COMMENT '所属虚拟路由器id',
    `rule_id`          bigint       DEFAULT NULL COMMENT 'NAT ID',
    `from_name`        varchar(100) DEFAULT NULL COMMENT '源地址',
    `from_type`        int          DEFAULT NULL COMMENT '源地址类型：0 地址条目 1 IP地址或IP掩码',
    `to_name`          varchar(100) DEFAULT NULL COMMENT '目的地址',
    `to_type`          int          DEFAULT NULL COMMENT '目的地址类型：0 地址条目 1 IP地址或IP掩码',
    `service_id`       bigint       DEFAULT NULL COMMENT '服务id',
    `trans`            varchar(100) DEFAULT NULL COMMENT '转换类型为指定IP时，转换地址',
    `trans_type`       int          DEFAULT NULL COMMENT '转换类型为指定IP时，转换地址类型：null 不转换 0 地址条目 1 IP地址或IP掩码，SLB服务器池因为没有数据无法测试',
    `port`             int          DEFAULT NULL COMMENT '转换端口，1-65535，为null则表示不启用转换端口',
    `load_balance`     tinyint      DEFAULT NULL COMMENT '负载均衡',
    `group_id`         int          DEFAULT NULL COMMENT 'ha组',
    `description`      text         DEFAULT NULL COMMENT '描述',
    `ping_stack`       tinyint      DEFAULT NULL COMMENT 'PING跟踪',
    `tcp_stack`        tinyint      DEFAULT NULL COMMENT 'TCP跟踪',
    `tcp_stack_port`   int          DEFAULT NULL COMMENT 'TCP跟踪端口',
    `log`              tinyint      DEFAULT NULL COMMENT 'NAT日志',
    `pos`              int          DEFAULT NULL COMMENT '列表位置对标id',
    `pos_flag`         int          DEFAULT NULL COMMENT '列表位置，1->列表最前；2->该ID之前；3->该ID之后；4->列表最后',
    `enable`           tinyint      DEFAULT NULL COMMENT '启用/禁用',
    PRIMARY KEY (`id`)
) COMMENT '源NAT' ENGINE = InnoDB
                 DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_virtual_route_ribv4`;
CREATE TABLE `hillstone_virtual_route_ribv4`
(
    `id`                bigint NOT NULL AUTO_INCREMENT,
    `virtual_route_id`  bigint      DEFAULT NULL COMMENT '所属虚拟路由器id',
    `route_type`        int         DEFAULT NULL COMMENT '路由类别：7->ISP路由；3->目的接口路由；2->目的路由；4->源路由；5->源接口路由；1->就近探测路由；',
    `destination`       bigint      DEFAULT NULL COMMENT '目的地IP（目的路由、目的接口路由）、源IP（源路由、源接口路由）',
    `netmask`           bigint      DEFAULT NULL COMMENT '子网掩码',
    `next_hop`          varchar(64) DEFAULT NULL COMMENT '下一跳，取值为网关名称或接口名称',
    `next_hop_type`     int         DEFAULT NULL COMMENT '下一跳类型，3 网关 9 接口，“当前系统虚拟路由器”和“其他系统虚拟路由器”无法测试取值未知',
    `next_hop_id`       bigint      DEFAULT NULL COMMENT '下一跳，取值为接口id，当吓一跳类型为3接口时该字段有效',
    `interface_gate`    bigint      DEFAULT NULL COMMENT '接口网关，当下一跳类型为9接口时该字段有效',
    `weight`            int         DEFAULT NULL COMMENT '路由权值',
    `preference`        int         DEFAULT NULL COMMENT '优先权',
    `description`       text        DEFAULT NULL COMMENT '描述',
    `into_interface_id` bigint      DEFAULT NULL COMMENT '入接口id，目的接口路由时该字段有效',
    `isp_id`            bigint      DEFAULT NULL COMMENT 'ISP信息id，ISP路由时该字段有效',
    PRIMARY KEY (`id`)
) COMMENT 'RIBV4路由' ENGINE = InnoDB
                    DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_virtual_route_rip`;
CREATE TABLE `hillstone_virtual_route_rip`
(
    `id`               bigint NOT NULL AUTO_INCREMENT,
    `virtual_route_id` bigint  DEFAULT NULL COMMENT '所属虚拟路由器id',
    `version`          int     DEFAULT NULL COMMENT '版本 v1/v2',
    `enable`           int     DEFAULT NULL COMMENT '启用/禁用',
    `default_metric`   int     DEFAULT NULL COMMENT '缺省度量 1（1-15）',
    `default_distance` int     DEFAULT NULL COMMENT '缺省距离 120（1-255）',
    `default_info`     tinyint DEFAULT NULL COMMENT '缺省信息发布：0->未开启；1->开启',
    `interval_second`  int     DEFAULT NULL COMMENT '更新时间,(0~16777215)秒,缺省值:30',
    `invalid`          int     DEFAULT NULL COMMENT '无效时间,(0~16777215)秒,缺省值:180',
    `holddown`         int     DEFAULT NULL COMMENT '阻止时间,(0~16777215)秒,缺省值:180',
    `flush`            int     DEFAULT NULL COMMENT '清除时间,(0~16777215)秒,缺省值:240',
    `redistributes`    text    DEFAULT NULL COMMENT '引入路由，JSON格式，包含字段protocol metric',
    `neighbor`         text    DEFAULT NULL COMMENT '邻居，数据格式：1.1.1.1,2.2.2.2',
    `network`          text    DEFAULT NULL COMMENT '网络，数据格式：1.1.1.1/24,2.2.2.2/24',
    `distances`        text    DEFAULT NULL COMMENT '距离，JSON格式，包含字段ip mask distance',
    PRIMARY KEY (`id`)
) COMMENT 'RIP' ENGINE = InnoDB
                DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_virtual_route_src_nat`;
CREATE TABLE `hillstone_virtual_route_src_nat`
(
    `id`               bigint NOT NULL AUTO_INCREMENT,
    `virtual_route_id` bigint       DEFAULT NULL COMMENT '所属虚拟路由器id',
    `rule_id`          bigint       DEFAULT NULL COMMENT 'NAT ID',
    `group_id`         int          DEFAULT NULL COMMENT 'HA组',
    `from_name`        varchar(100) DEFAULT NULL COMMENT '源地址',
    `from_type`        int          DEFAULT NULL COMMENT '源地址类型：0 地址条目 1 IP地址或IP掩码',
    `to_name`          varchar(100) DEFAULT NULL COMMENT '目的地址',
    `to_type`          int          DEFAULT NULL COMMENT '目的地址类型：0 地址条目 1 IP地址或IP掩码',
    `service_id`       bigint       DEFAULT NULL COMMENT '服务id',
    `flag`             int          DEFAULT NULL COMMENT '地址转换类型',
    `trans`            varchar(100) DEFAULT NULL COMMENT '转换类型为指定IP时，转换地址',
    `trans_type`       int          DEFAULT NULL COMMENT '转换类型为指定IP时，转换地址类型：0 地址条目 1 IP地址或IP掩码',
    `pos`              int          DEFAULT NULL COMMENT '列表位置对标id',
    `pos_flag`         int          DEFAULT NULL COMMENT '列表位置，1->列表最前；2->该ID之前；3->该ID之后；4->列表最后',
    `log`              int          DEFAULT NULL COMMENT 'NAT日志：0 -> 不开启; 1 -> 开启',
    `description`      text         DEFAULT NULL COMMENT '描述',
    `enable`           tinyint      DEFAULT NULL COMMENT '可用/禁用',
    PRIMARY KEY (`id`)
) COMMENT '源NAT' ENGINE = InnoDB
                 DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_vpn_ipsec_config`;
CREATE TABLE `hillstone_vpn_ipsec_config`
(
    `id`        bigint NOT NULL AUTO_INCREMENT,
    `vendor_id` bigint       DEFAULT NULL COMMENT '平台id',
    `name`      varchar(100) DEFAULT NULL COMMENT '名称',
    `peer_id`   bigint       DEFAULT NULL COMMENT '对端选项id',
    `mode`      int          DEFAULT NULL COMMENT '模式，null tunnel，2 transport',
    `prop_id`   bigint       DEFAULT NULL COMMENT 'P2提议id',
    PRIMARY KEY (`id`)
) COMMENT 'VPN IPsec 配置' ENGINE = InnoDB
                         DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_vpn_ipsec_config_proxy_id`;
CREATE TABLE `hillstone_vpn_ipsec_config_proxy_id`
(
    `id`                  bigint NOT NULL AUTO_INCREMENT,
    `vpn_ipsec_config_id` bigint DEFAULT NULL COMMENT '所属IPSecVPN',
    `local_ip`            bigint DEFAULT NULL COMMENT '本地IP',
    `local_mask`          bigint DEFAULT NULL COMMENT '本地IP',
    `remote_ip`           bigint DEFAULT NULL COMMENT '远程IP',
    `remote_mask`         bigint DEFAULT NULL COMMENT '远程IP',
    `service_id`          bigint DEFAULT NULL COMMENT '服务id',
    PRIMARY KEY (`id`)
) COMMENT 'VPN IPsec 配置代理ID' ENGINE = InnoDB
                             DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_vpn_ipsec_peer`;
CREATE TABLE `hillstone_vpn_ipsec_peer`
(
    `id`            bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`     bigint       DEFAULT NULL COMMENT '平台id',
    `name`          varchar(100) DEFAULT NULL COMMENT '名称',
    `intf_id`       bigint       DEFAULT NULL COMMENT '接口id',
    `mode`          int          DEFAULT NULL COMMENT '认证模式，null 主模式 4 野蛮模式',
    `type`          int          DEFAULT NULL COMMENT '类型，null 静态IP 2 动态IP 4 用户组',
    `peer`          bigint       DEFAULT NULL COMMENT '对端IP，当type=null时有效',
    `aaa_server`    varchar(100) DEFAULT NULL COMMENT 'AAA服务器，当type=4时有效',
    `local_id_type` int          DEFAULT NULL COMMENT '本地IP类型，null 无，1 FQDN，2 U-FQDN，5 ASN1-DN 3 KEY_ID 4 IP',
    `local_id`      varchar(100) DEFAULT NULL COMMENT '本地IP',
    `peer_id_type`  int          DEFAULT NULL COMMENT '对端IP类型，null 无，1 FQDN，2 U-FQDN，5 ASN1-DN 3 KEY_ID 4 IP',
    `peer_id`       varchar(100) DEFAULT NULL COMMENT '对端IP',
    `prop1_id`      bigint       DEFAULT NULL COMMENT '提议1 Id',
    `prop2_id`      bigint       DEFAULT NULL COMMENT '提议2 Id',
    `prop3_id`      bigint       DEFAULT NULL COMMENT '提议3 Id',
    `prop4_id`      bigint       DEFAULT NULL COMMENT '提议4 Id',
    `pre_key`       varchar(100) DEFAULT NULL COMMENT '共享秘钥',
    `td_id`         bigint       DEFAULT NULL COMMENT '签名信任域id',
    PRIMARY KEY (`id`)
) COMMENT 'VPN IPsec 对端列表' ENGINE = InnoDB
                           DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_vpn_ipsec_proposal1`;
CREATE TABLE `hillstone_vpn_ipsec_proposal1`
(
    `id`          bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`   bigint       DEFAULT NULL COMMENT '平台id',
    `name`        varchar(100) DEFAULT NULL COMMENT '名称',
    `auth`        int          DEFAULT NULL COMMENT '认证，3 RAS-Signature, 2 DSA-Signature, null Pre-share',
    `hash`        int          DEFAULT NULL COMMENT '验证算法，1 MD5，null SHA，4 SHA256, 5 SHA384, 6 SHA512',
    `encryption`  int          DEFAULT NULL COMMENT '加密算法，null 3DES，1 DES，7 AES',
    `enc_key_len` int          DEFAULT NULL COMMENT 'key长度，当encryption=7时此字段有值',
    `dh_group`    int          DEFAULT NULL COMMENT 'DH组，Group1 Group2 Group5 Group14 Group15 Group16, null为Group2',
    `left_time`   int          DEFAULT NULL COMMENT '生存时间，秒',
    PRIMARY KEY (`id`)
) COMMENT 'VPN IPsec 提议1' ENGINE = InnoDB
                          DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_vpn_ipsec_proposal2`;
CREATE TABLE `hillstone_vpn_ipsec_proposal2`
(
    `id`          bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`   bigint       DEFAULT NULL COMMENT '平台id',
    `name`        varchar(100) DEFAULT NULL COMMENT '名称',
    `protocol`    int          DEFAULT NULL COMMENT '协议，null ESP, 2 AH',
    `compression` int          DEFAULT NULL COMMENT '压缩，0 none 2 Deflate',
    `hash`        int          DEFAULT NULL COMMENT '第1个验证算法，1 MD5 2 SHA 5 SHA-256 6 SHA-384 7 SHA-512 8 NULL',
    `hash1`       int          DEFAULT NULL COMMENT '第2个验证算法，支持的值同hash字段',
    `hash2`       int          DEFAULT NULL COMMENT '第3个验证算法，支持的值同hash字段',
    `encryption`  int          DEFAULT NULL COMMENT '第1个加密算法，3 3DES 2 DES 12 AES 14 AES-192 15 AES-256 11 NULL',
    `encryption1` int          DEFAULT NULL COMMENT '第2个加密算法，支持的值同encryption字段',
    `encryption2` int          DEFAULT NULL COMMENT '第3个加密算法，支持的值同encryption字段',
    `encryption3` int          DEFAULT NULL COMMENT '第4个加密算法，支持的值同encryption字段',
    `pfs_group`   int          DEFAULT NULL COMMENT 'PFS组，Group1 Group2 Group5 Group14 Group15 Group16，为null时No PFS',
    `left_time`   int          DEFAULT NULL COMMENT '生存时间，秒，180-86400，缺省28800',
    `life_size`   int          DEFAULT NULL COMMENT '生存大小，KB，1800-41494303',
    PRIMARY KEY (`id`)
) COMMENT 'VPN IPsec 提议2' ENGINE = InnoDB
                          DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `hillstone_local_user`;
CREATE TABLE `hillstone_local_user`
(
    `id`            bigint NOT NULL AUTO_INCREMENT,
    `aaa_server_id` bigint       DEFAULT NULL COMMENT '所属服务器id',
    `name`          varchar(64)  DEFAULT NULL COMMENT '名称',
    `password`      varchar(128) DEFAULT NULL COMMENT '密码',
    `expire_year`   int          DEFAULT NULL COMMENT '到日期-年',
    `expire_month`  int          DEFAULT NULL COMMENT '到日期-月',
    `expire_day`    int          DEFAULT NULL COMMENT '到日期-日',
    `expire_hour`   int          DEFAULT NULL COMMENT '到日期-小时',
    `expire_min`    int          DEFAULT NULL COMMENT '到日期-分钟',
    `phone_number`  varchar(32)  DEFAULT NULL COMMENT '手机号',
    `description`   text COMMENT '描述',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='本地用户表';

DROP TABLE IF EXISTS `hillstone_local_user_group`;
CREATE TABLE `hillstone_local_user_group`
(
    `id`            bigint NOT NULL AUTO_INCREMENT,
    `aaa_server_id` bigint      DEFAULT NULL COMMENT '所属服务器id',
    `name`          varchar(64) DEFAULT NULL COMMENT '名称',
    `user_member`   text        DEFAULT NULL COMMENT '包含用户',
    `group_member`  text        DEFAULT NULL COMMENT '包含用户组',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='本地用户组';

DROP TABLE IF EXISTS `hillstone_local_user_ike`;
CREATE TABLE `hillstone_local_user_ike`
(
    `id`            bigint NOT NULL AUTO_INCREMENT,
    `local_user_id` bigint       DEFAULT NULL COMMENT '关联本地用户id 1-1',
    `props`         varchar(255) DEFAULT NULL COMMENT '原生ID',
    `id_type`       int          DEFAULT '0' COMMENT '5 -> ANS1DN; 1->FQDN; 3->KEY-ID; 0 -> None   默认0',
    `gateway`       bigint       DEFAULT NULL COMMENT 'DHCP网关',
    `dhcp_start`    bigint       DEFAULT NULL COMMENT 'DHCP启始地址',
    `dhcp_end`      bigint       DEFAULT NULL COMMENT 'DHCP结束地址',
    `dhcp_netmask`  bigint       DEFAULT NULL COMMENT 'DHCP网络掩码 默认0',
    `dns1`          bigint       DEFAULT NULL COMMENT 'dns1',
    `dns2`          bigint       DEFAULT NULL COMMENT 'dns2',
    `dns3`          bigint       DEFAULT NULL COMMENT 'dns3',
    `dns4`          bigint       DEFAULT NULL COMMENT 'dns4',
    `wins1`         bigint       DEFAULT NULL COMMENT 'wins1',
    `wins2`         bigint       DEFAULT NULL COMMENT 'wins2',
    `tunnel_ip`     bigint       DEFAULT NULL COMMENT ' 隧道IP',
    `snat`          bigint       DEFAULT '0' COMMENT '用户源NAT 0 -> 关闭；1 -> 开启 默认0',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='本地用户IKE表';

DROP TABLE IF EXISTS `hillstone_local_user_ike_route`;
CREATE TABLE `hillstone_local_user_ike_route`
(
    `id`                bigint NOT NULL AUTO_INCREMENT,
    `local_user_ike_id` bigint DEFAULT NULL COMMENT '对应ikeId n-1',
    `dest`              bigint DEFAULT NULL COMMENT '网络地址',
    `netmask`           int    DEFAULT NULL COMMENT '网络掩码',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

SET FOREIGN_KEY_CHECKS = 1;

DROP TABLE IF EXISTS `hillstone_aaa_server`;
CREATE TABLE `hillstone_aaa_server`
(
    `id`                        bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`                 bigint      DEFAULT NULL COMMENT '所属平台',
    `name`                      varchar(32) DEFAULT NULL COMMENT '名称',
    `type`                      int         DEFAULT NULL COMMENT ' 0 -> 本地服务器；3 -> LDAP服务器；2 -> ACTIVE-DIRECTORY服务器',
    `allow_change_pwd`          int         DEFAULT NULL COMMENT '1->开启；不开启无此属性',
    `back_up_aaa_server`        varchar(64) DEFAULT NULL COMMENT '备用服务器',
    `hostname`                  varchar(64) DEFAULT NULL COMMENT '服务器地址',
    `hostname_virtual_route`    varchar(64) DEFAULT NULL COMMENT '虚拟路由器',
    `hostname_virtual_route_id` varchar(64) DEFAULT NULL COMMENT '虚拟路由器 id',
    `back_up_1`                 varchar(64) DEFAULT NULL COMMENT '备份服务器1',
    `back_up_1_virtual_route`   varchar(64) DEFAULT NULL COMMENT '虚拟路由器1',
    `back_up_2`                 varchar(64) DEFAULT NULL COMMENT '备份服务器2',
    `back_up_2_virtual_route`   varchar(64) DEFAULT NULL COMMENT '虚拟路由器2',
    `ldap_bdn`                  varchar(64) DEFAULT NULL COMMENT 'BASE-DN',
    `ldap_port`                 int         DEFAULT NULL COMMENT '端口',
    `ldap_login_dn`             varchar(64) DEFAULT NULL COMMENT 'LOGIN-DN',
    `ldap_login_password`       varchar(64) DEFAULT NULL COMMENT '密钥',
    `ldap_naming_attr`          varchar(64) DEFAULT NULL COMMENT '用户名属性',
    `ldap_group_class`          varchar(64) DEFAULT NULL COMMENT '组类别',
    `ldap_member_attr`          varchar(64) DEFAULT NULL COMMENT '成员属性',
    `user_filter`               varchar(64) DEFAULT NULL COMMENT '过滤条件',
    `ldap_auth_method`          int         DEFAULT NULL COMMENT '0 -> 明文；md5 无此属性',
    `ldap_agent_enable`         int         DEFAULT NULL COMMENT '监控用户登陆 1->启用 关闭无此属性',
    `ldap_agent_port`           int         DEFAULT '6666' COMMENT '监听端口 1025-65535 默认6666',
    `disconn_del_timeout`       int         DEFAULT '300' COMMENT '登陆信息保留时间 0-1800 默认300',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='3A服务器';

DROP TABLE IF EXISTS `hillstone_virtual_switch`;
CREATE TABLE `hillstone_virtual_switch`
(
    `id`                       bigint NOT NULL AUTO_INCREMENT,
    `vendor_id`                bigint      DEFAULT NULL COMMENT '所属平台',
    `name`                     varchar(64) DEFAULT NULL COMMENT '名称',
    `virtual_switch_interface` varchar(64) DEFAULT NULL COMMENT '接口名称',
    `trunk_vlan_enable`        int         DEFAULT '0' COMMENT '转发标记包 0->未开启；1->开启；',
    `trunk_dvlan_enable`       int         DEFAULT '0' COMMENT '转发双标记包 0->未开启；1->开启',
    `unknown_mc_drop`          int         DEFAULT '0' COMMENT '丢弃未知多播包 0->未开启；1->开启；',
    `vm_mode`                  int         DEFAULT NULL COMMENT 'virtual-wire模式 0->严格；1->不严格; 没有表示不开启',
    `igmp_snooping_enable`     int         DEFAULT NULL COMMENT 'IGMP Snooping 1->开启; 没有表示不开启',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='虚拟交换机';

DROP TABLE IF EXISTS `hillstone_application_book`;
CREATE TABLE `hillstone_application_book`
(
    `id`                     bigint(0)    NOT NULL AUTO_INCREMENT,
    `vendor_id`              bigint(0)    NULL DEFAULT NULL COMMENT '所属平台',
    `props`                  varchar(255) NULL DEFAULT NULL COMMENT '原生平台id',
    `app_type`               int(0)       NULL DEFAULT NULL COMMENT '预留区分 0 -> 应用、 1 -> 组、 2 -> 过滤组',
    `type`                   int(0)       NULL DEFAULT NULL COMMENT '0->自定义 2->预定义',
    `name`                   varchar(64)  NULL DEFAULT NULL COMMENT '名称',
    `show_name`              varchar(64)  NULL DEFAULT NULL COMMENT '页面显示名称',
    `category`               varchar(64)  NULL DEFAULT NULL COMMENT '类别',
    `sub_category`           varchar(64)  NULL DEFAULT NULL COMMENT '子类别',
    `tcp_timeout`            int(0)       NULL DEFAULT NULL COMMENT 'TCP 前端天换算成秒 如何标识？ 1-65535 默认1800',
    `udp_timeout`            int(0)       NULL DEFAULT NULL COMMENT 'UDP 默认60',
    `icmp_timeout`           int(0)       NULL DEFAULT NULL COMMENT 'ICMP 默认6',
    `other_protocol_timeout` int(0)       NULL DEFAULT NULL COMMENT '其他 默认60',
    `risk`                   int(0)       NULL DEFAULT NULL COMMENT '风险等级 新建0',
    `technology`             varchar(64)  NULL DEFAULT NULL COMMENT '所用技术',
    `flag`                   int(0)       NULL DEFAULT NULL COMMENT '？？？',
    `standard_port`          varchar(64)  NULL DEFAULT NULL COMMENT '常规端口',
    `evasive`                varchar(16)  NULL DEFAULT NULL COMMENT '易逃逸 yes / no 新建none',
    `excessive_bandwidth`    varchar(16)  NULL DEFAULT NULL COMMENT '大量消耗带宽 yes / no 新建none',
    `prone_to_misuse`        varchar(16)  NULL DEFAULT NULL COMMENT '易被滥用 yes / no 新建none',
    `file_transfer`          varchar(16)  NULL DEFAULT NULL COMMENT '能够传输文件 yes / no 新建none',
    `tunnels_other_apps`     varchar(16)  NULL DEFAULT NULL COMMENT '被其他应用使用 yes / no 新建none',
    `user_by_malware`        varchar(16)  NULL DEFAULT NULL COMMENT '被恶意软件利用 yes / no 新建none',
    `vulnerabilities`        varchar(16)  NULL DEFAULT NULL COMMENT '存在已知漏洞 yes / no 新建none',
    `widely_used`            varchar(16)  NULL DEFAULT NULL COMMENT '已被大规模使用 yes / no 新建none',
    `refers`                 text         NULL DEFAULT NULL COMMENT '右下角关联项 flag 1->安全策略； 7->策略路由； 0->组',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
    COMMENT ='应用本'
  COLLATE = utf8_general_ci
  ROW_FORMAT = Dynamic;

drop table if exists hillstone_application_static_feature_rule;
create table hillstone_application_static_feature_rule
(
    id        bigint      not null AUTO_INCREMENT,
    vendor_id bigint      NULL DEFAULT NULL COMMENT '所属平台',
    cont_ai   int         null comment '继续动态识别',
    enable    int         null comment '应用特征规则',
    src_zone  varchar(64) null comment '源安全域',
    props     varchar(64) null comment '原生id',
    constraint hillstone_application_static_feature_rule_pk
        primary key (id)
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci comment '应用本-静态特征规则表'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `hillstone_arp_bind`;
CREATE TABLE `hillstone_arp_bind`
(
    `id`             bigint(0)                                               NOT NULL AUTO_INCREMENT,
    `ip_addr`        bigint(0)                                               NULL DEFAULT NULL COMMENT '绑定IP',
    `vendor_id`      bigint(0)                                               NULL DEFAULT NULL COMMENT '所属平台',
    `mac_addr`       varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT 'mac',
    `vr_name`        varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '虚拟路由器',
    `description`    varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'mac描述',
    `type`           int(0)                                                  NULL DEFAULT NULL COMMENT '1->绑定为静态条目 启用后隐藏 0-> 不绑定，显示',
    `authenticated`  int(0)                                                  NULL DEFAULT NULL COMMENT 'ARP认证 0->启用； 1->不启用',
    `interface_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '接口',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci COMMENT = 'ARP攻击防护 ARP绑定'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `hillstone_arp_auth`;
CREATE TABLE `hillstone_arp_auth`
(
    `id`        bigint(0)                                              NOT NULL AUTO_INCREMENT,
    `vendor_id` bigint(0)                                              NULL DEFAULT NULL COMMENT '所属平台',
    `name`      varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '接口名称',
    `auth_arp`  int(0)                                                 NULL DEFAULT NULL COMMENT '1->ARP强制认证 2->ARP强制认证+强制安装客户端 0->全部禁用',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci COMMENT = 'ARP攻击防护 APR认证'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `hillstone_arp_check`;
CREATE TABLE `hillstone_arp_check`
(
    `id`         bigint(0)                                               NOT NULL AUTO_INCREMENT,
    `vendor_id`  bigint(0)                                               NULL DEFAULT NULL COMMENT '所属平台',
    `name`       varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '接口名称',
    `obj_type`   int(0)                                                  NULL DEFAULT NULL,
    `enable`     int(0)                                                  NULL DEFAULT NULL COMMENT 'ARP检查 0->不启用；1->启用 转发；2->启用 丢弃。',
    `rate_limit` int(0)                                                  NULL DEFAULT NULL COMMENT '高级配置 ARP速率',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci COMMENT = 'ARP攻击防护 ARP检查'
  ROW_FORMAT = Dynamic;

drop table if exists hillstone_snmp_host;
create table hillstone_snmp_host
(
    id                      bigint      not null AUTO_INCREMENT,
    vendor_id               bigint      NULL COMMENT '所属平台',
    hostname                varchar(64) null comment '主机',
    host_type               int         null comment '主机类型 1->trap主机；2->snmp主机',
    hostname_type           int         null comment '??? 默认2',
    mode                    int         null comment '1->IP/掩码；2->IP范围；3->IP地址',
    range_start_ipv4        bigint      null comment 'IPV4起始',
    net_seg_ipmask_ipv4     bigint      null comment '网络设置IPV4/掩码',
    net_seg_ipv4            bigint      null comment '网络设置IPV4',
    range_end_ipv4          bigint      null comment 'IPV4终止',
    net_seg_ipv6            varchar(64) null comment '网络设置IPV6',
    net_seg_ipmask_len_ipv6 bigint      null comment '网络设置IPV6/掩码',
    range_start_ipv6        varchar(64) null comment 'IPV6起始',
    range_end_ipv6          varchar(64) null comment 'IPV6终止',
    version                 int         null comment '3->v3; 0->v1; 1->v2c',
    access                  int         null comment '权限 1->只读； 2->可写',
    community               varchar(64) null comment '团体字',
    port                    int         null comment '端口',
    constraint hillstone_snmp_host_pk
        primary key (id)
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci comment 'SNMP主机'
  ROW_FORMAT = Dynamic;

drop table if exists hillstone_snmp_proxy;
create table hillstone_snmp_proxy
(
    id            bigint      not null AUTO_INCREMENT,
    vendor_id     bigint      NULL COMMENT '所属平台',
    status        int         null comment '是否启用snmp代理：0->不启用；1->启用。',
    hostname      varchar(64) null comment '主机名称',
    location      int         null comment '系统位置',
    contact       int         null comment '系统联络',
    host_port     int         null comment '主机端口',
    engine_id     varchar(64) null comment '本地引擎id',
    sys_object_id varchar(64) null comment '对象id',
    constraint hillstone_snmp_proxy_pk
        primary key (id)
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci comment 'SNMP代理'
  ROW_FORMAT = Dynamic;

drop table if exists hillstone_snmp_v3_group;
create table hillstone_snmp_v3_group
(
    id             bigint      not null AUTO_INCREMENT,
    vendor_id      bigint      NULL COMMENT '所属平台',
    group_name     varchar(64) null comment '组名',
    security_mode  int         null comment '安全模式',
    security_level int         null comment '安全级别 1->不认证；2->认证；3->认证并加密',
    read_view      varchar(64) null comment '可读视图',
    write_view     varchar(64) null comment '写视图',
    constraint hillstone_snmp_v3_group_pk
        primary key (id)
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci comment 'SNMPV3用户组'
  ROW_FORMAT = Dynamic;

drop table if exists hillstone_snmp_v3_user;
create table hillstone_snmp_v3_user
(
    id             bigint       not null AUTO_INCREMENT,
    vendor_id      bigint       NULL COMMENT '所属平台',
    username       varchar(64)  null comment '名称',
    remote_ip_type int          null comment '远程IP类型',
    group_name     varchar(64)  null comment 'V3用户组',
    remote_ip      bigint       null comment '远程IP',
    auth_type      int          null comment '认证类型 1->MD5; 2->SHA-1;',
    auth_pass      varchar(64)  null comment '认证密码',
    priv_type      int          null comment '加密算法 1->AES-128; 2->DES;',
    priv_pass      varchar(255) null comment '加密密码',
    constraint hillstone_snmp_v3_user_pk
        primary key (id)
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci comment 'SNMPV3用户'
  ROW_FORMAT = Dynamic;

drop table if exists hillstone_application_static_feature_rule_row;
create table hillstone_application_static_feature_rule_row
(
    id                     bigint not null AUTO_INCREMENT,
    static_feature_rule_id bigint not null comment '关联的静态特征规则id',
    protocol               int    null comment '6->TCP；17->UDP；1->ICMP dplow/high都是类型，splow/sphigh都是最小码 ；自定义->其他 1-255',
    dp_low                 int    null comment '目的端口最小',
    props                  bigint null comment '原生id',
    dp_high                int    null comment '目的端口最大',
    sp_low                 int    null comment '源端口最小',
    sp_high                int    null comment '源端口最大',
    primary key (id)
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci comment '静态特征规则行'
  ROW_FORMAT = Dynamic;

drop table if exists jumpserver_role;
create table jumpserver_role
(
    id         bigint auto_increment comment '主键'
        primary key,
    vendor_id  bigint       null comment '平台id',
    origin_id  bigint       null comment '原生id',
    name       varchar(256) null comment '角色名称',
    is_deleted tinyint(1)   not null,
    creator_id bigint       null,
    mender_id  bigint       null,
    owner_id   bigint       null,
    gmt_create datetime     null,
    gmt_modify datetime     null,
    props      varchar(64)  null,
    remark     varchar(64)  null,
    status     varchar(64)  null
)
    comment '堡垒机角色表';


-- 添加防火墙平台展示字段
alter table cloud_vendor_statistics
    add policy_count bigint null comment '防火墙安全策略';

alter table cloud_vendor_statistics
    add nat_count bigint null comment '防火墙NAT';

alter table cloud_vendor_statistics
    add safe_zone_count bigint null comment '防火墙安全域';

alter table cloud_vendor_statistics
    add interface_count bigint null comment '防火墙接口';

alter table cloud_vendor_statistics
    add ipsec_count bigint null comment '防火墙Ipsec vpn';


-- 字典
-- 菜单
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1453, '防火墙', null, 1025, '2020-12-09 09:53:11', '2020-12-09 09:53:11', 109, null, 'NORMAL', 0, null, null,
        'firewall', null, 'menu', 3, 0, null, 'App', 'firewall/list', '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1454, '平台列表', null, 1453, '2020-12-09 09:54:56', '2020-12-09 10:33:02', 109, null, 'NORMAL', 0, null, null,
        'list', null, 'view', 1, 0, 'FIREWALL', 'CloudVendor', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1455, '防火墙管理', null, 1453, '2020-12-09 10:34:41', '2020-12-09 11:54:33', 109, null, 'NORMAL', 0, null, null,
        'hillstone', null, 'view', 2, 0, 'HILLSTONE', 'fireWallList', 'hillstone/arp_protection', '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1456, 'ARP防护', null, 1453, '2020-12-09 11:04:50', '2020-12-11 14:41:18', 109, null, 'NORMAL', 0, null, null,
        'arp_protection', null, 'menu', 3, 0, null, 'arpRrotection', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1457, '应用薄', null, 1453, '2020-12-09 11:05:24', '2020-12-11 14:41:49', 109, null, 'NORMAL', 0, null, null,
        'applicationbook', null, 'menu', 6, 0, null, 'applicationbook', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1458, '配置文件管理', null, 1453, '2020-12-09 11:15:56', '2020-12-11 16:01:38', 109, null, 'NORMAL', 0, null, null,
        'config_file', null, 'menu', 18, 0, null, 'configFile', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1459, '接口', null, 1453, '2020-12-09 11:16:10', '2020-12-11 15:58:39', 109, null, 'NORMAL', 0, null, null,
        'interface', null, 'menu', 12, 0, null, 'interface', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1460, 'AAA服务器', null, 1453, '2020-12-09 15:38:00', '2020-12-11 15:58:02', 109, null, 'NORMAL', 0, null, null,
        'aaa_server', null, 'menu', 8, 0, null, 'aaaServer', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1461, 'ISP信息', null, 1453, '2020-12-10 10:22:25', '2020-12-11 18:32:29', 109, null, 'NORMAL', 0, null, null,
        'ips_info', null, 'view', 62, 0, null, 'ispInfo', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1462, '用户', null, 1453, '2020-12-10 10:22:53', '2020-12-11 15:58:12', 109, null, 'NORMAL', 0, null, null,
        'local_user', null, 'menu', 9, 0, null, 'localUser', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1463, '监测对象', null, 1453, '2020-12-10 15:17:35', '2020-12-11 15:58:22', 109, null, 'NORMAL', 0, null, null,
        'monitorbook', null, 'menu', 10, 0, null, 'monitorbook', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1464, '策略路由', null, 1453, '2020-12-10 15:19:02', '2020-12-11 18:32:23', 109, null, 'NORMAL', 0, null, null,
        'policyroute', null, 'view', 9, 0, null, 'policyroute', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1465, '安全域', null, 1453, '2020-12-10 15:20:16', '2020-12-11 15:58:31', 109, null, 'NORMAL', 0, null, null,
        'safezone', null, 'menu', 11, 0, null, 'safezone', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1466, '安全策略', null, 1453, '2020-12-10 15:20:27', '2020-12-11 14:36:29', 109, null, 'NORMAL', 0, null, null,
        'securitypolicy', null, 'menu', 1, 0, null, 'securitypolicy', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1467, '服务薄', null, 1453, '2020-12-10 15:21:44', '2020-12-11 14:41:34', 109, null, 'NORMAL', 0, null, null,
        'servicebook', null, 'menu', 5, 0, null, 'servicebook', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1468, 'NAT', null, 1453, '2020-12-11 14:36:52', '2020-12-11 14:41:13', 109, null, 'NORMAL', 0, null, null,
        'nat', null, 'menu', 2, 0, null, 'nat', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1469, '地址薄', null, 1453, '2020-12-11 14:39:42', '2020-12-11 14:59:05', 109, null, 'NORMAL', 0, null, null,
        'addressbook', null, 'menu', 4, 0, null, 'addressbook', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1470, '时间表', null, 1453, '2020-12-11 14:42:34', '2020-12-11 15:57:32', 109, null, 'NORMAL', 0, null, null,
        'timebook', null, 'menu', 7, 0, null, 'timebook', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1471, '虚拟路由器', null, 1453, '2020-12-11 15:59:17', '2020-12-11 15:59:17', 109, null, 'NORMAL', 0, null, null,
        'virtualroute', null, 'menu', 13, 0, null, 'virtualroute', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1472, '虚拟交换机', null, 1453, '2020-12-11 15:59:36', '2020-12-11 15:59:36', 109, null, 'NORMAL', 0, null, null,
        'virtualswitch', null, 'menu', 14, 0, null, 'virtualswitch', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1473, '路由', null, 1453, '2020-12-11 16:00:31', '2020-12-11 16:00:31', 109, null, 'NORMAL', 0, null, null,
        'firewall_route', null, 'menu', 15, 0, null, 'fwRoute', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1474, 'Ipsec VPN', null, 1453, '2020-12-11 16:00:44', '2020-12-11 16:00:44', 109, null, 'NORMAL', 0, null, null,
        'ipsec', null, 'menu', 16, 0, null, 'ipsec', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1475, '设备管理', null, 1453, '2020-12-11 16:01:14', '2020-12-11 16:01:14', 109, null, 'NORMAL', 0, null, null,
        'equipment', null, 'menu', 17, 0, null, 'equipment', null, '[]', '[]', null);
REPLACE INTO permission (id, name, remark, parent_id, gmt_create, gmt_modify, creator_id, mender_id, status, is_deleted,
                         owner_id, props, path, icon, category, priority, is_tenant, router, component, redirect, meta,
                         params, service_codes)
VALUES (1476, 'SNMP', null, 1453, '2020-12-11 16:01:29', '2020-12-11 16:01:29', 109, null, 'NORMAL', 0, null, null,
        'snmp', null, 'menu', 19, 0, null, 'snmp', null, '[]', '[]', null);

alter table `hillstone_application_book`
    modify column `standard_port` varchar(255) comment '标准端口';

-- 修改tinyint长度为1，否则全部为false
alter table hillstone_system_user modify console tinyint(1) comment '允许console登录';
alter table hillstone_system_user modify telnet tinyint(1) comment '允许telnet登录';
alter table hillstone_system_user modify http tinyint(1) comment '允许http登录';
alter table hillstone_system_user modify https tinyint(1) comment '允许https登录';
alter table hillstone_system_user modify ssh tinyint(1) comment '允许ssh登录';