DROP TABLE IF EXISTS `authority_info`;
CREATE TABLE IF NOT EXISTS `authority_info`
(
    `id`        bigint(20)   NOT NULL,
    `parent_id` bigint(20)   NOT NULL COMMENT '上级ID',
    `name`      varchar(32)  NOT NULL COMMENT '权限名称',
    `remark`    varchar(255) NOT NULL COMMENT '权限说明',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='平台权限表';


INSERT INTO `authority_info` (`id`, `parent_id`, `name`, `remark`)
VALUES (1000, 0, 'oauth.authority', '权限资源管理'),
       (1001, 1000, 'oauth.authority.find', '查询'),
       (1100, 0, 'oauth.role', '角色管理'),
       (1101, 1100, 'oauth.role.find', '查询'),
       (1102, 1100, 'oauth.role.add', '添加'),
       (1103, 1100, 'oauth.role.edit', '编辑'),
       (1104, 1100, 'oauth.role.delete', '删除'),
       (1105, 1100, 'oauth.role.authority', '设置权限'),
       (1200, 0, 'oauth.user', '用户管理'),
       (1201, 1200, 'oauth.user.find', '查询'),
       (1202, 1200, 'oauth.user.add', '添加'),
       (1203, 1200, 'oauth.user.edit', '编辑'),
       (1204, 1200, 'oauth.user.disable', '禁用'),
       (1205, 1200, 'oauth.user.enable', '启用'),
       (1206, 1200, 'oauth.user.set.role', '设置角色'),
       (1207, 1200, 'oauth.user.reset.login.password', '重置登录密码'),
       (1300, 0, 'dict.city', '城市字典管理'),
       (1301, 1300, 'dict.city.find', '查询'),
       (1302, 1300, 'dict.city.edit', '编辑'),
       (1400, 0, 'system.config', '系统参数配置'),
       (1401, 1400, 'system.config.find', '查询'),
       (1402, 1400, 'system.config.edit', '修改'),
       (1500, 0, 'url.mapping', '网站路由管理'),
       (1501, 1500, 'url.mapping.find', '查询'),
       (1502, 1500, 'url.mapping.add', '添加'),
       (1503, 1500, 'url.mapping.edit', '修改'),
       (1504, 1500, 'url.mapping.delete', '删除'),
       (1505, 1500, 'url.mapping.enable', '启用'),
       (1506, 1500, 'url.mapping.disable', '禁用'),
       (1600, 0, 'category', '栏目管理'),
       (1601, 1600, 'category.find', '查询'),
       (1602, 1600, 'category.add', '添加'),
       (1603, 1600, 'category.edit', '编辑'),
       (1604, 1600, 'category.delete', '删除'),
       (1700, 0, 'content.article', '文章管理'),
       (1701, 1700, 'content.article.find', '查询'),
       (1702, 1700, 'content.article.add', '添加'),
       (1703, 1700, 'content.article.edit', '修改'),
       (1704, 1700, 'content.article.delete', '删除'),
       (1705, 1700, 'content.article.check', '审核'),
       (1706, 1700, 'content.article.pushToEs', '推送到搜索'),
       (1707, 1700, 'content.article.export', '导出');

DROP TABLE IF EXISTS `role_authority`;
CREATE TABLE IF NOT EXISTS `role_authority`
(
    `id`           bigint(20) NOT NULL AUTO_INCREMENT,
    `authority_id` bigint(20) NOT NULL COMMENT '权限ID',
    `role_id`      bigint(20) NOT NULL COMMENT '角色ID',
    PRIMARY KEY (`id`),
    KEY `authority_id_index` (`authority_id`),
    KEY `role_id_index` (`role_id`)
) ENGINE = InnoDB
  AUTO_INCREMENT = 624
  DEFAULT CHARSET = utf8mb4 COMMENT ='平台角色权限关联表';


INSERT INTO `role_authority` (`id`, `authority_id`, `role_id`)
VALUES (590, 1207, 1000),
       (591, 1203, 1000),
       (592, 1202, 1000),
       (593, 1206, 1000),
       (594, 1205, 1000),
       (595, 1201, 1000),
       (596, 1105, 1000),
       (597, 1101, 1000),
       (598, 1102, 1000),
       (599, 1103, 1000),
       (600, 1104, 1000),
       (601, 1001, 1000),
       (602, 1204, 1000),
       (603, 1301, 1000),
       (604, 1302, 1000),
       (605, 1401, 1000),
       (606, 1402, 1000),
       (607, 1501, 1000),
       (608, 1505, 1000),
       (609, 1506, 1000),
       (610, 1502, 1000),
       (611, 1503, 1000),
       (612, 1504, 1000),
       (613, 1601, 1000),
       (614, 1602, 1000),
       (615, 1603, 1000),
       (616, 1604, 1000),
       (617, 1701, 1000),
       (618, 1705, 1000),
       (619, 1706, 1000),
       (620, 1702, 1000),
       (621, 1703, 1000),
       (622, 1704, 1000),
       (623, 1707, 1000);

DROP TABLE IF EXISTS `role_info`;
CREATE TABLE IF NOT EXISTS `role_info`
(
    `id`     bigint(20)  NOT NULL AUTO_INCREMENT,
    `name`   varchar(50) NOT NULL COMMENT '角色名称',
    `remark` varchar(100) DEFAULT NULL COMMENT '角色说明',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  AUTO_INCREMENT = 1036
  DEFAULT CHARSET = utf8mb4 COMMENT ='平台角色';


INSERT INTO `role_info` (`id`, `name`, `remark`)
VALUES (1000, '系统管理员', '管理网站的一切事务');

DROP TABLE IF EXISTS `user_base_info`;
CREATE TABLE IF NOT EXISTS `user_base_info`
(
    `id`            bigint(20)   NOT NULL AUTO_INCREMENT,
    `nick_name`     varchar(50)  NOT NULL COMMENT '昵称',
    `avatar`        varchar(200) NOT NULL DEFAULT '' COMMENT '用户头像',
    `gender`        int(1)       NOT NULL DEFAULT 0,
    `state`         int(1)       NOT NULL COMMENT '用户状态',
    `register_time` datetime     NOT NULL,
    `register_ip`   varchar(50)  NOT NULL,
    PRIMARY KEY (`id`),
    KEY `register_time_index` (`register_time`),
    KEY `state_index` (`state`),
    KEY `gender_index` (`gender`),
    KEY `nick_name_index` (`nick_name`)
) ENGINE = InnoDB
  AUTO_INCREMENT = 425782255161
  DEFAULT CHARSET = utf8mb4 COMMENT ='用户基本信息表';


INSERT INTO `user_base_info` (`id`, `nick_name`, `avatar`, `gender`, `state`, `register_time`, `register_ip`)
VALUES (1000, 'admin', '/2020/11/15/4565685fb6a02e4fd04b0267b9f4932f.jpg', 0, 1, '2019-08-06 16:12:57', '127.0.0.1');


DROP TABLE IF EXISTS `user_login_account`;
CREATE TABLE IF NOT EXISTS `user_login_account`
(
    `id`            varchar(32) NOT NULL,
    `uid`           bigint(20)  NOT NULL COMMENT '平台uid',
    `login_account` varchar(50) NOT NULL COMMENT '登录账号\n微信登录保存的为unionid',
    `account_type`  int(1)      NOT NULL DEFAULT 1 COMMENT '账号类型',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uid_account_type_unique` (`uid`, `account_type`),
    UNIQUE KEY `login_account_account_type_unique` (`login_account`, `account_type`),
    KEY `uid_index` (`uid`),
    KEY `login_account_index` (`login_account`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='用户基本信息表';


INSERT INTO `user_login_account` (`id`, `uid`, `login_account`, `account_type`)
VALUES ('13401bc84fcc27970a4dbc282d224333', 1000, 'admin@dliyun.com', 1),
       ('8604638900001fbee1de5551e67ea9e3', 1000, '18888888888', 2),
       ('969b224cb71a9e25e829e24049914c26', 1000, 'admin', 0);

DROP TABLE IF EXISTS `user_login_logs`;
CREATE TABLE IF NOT EXISTS `user_login_logs`
(
    `id`            bigint(20)   NOT NULL AUTO_INCREMENT,
    `login_account` varchar(50)  NOT NULL,
    `account_type`  int(5)       NOT NULL,
    `login_ip`      varchar(20)  NOT NULL,
    `login_local`   varchar(100) NOT NULL,
    `from_source`   varchar(20) DEFAULT NULL,
    `device_id`     varchar(45) DEFAULT NULL COMMENT '登录的设备号',
    `login_time`    datetime     NOT NULL,
    `state`         int(5)       NOT NULL,
    PRIMARY KEY (`id`),
    KEY `login_account_index` (`login_account`),
    KEY `account_type_index` (`account_type`),
    KEY `from_source_index` (`from_source`),
    KEY `login_ip_index` (`login_ip`),
    KEY `login_time_index` (`login_time`),
    KEY `state_index` (`state`)
) ENGINE = InnoDB
  AUTO_INCREMENT = 380
  DEFAULT CHARSET = utf8mb4 COMMENT ='用户登录日志';

INSERT INTO `user_login_logs` (`id`, `login_account`, `account_type`, `login_ip`, `login_local`, `from_source`,
                               `device_id`, `login_time`, `state`)
VALUES (373, 'admin', 0, '192.168.0.212', '0|0|0|内网IP|内网IP', 'manager-web', '', '2021-12-06 12:53:15', 4),
       (374, 'admin', 0, '192.168.0.212', '0|0|0|内网IP|内网IP', 'manager-web', '', '2021-12-06 12:53:25', 1),
       (375, 'admin', 0, '192.168.0.212', '0|0|0|内网IP|内网IP', 'manager-web', '', '2021-12-06 12:53:48', 1),
       (376, 'admin', 0, '192.168.0.212', '0|0|0|内网IP|内网IP', 'manager-web', '', '2021-12-06 12:54:30', 1),
       (377, 'admin', 0, '192.168.0.212', '0|0|0|内网IP|内网IP', 'manager-web', '', '2021-12-06 13:34:55', 1),
       (378, 'admin', 0, '192.168.0.212', '0|0|0|内网IP|内网IP', 'manager-web', '', '2021-12-06 13:40:51', 4),
       (379, 'admin', 0, '192.168.0.212', '0|0|0|内网IP|内网IP', 'manager-web', '', '2021-12-06 13:40:58', 1);

DROP TABLE IF EXISTS `user_operate_logs`;
CREATE TABLE IF NOT EXISTS `user_operate_logs`
(
    `id`             varchar(50)  NOT NULL COMMENT '请请ID',
    `uid`            bigint(20)   NOT NULL DEFAULT 0 COMMENT '用户ID',
    `tags`           varchar(100)          DEFAULT NULL COMMENT '标签说明',
    `from_source`    varchar(20)           DEFAULT NULL COMMENT '来源',
    `request_url`    varchar(200) NOT NULL COMMENT '请求地址',
    `request_ip`     varchar(50)  NOT NULL COMMENT '请求IP地址',
    `request_params` text         NOT NULL COMMENT '请求参数',
    `request_data`   text         NOT NULL COMMENT '请求主体参数',
    `request_time`   datetime     NOT NULL COMMENT '请求时间',
    `response_time`  datetime              DEFAULT NULL COMMENT '响应时间',
    PRIMARY KEY (`id`),
    KEY `uid_index` (`uid`),
    KEY `request_time_index` (`request_time`),
    KEY `respone_time_index` (`response_time`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='用户操作日志';


INSERT INTO `user_operate_logs` (`id`, `uid`, `tags`, `from_source`, `request_url`, `request_ip`, `request_params`,
                                 `request_data`, `request_time`, `response_time`)
VALUES ('0478f4e7-fc66-49bf-8bb2-6b6fe2bd0437', 1000, '城市字典查询', 'manager-web', '/setting/dictCity/findChildren',
        '192.168.0.212', '{"parentId":"0"}', '', '2021-12-06 13:42:56', '2021-12-06 13:42:56'),
       ('16e3d7a6-524e-44d9-8d5e-bc4ff3bd0235', 1000, '查询系统所有用户', 'manager-web', '/user/findPage', '192.168.0.212',
        '{}', '', '2021-12-06 13:35:04', '2021-12-06 13:35:04'),
       ('28886c0f-3f0b-472c-8b36-765886f328ad', 1000, '查询系统角色', 'manager-web', '/user/role/findPage', '192.168.0.212',
        '{}', '', '2021-12-06 13:41:00', '2021-12-06 13:41:00'),
       ('2c01af97-20f6-4618-8082-372b9a2cba6e', 1000, '查询系统角色', 'manager-web', '/user/role/findPage', '192.168.0.212',
        '{}', '', '2021-12-06 13:35:07', '2021-12-06 13:35:07'),
       ('35a6241d-4076-4dc0-9d07-a6f7a1153cbd', 1000, '系统参数查询', 'manager-web', '/setting/systemConfig/findPage',
        '192.168.0.212', '{}', '', '2021-12-06 13:41:09', '2021-12-06 13:41:09'),
       ('3f5196d0-ed21-482d-8f90-fa6ee2a95e00', 1000, '路由地址查询', 'manager-web', '/setting/urlMapping/findPage',
        '192.168.0.212', '{}', '', '2021-12-06 13:41:08', '2021-12-06 13:41:08'),
       ('5415a581-d411-4c04-ad27-294b4d439dfa', 1000, '城市字典查询', 'manager-web', '/setting/dictCity/findChildren',
        '192.168.0.212', '{"parentId":"0"}', '', '2021-12-06 13:41:09', '2021-12-06 13:41:09'),
       ('6177b9e1-2bf9-4dcd-aafa-848e70d59b16', 1000, '城市字典查询', 'manager-web', '/setting/dictCity/findChildren',
        '192.168.0.212', '{"parentId":"0"}', '', '2021-12-06 13:41:04', '2021-12-06 13:41:04'),
       ('66222c9b-ee91-4220-aa21-11e730d82333', 1000, '文章查询', 'manager-web', '/content/article/findPage',
        '192.168.0.212', '{}', '', '2021-12-06 13:43:02', '2021-12-06 13:43:03'),
       ('6d4e0600-0719-4d6d-b903-85f6687709ed', 1000, '查询系统角色', 'manager-web', '/user/role/findPage', '192.168.0.212',
        '{}', '', '2021-12-06 13:40:43', '2021-12-06 13:40:43'),
       ('6def94cf-4a45-46de-8dbd-f30a1b45a4cc', 1000, '查询系统所有用户', 'manager-web', '/user/findPage', '192.168.0.212',
        '{}', '', '2021-12-06 13:35:07', '2021-12-06 13:35:07'),
       ('703d23ad-98d3-466e-8d49-13ca8a1c0b08', 1000, '查询服务分类', 'manager-web', '/setting/category/findChildren',
        '192.168.0.212', '{"parentId":"0"}', '', '2021-12-06 13:41:02', '2021-12-06 13:41:02'),
       ('78566afe-98bb-475d-874f-2ed14df401f2', 1000, '查询服务分类', 'manager-web', '/setting/category/findChildren',
        '192.168.0.212', '{"parentId":"0"}', '', '2021-12-06 13:41:10', '2021-12-06 13:41:10'),
       ('8b263a7c-0c4c-4fa8-967e-ced0dd1cd758', 1000, '系统参数查询', 'manager-web', '/setting/systemConfig/findPage',
        '192.168.0.212', '{}', '', '2021-12-06 13:41:07', '2021-12-06 13:41:07'),
       ('93c41f3d-6bff-41b0-8d41-3f0b515901f4', 1000, '查询系统角色', 'manager-web', '/user/role/findPage', '192.168.0.212',
        '{}', '', '2021-12-06 13:35:05', '2021-12-06 13:35:05'),
       ('9db2a9cb-425e-44b4-9639-0d7c97c006c1', 1000, '查询系统角色', 'manager-web', '/user/role/findPage', '192.168.0.212',
        '{}', '', '2021-12-06 13:40:26', '2021-12-06 13:40:26'),
       ('a78774d5-745e-42b3-939e-4cf3ea84a252', 1000, '查询系统权限', 'manager-web', '/user/authority/findAllAuthorities',
        '192.168.0.212', '{}', '', '2021-12-06 13:35:05', '2021-12-06 13:35:05'),
       ('c663e24a-bb54-4900-9cb7-e9fe439c5892', 1000, '查询服务分类', 'manager-web', '/setting/category/findChildren',
        '192.168.0.212', '{"parentId":"0"}', '', '2021-12-06 13:43:00', '2021-12-06 13:43:00'),
       ('d30a60bc-def4-460e-bae9-cfc0077437bc', 1000, '保存用户的权限值', 'manager-web', '/user/role/saveAuthorities',
        '192.168.0.212', '{"roleId":"1000"}', '', '2021-12-06 13:40:43', '2021-12-06 13:40:43'),
       ('e0587069-bec4-4989-b5ad-1f0818583358', 1000, '查询系统权限', 'manager-web', '/user/authority/findAllAuthorities',
        '192.168.0.212', '{}', '', '2021-12-06 13:35:38', '2021-12-06 13:35:38'),
       ('e0e735a8-0ed8-4e9d-b87a-65a249f82fb0', 1000, '查询系统权限', 'manager-web', '/user/authority/findAllAuthorities',
        '192.168.0.212', '{}', '', '2021-12-06 13:40:28', '2021-12-06 13:40:28');

DROP TABLE IF EXISTS `user_password`;
CREATE TABLE IF NOT EXISTS `user_password`
(
    `id`            varchar(32) NOT NULL,
    `uid`           bigint(20)  NOT NULL,
    `passwd`        varchar(50) NOT NULL,
    `salt`          varchar(8)  NOT NULL,
    `password_type` int(1)      NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `uid_type_unique` (`uid`, `password_type`),
    KEY `uid_index` (`uid`),
    KEY `password_type_index` (`password_type`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='用户基本信息表';


INSERT INTO `user_password` (`id`, `uid`, `passwd`, `salt`, `password_type`)
VALUES ('f37011db6434955899ea64fb3ebe888f', 1000, '4257ff6ac1cd7c0dbb2f508efa6ebfc4', 'OcZII0zZ', 1);

DROP TABLE IF EXISTS `user_role`;
CREATE TABLE IF NOT EXISTS `user_role`
(
    `id`      bigint(20) NOT NULL AUTO_INCREMENT,
    `uid`     bigint(20) NOT NULL,
    `role_id` bigint(20) NOT NULL,
    PRIMARY KEY (`id`),
    KEY `uid_index` (`uid`),
    KEY `role_id_index` (`role_id`)
) ENGINE = InnoDB
  AUTO_INCREMENT = 1035
  DEFAULT CHARSET = utf8mb4 COMMENT ='管理平台用户与角色关联表';


INSERT INTO `user_role` (`id`, `uid`, `role_id`)
VALUES (1017, 1000, 1000);