/*
 Navicat Premium Data Transfer

 Source Server         : localhost
 Source Server Type    : MySQL
 Source Server Version : 50720
 Source Host           : localhost:3306
 Source Schema         : xiaoan

 Target Server Type    : MySQL
 Target Server Version : 50720
 File Encoding         : 65001

 Date: 21/02/2020 11:35:38
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for tb_data_dictionary
-- ----------------------------
DROP TABLE IF EXISTS `tb_data_dictionary`;
CREATE TABLE `tb_data_dictionary`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `rec_status` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '记录的状态，A: 生效，I: 禁用',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `code` varchar(24) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据字典code',
  `data_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据字典key',
  `data_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据字典value',
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '描述',
  `param1` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备用，参数1',
  `param2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备用，参数2',
  `param3` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备用，参数3',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '数据字典表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for tb_resource
-- ----------------------------
DROP TABLE IF EXISTS `tb_resource`;
CREATE TABLE `tb_resource`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '资源描述',
  `icon` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图标',
  `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '资源名称',
  `url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '资源地址',
  `parent_id` bigint(20) NULL DEFAULT NULL COMMENT '父资源id',
  `resource_type` enum('menu','button') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '资源类型',
  `resource_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '资源key',
  `rec_status` tinyint(2) NULL DEFAULT NULL COMMENT '记录的状态，0: 生效，1: 禁用',
  `sort` tinyint(4) NULL DEFAULT NULL COMMENT '排序',
  `create_by` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `FKf5ra2gn0xedeida2op8097sr5`(`parent_id`) USING BTREE,
  CONSTRAINT `FKf5ra2gn0xedeida2op8097sr5` FOREIGN KEY (`parent_id`) REFERENCES `tb_resource` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 30 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '资源表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of tb_resource
-- ----------------------------
INSERT INTO `tb_resource` VALUES (1, '2018-05-10 17:18:36', '2018-05-10 17:22:42', NULL, '&#xe716', '系统管理', 'javascript:void(0);', NULL, 'menu', 'system', 0, 1, NULL);
INSERT INTO `tb_resource` VALUES (2, '2018-05-11 10:05:41', '2018-12-04 11:22:02', NULL, '&#xe66f', '用户管理', '/admin/userEntity/list', 1, 'menu', 'admin:userEntity:list', 0, 2, NULL);
INSERT INTO `tb_resource` VALUES (3, '2018-05-14 09:38:43', '2018-05-14 09:38:46', NULL, '&#xe66f', '用户添加', '/admin/userEntity/add', 2, 'button', 'admin:userEntity:add', 0, 3, NULL);
INSERT INTO `tb_resource` VALUES (4, '2018-05-14 10:46:32', '2018-05-14 10:46:36', NULL, '&#xe66f', '用户编辑', '/admin/userEntity/edit', 2, 'button', 'admin:userEntity:edit', 0, 4, NULL);
INSERT INTO `tb_resource` VALUES (5, '2018-05-14 12:03:20', '2018-05-14 12:03:30', NULL, '&#xe66f', '用户重置密码', '/admin/userEntity/resetPass', 2, 'button', 'admin:userEntity:resetPass', 0, 5, NULL);
INSERT INTO `tb_resource` VALUES (6, '2018-05-14 14:08:16', '2018-05-14 14:08:20', NULL, '&#xe66f', '用户删除', '/admin/userEntity/remove', 2, 'button', 'admin:userEntity:remove', 0, 6, NULL);
INSERT INTO `tb_resource` VALUES (7, '2018-05-14 14:09:07', '2018-05-14 14:09:10', NULL, '&#xe770', '角色管理', '/admin/roleEntity/list', 1, 'menu', 'admin:roleEntity:list', 0, 7, NULL);
INSERT INTO `tb_resource` VALUES (8, '2018-05-14 15:06:59', '2018-05-14 15:07:01', NULL, '&#xe770', '角色添加', '/admin/roleEntity/add', 7, 'button', 'admin:roleEntity:add', 0, 8, NULL);
INSERT INTO `tb_resource` VALUES (9, '2018-05-14 15:06:59', '2018-05-14 15:07:01', NULL, '&#xe770', '角色编辑', '/admin/roleEntity/edit', 7, 'button', 'admin:roleEntity:edit', 0, 9, NULL);
INSERT INTO `tb_resource` VALUES (10, '2018-05-14 15:08:06', '2018-05-14 15:08:08', NULL, '&#xe770', '角色删除', '/admin/roleEntity/remove', 7, 'button', 'admin:roleEntity:remove', 0, 10, NULL);
INSERT INTO `tb_resource` VALUES (11, '2018-05-14 15:08:06', '2018-05-14 15:08:08', NULL, '&#xe671', '资源管理', '/admin/resourceEntity/list', 1, 'menu', 'admin:resourceEntity:list', 0, 11, NULL);
INSERT INTO `tb_resource` VALUES (12, '2018-05-15 09:51:49', '2018-05-15 09:51:51', NULL, '&#xe671', '资源添加', '/admin/resourceEntity/add', 11, 'button', 'admin:resourceEntity:add', 0, 12, NULL);
INSERT INTO `tb_resource` VALUES (13, '2018-05-15 09:51:49', '2018-05-15 09:51:51', NULL, '&#xe671', '资源编辑', '/admin/resourceEntity/edit', 11, 'button', 'admin:resourceEntity:edit', 0, 13, NULL);
INSERT INTO `tb_resource` VALUES (14, '2018-05-15 09:51:49', '2018-12-04 11:20:29', NULL, '&#xe671', '资源删除', '/admin/resourceEntity/remove', 11, 'button', 'admin:resourceEntity:remove', 0, 14, NULL);
INSERT INTO `tb_resource` VALUES (15, '2018-07-27 16:30:51', '2018-07-27 16:30:51', NULL, '&#xe66e', '数据字典管理', '/admin/dataDictionary/list', 1, 'menu', 'admin:dataDictionary:list', 0, 40, NULL);
INSERT INTO `tb_resource` VALUES (16, '2018-07-27 16:31:57', '2018-07-27 16:31:57', NULL, '&#xe66e', '数据字典添加', '/admin/dataDictionary/add', 15, 'button', 'admin:dataDictionary:add', 0, 41, NULL);
INSERT INTO `tb_resource` VALUES (17, '2018-07-27 16:35:59', '2018-07-27 16:35:59', NULL, '&#xe66e', '数据字典编辑', '/admin/dataDictionary/edit', 15, 'button', 'admin:dataDictionary:edit', 0, 42, NULL);
INSERT INTO `tb_resource` VALUES (18, '2018-07-27 16:36:56', '2018-07-27 16:36:56', NULL, '&#xe66e', '数据字典删除', '/admin/dataDictionary/remove', 15, 'button', 'admin:dataDictionary:remove', 0, 43, NULL);
INSERT INTO `tb_resource` VALUES (19, '2019-03-29 11:36:57', '2019-03-29 11:36:57', NULL, '&#xe66f', '设备管理', '/admin/device/list', 1, 'menu', 'admin:device:list', 0, 100, NULL);
INSERT INTO `tb_resource` VALUES (20, '2019-03-29 11:38:00', '2019-03-29 11:38:00', NULL, '&#xe66e', '设备添加', '/admin/device/add', 19, 'button', 'admin:device:add', 0, 3, NULL);
INSERT INTO `tb_resource` VALUES (21, '2019-03-29 11:40:20', '2019-03-29 11:40:20', NULL, '&#xe66e', '设备添加', '/admin/device/edit', 19, 'button', 'admin:device:edit', 0, 43, NULL);
INSERT INTO `tb_resource` VALUES (22, '2019-03-29 11:41:08', '2019-03-29 11:41:08', NULL, '&#xe66e', '设备删除', '/admin/device/remove', 19, 'button', 'admin:device:remove', 0, 47, NULL);
INSERT INTO `tb_resource` VALUES (23, '2019-04-01 15:56:00', '2019-04-01 15:56:00', NULL, '&#xe66f', '设备告警管理', '/admin/deviceEvent/list', 1, 'menu', 'admin:deviceEvent:list', 0, 105, NULL);

-- ----------------------------
-- Table structure for tb_role
-- ----------------------------
DROP TABLE IF EXISTS `tb_role`;
CREATE TABLE `tb_role`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `role_desc` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '角色描述',
  `role_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '角色名',
  `role_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '角色key',
  `rec_status` tinyint(2) NULL DEFAULT NULL COMMENT '记录的状态，0: 生效，1: 禁用',
  `create_by` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `sort` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '角色表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of tb_role
-- ----------------------------
INSERT INTO `tb_role` VALUES (1, '2018-05-11 10:02:27', '2019-04-01 16:07:09', '超级管理员', '超级管理员', 'admin', 0, NULL, '1');
INSERT INTO `tb_role` VALUES (2, '2019-11-12 09:10:25', '2019-12-04 15:40:29', '指定模块增删改', '普通管理员', 'normal', 1, NULL, '2');

-- ----------------------------
-- Table structure for tb_role_resource
-- ----------------------------
DROP TABLE IF EXISTS `tb_role_resource`;
CREATE TABLE `tb_role_resource`  (
  `role_id` bigint(20) NOT NULL COMMENT '角色表id',
  `resource_id` bigint(20) NOT NULL COMMENT '资源表id',
  PRIMARY KEY (`role_id`, `resource_id`) USING BTREE,
  INDEX `FK868kc8iic48ilv5npa80ut6qo`(`resource_id`) USING BTREE,
  CONSTRAINT `tb_role_resource_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `tb_role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `tb_role_resource_ibfk_2` FOREIGN KEY (`resource_id`) REFERENCES `tb_resource` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '角色资源关系表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of tb_role_resource
-- ----------------------------
INSERT INTO `tb_role_resource` VALUES (1, 1);
INSERT INTO `tb_role_resource` VALUES (2, 1);
INSERT INTO `tb_role_resource` VALUES (1, 2);
INSERT INTO `tb_role_resource` VALUES (1, 3);
INSERT INTO `tb_role_resource` VALUES (1, 4);
INSERT INTO `tb_role_resource` VALUES (1, 5);
INSERT INTO `tb_role_resource` VALUES (1, 6);
INSERT INTO `tb_role_resource` VALUES (1, 7);
INSERT INTO `tb_role_resource` VALUES (1, 8);
INSERT INTO `tb_role_resource` VALUES (1, 9);
INSERT INTO `tb_role_resource` VALUES (1, 10);
INSERT INTO `tb_role_resource` VALUES (1, 11);
INSERT INTO `tb_role_resource` VALUES (1, 12);
INSERT INTO `tb_role_resource` VALUES (1, 13);
INSERT INTO `tb_role_resource` VALUES (1, 14);
INSERT INTO `tb_role_resource` VALUES (1, 15);
INSERT INTO `tb_role_resource` VALUES (1, 16);
INSERT INTO `tb_role_resource` VALUES (1, 17);
INSERT INTO `tb_role_resource` VALUES (1, 18);
INSERT INTO `tb_role_resource` VALUES (1, 19);
INSERT INTO `tb_role_resource` VALUES (2, 19);
INSERT INTO `tb_role_resource` VALUES (1, 20);
INSERT INTO `tb_role_resource` VALUES (2, 20);
INSERT INTO `tb_role_resource` VALUES (1, 21);
INSERT INTO `tb_role_resource` VALUES (2, 21);
INSERT INTO `tb_role_resource` VALUES (1, 22);
INSERT INTO `tb_role_resource` VALUES (2, 22);
INSERT INTO `tb_role_resource` VALUES (1, 23);
INSERT INTO `tb_role_resource` VALUES (2, 23);

-- ----------------------------
-- Table structure for tb_user
-- ----------------------------
DROP TABLE IF EXISTS `tb_user`;
CREATE TABLE `tb_user`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `rec_status` tinyint(4) NULL DEFAULT NULL COMMENT '状态，0：激活，1：禁用',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `password` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '登录密码',
  `real_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '真实姓名',
  `user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户名',
  `department` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '部门',
  `email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '邮箱',
  `phone` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '电话',
  `sex` tinyint(4) NULL DEFAULT NULL COMMENT '性别， 0：男， 1：女',
  `create_by` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `status` int(11) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 15 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of tb_user
-- ----------------------------
INSERT INTO `tb_user` VALUES (9, '2018-05-10 15:12:42', 0, '2018-12-04 10:58:51', 'c44b01947c9e6e3f', '超级管理员', 'admin', NULL, NULL, NULL, 1, NULL, 0);
INSERT INTO `tb_user` VALUES (13, '2020-02-20 12:21:23', 0, '2020-02-20 12:21:23', '2c01ba92b4dab363', '普通用户', 'root', 'string', 'string', 'string', 0, 'owen', 0);
INSERT INTO `tb_user` VALUES (14, '2020-02-20 17:38:38', 0, '2020-02-20 17:38:38', '52c356a463b5d4fc', 'string', 'test1', 'string', 'string', 'string', 0, NULL, 0);

-- ----------------------------
-- Table structure for tb_user_role
-- ----------------------------
DROP TABLE IF EXISTS `tb_user_role`;
CREATE TABLE `tb_user_role`  (
  `user_id` bigint(20) NOT NULL COMMENT '用户表id',
  `role_id` bigint(20) NOT NULL COMMENT '角色表id',
  PRIMARY KEY (`user_id`, `role_id`) USING BTREE,
  INDEX `role_id`(`role_id`) USING BTREE,
  CONSTRAINT `tb_user_role_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `tb_user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `tb_user_role_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `tb_role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户角色关系表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of tb_user_role
-- ----------------------------
INSERT INTO `tb_user_role` VALUES (9, 1);
INSERT INTO `tb_user_role` VALUES (13, 2);

SET FOREIGN_KEY_CHECKS = 1;
