/*
 *  Server Type    : MySQL
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- 后台用户表
DROP TABLE IF EXISTS `app_admin_user`;
CREATE TABLE `app_admin_user` (
    `id` int unsigned NOT NULL AUTO_INCREMENT,
    `username` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '用户名',
    `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '用户密码',
    `salt` varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '盐值',
    `avatar` int NOT NULL DEFAULT 0 COMMENT '用户头像',
    `chinese_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '中文名',
    `mobile` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '手机号',
    `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '用户状态 1 正常 2 禁用',
    `last_login_ip` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '最后登录IP',
    `last_login_time` datetime NOT NULL COMMENT '最后登录时间',
    `is_del` tinyint(1) NOT NULL DEFAULT '1' COMMENT '用户状态 1 正常 2 删除 涉及到后台操作日志表',
    `role_id` tinyint(1) NOT NULL DEFAULT '0' COMMENT '角色',
    `create_time` datetime DEFAULT NULL COMMENT '创建时间',
    `update_time` datetime DEFAULT NULL,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='后台用户表';

-- 后台用户角色表
DROP TABLE IF EXISTS `app_admin_role`;
CREATE TABLE `app_admin_role` (
    `id` int NOT NULL AUTO_INCREMENT,
    `name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '角色名',
    `remark` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '备注',
    `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '1=正常 2=禁用',
    `create_time` datetime DEFAULT NULL,
    `update_time` datetime DEFAULT NULL,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 后台用户权限表
DROP TABLE IF EXISTS `app_admin_menu`;
CREATE TABLE `app_admin_menu` (
    `id` int NOT NULL AUTO_INCREMENT,
    `parent_id` int NOT NULL DEFAULT '0' COMMENT '父级权限ID',
    `title` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '权限名',
    `icon` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '图标',
    `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '权限类型 1=菜单 2=按钮',
    `url` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '权限URL',
    `value` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '权限方法',
    `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '权限状态 1=正常 2=禁用',
    `sort` int NOT NULL DEFAULT '0' COMMENT '排序',
    `create_time` datetime DEFAULT NULL,
    `update_time` datetime DEFAULT NULL,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
