SET NAMES utf8mb4;

ALTER TABLE sys_user ADD is_permanent char(1) DEFAULT '1' NULL COMMENT '长期和临时用户标识0：临时用户，1：长期用户';
ALTER TABLE sys_user ADD is_built_in char(1) DEFAULT '1' NULL COMMENT '是否内置用户0：内置用户，1：非内置用户';

ALTER TABLE sys_dept MODIFY COLUMN phone varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '联系电话';
ALTER TABLE sys_dept MODIFY COLUMN email varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '邮箱';

ALTER TABLE sys_user MODIFY COLUMN email varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' NULL COMMENT '用户邮箱';
ALTER TABLE sys_user MODIFY COLUMN phonenumber varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' NULL COMMENT '手机号码';

ALTER TABLE sys_role ADD is_built_in char(1) DEFAULT '1' NULL COMMENT '是否内置0：内置角色，1：非内置角色';

ALTER TABLE sys_logs
ADD COLUMN warning_status CHAR(1) NULL DEFAULT '1' COMMENT '0未处理，1已处理';

ALTER TABLE sys_logs_set MODIFY COLUMN capacity varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '1' NULL COMMENT '单位是GB';

-- ------------------------------
-- 22 waring table
-- ------------------------------
drop table if exists sys_warning;
create table sys_warning  (
    warning_id         bigint(20)      not null auto_increment    comment '编号',
    warning_event      varchar(50)     default ''       comment '告警事件',
    warning_content    varchar(50)     default ''       comment '告警内容',
    warning_ip         varchar(50)     default ''       comment '告警IP',
    warning_grade      varchar(50)     default ''       comment '告警等级',
    opera_user_name    varchar(50)     default ''       comment '操作人名称',
    warning_time 	   datetime        default NULL  comment '告警时间',
    warning_status     char(1)         default '0'      comment '告警状态0未处理，1已处理',
    primary key (warning_id)
) engine = innodb comment = '报警日志表';


drop table if exists sys_ip_whitelist;
CREATE TABLE `sys_ip_whitelist`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '单个IP地址',
  `ip_range_start` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'IP网段起始地址',
  `ip_range_end` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'IP网段结束地址',
  `access_start_time` timestamp NULL DEFAULT NULL COMMENT '允许访问的开始时间',
  `access_end_time` timestamp NULL DEFAULT NULL COMMENT '允许访问的结束时间',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '帐号状态（0正常 1停用）',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = innodb CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;


INSERT INTO `sys_menu` VALUES (2020, '白名单管理', 1, 1, 'ipWhitelist', 'system/ipWhitelist/index', NULL, 1, 0, 'C', '0', '0', 'system:whitelist:list', 'clipboard', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:28:51', '【请填写功能名称】菜单', '0');
INSERT INTO `sys_menu` VALUES (2021, '查询', 2020, 1, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:whitelist:query', '#', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:24:56', '', '0');
INSERT INTO `sys_menu` VALUES (2022, '新增', 2020, 2, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:whitelist:add', '#', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:25:05', '', '0');
INSERT INTO `sys_menu` VALUES (2023, '修改', 2020, 3, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:whitelist:edit', '#', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:25:13', '', '0');
INSERT INTO `sys_menu` VALUES (2024, '删除', 2020, 4, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:whitelist:remove', '#', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:25:20', '', '0');
INSERT INTO `sys_menu` VALUES (2025, '导出', 2020, 5, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:whitelist:export', '#', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:25:28', '', '0');
INSERT INTO `sys_menu` VALUES (2026, '用户锁定', 1, 7, 'lockUser', 'system/lockUser/index', NULL, 1, 0, 'C', '0', '0', NULL, 'radio', 'bonus_admin', '2024-11-07 03:10:44', '', NULL, '', '0');


INSERT INTO sys_config (config_name,config_key,config_value,config_type,create_by,create_time,update_by,update_time,remark) VALUES
     ('登录失败锁定-次数','sys.login.failed.times','5','Y','admin','2024-11-05 01:22:10','',NULL,NULL),
	 ('登录失败锁定-时间','sys.login.failed.locktime','20','Y','admin','2024-11-05 01:24:37','',NULL,NULL),
	 ('系统并发访问限制','sys.backend.concurrency','100','Y','admin','2024-11-05 03:23:01','admin','2024-11-06 01:22:16',NULL),
	 ('系统会话时长','sys.visit.tokentime','29','Y','admin','2024-11-06 01:23:35','admin','2024-11-06 01:23:49',NULL);