text: /*
   Navicat Premium Data Transfer
  
   Source Server         : 192.168.100.80
   Source Server Type    : MySQL
   Source Server Version : 80027
   Source Host           : 192.168.100.80:30000
   Source Schema         : app
  
   Target Server Type    : MySQL
   Target Server Version : 80027
   File Encoding         : 65001
  
   Date: 02/01/2022 23:27:35
  */
  
  SET NAMES utf8mb4;
  SET
  FOREIGN_KEY_CHECKS = 0;
  
  -- ----------------------------
  -- Table structure for menu
  -- ----------------------------
  DROP TABLE IF EXISTS `menu`;
  CREATE TABLE `menu`
  (
      `id`             bigint UNSIGNED NOT NULL AUTO_INCREMENT,
      `title`          varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci   NOT NULL COMMENT '菜单/按钮名称',
      `key`            varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci   NOT NULL COMMENT '唯一标识',
      `path`           varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci   NOT NULL COMMENT '前端路由',
      `icon`           varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci   NOT NULL COMMENT 'icon图标',
      `sort`           int                                                            NOT NULL COMMENT '顺序',
      `pid`            bigint                                                         NOT NULL COMMENT '上级id  没有上级为0',
      `type`           tinyint(1) NOT NULL COMMENT '类型 0 菜单 1按钮',
      `umask`          varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci   NOT NULL COMMENT '可见机构类型 ,分隔',
      `action`         varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '权限字段',
      `show`           tinyint(1) NOT NULL COMMENT '菜单栏是否展示 0 不显示 1显示',
      `default_select` tinyint(1) NOT NULL COMMENT '是否默认选择 0否  1是',
      `default_open`   tinyint(1) NOT NULL COMMENT '二级菜单是否默认展开  0 否 1是',
      PRIMARY KEY (`id`) USING BTREE,
      INDEX            `pid_index` (`pid`) USING BTREE COMMENT 'pid'
  ) ENGINE = InnoDB
    CHARACTER SET = utf8mb4
    COLLATE = utf8mb4_0900_ai_ci COMMENT = '菜单/按钮表'
    ROW_FORMAT = DYNAMIC;
  
  -- ----------------------------
  -- Records of menu
  -- ----------------------------
  INSERT INTO `menu`
  VALUES (1, '个人信息', 'profile', '/profile', '', 0, 0, 0, '0,1,2,3', '', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (2, '首页', 'index', '/index', 'HomeOutlined', 1, 0, 0, '0,1,2,3', '', 1, 1, 0);
  INSERT INTO `menu`
  VALUES (10, '代理管理', 'agent', '/agent', 'TwitterOutlined', 11, 0, 0, '0', '', 1, 0, 0);
  INSERT INTO `menu`
  VALUES (11, '代理列表', 'agent', '/agent', '', 1, 10, 0, '0', 'agent:list', 1, 0, 0);
  INSERT INTO `menu`
  VALUES (12, '新增', '', '', '', 1, 11, 1, '0', 'agent:add', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (13, '更新', '', '', '', 2, 11, 1, '0', 'agent:update', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (14, '删除', '', '', '', 3, 11, 1, '0', 'agent:delete', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (15, '禁用', '', '', '', 4, 11, 1, '0', 'agent:disable', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (16, '商户管理', 'merchant', '/merchant', 'AliwangwangOutlined', 12, 0, 0, '0,1', '', 1, 0, 0);
  INSERT INTO `menu`
  VALUES (17, '商户列表', 'merchant', '/merchant', '', 1, 16, 0, '0,1', 'merchant:list', 1, 0, 0);
  INSERT INTO `menu`
  VALUES (18, '新增', '', '', '', 1, 17, 1, '0,1', 'merchant:add', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (19, '更新', '', '', '', 2, 17, 1, '0,1', 'merchant:update', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (20, '删除', '', '', '', 3, 17, 1, '0,1', 'merchant:delete', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (21, '禁用', '', '', '', 4, 17, 1, '0,1', 'merchant:disable', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (1000, '系统管理', 'system', '/system', 'SettingOutlined', 5000, 0, 0, '0,1,2,3', '', 1, 0, 1);
  INSERT INTO `menu`
  VALUES (1001, '菜单管理', 'menu', '/menu', '', 1, 1000, 0, '0', 'menu:list', 1, 0, 0);
  INSERT INTO `menu`
  VALUES (1002, '新增', '', '', '', 1, 1001, 1, '0', 'menu:add', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (1003, '更新', '', '', '', 2, 1001, 1, '0', 'menu:update', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (1004, '删除', '', '', '', 3, 1001, 1, '0', 'menu:delete', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (1005, '角色管理', 'role', '/role', '', 2, 1000, 0, '0,1,2,3', 'role:list', 1, 0, 0);
  INSERT INTO `menu`
  VALUES (1006, '新增', '', '', '', 1, 1005, 1, '0,1,2,3', 'role:add', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (1007, '更新', '', '', '', 2, 1005, 1, '0,1,2,3', 'role:update', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (1008, '删除', '', '', '', 3, 1005, 1, '0,1,2,3', 'role:delete', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (1009, '分配用户', '', '', '', 4, 1005, 1, '0,1,2,3', 'role:assign_user', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (1010, '分配菜单', '', '', '', 5, 1005, 1, '0,1,2,3', 'role:assign_menu', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (1011, '用户管理', 'user', '/user', '', 4, 1000, 0, '0,1,2,3', 'user:list', 1, 0, 0);
  INSERT INTO `menu`
  VALUES (1012, '新增', '', '', '', 1, 1011, 1, '0,1,2,3', 'user:add', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (1013, '更新', '', '', '', 2, 1011, 1, '0,1,2,3', 'user:update', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (1014, '禁用', '', '', '', 3, 1011, 1, '0,1,2,3', 'user:disable', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (1015, '删除', '', '', '', 4, 1011, 1, '0,1,2,3', 'user:delete', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (1016, '分配角色', '', '', '', 5, 1011, 1, '0,1,2,3', 'user:assign_role', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (1017, 'Oauth2管理', 'oauth', '/oauth', '', 5, 1000, 0, '0', 'oauth:list', 1, 0, 0);
  INSERT INTO `menu`
  VALUES (1018, '新增', '', '', '', 1, 1017, 1, '0', 'oauth:add', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (1019, '更新', '', '', '', 2, 1017, 1, '0', 'oauth:update', 0, 0, 0);
  INSERT INTO `menu`
  VALUES (1020, '删除', '', '', '', 3, 1017, 1, '0', 'oauth:delete', 0, 0, 0);
  
  -- ----------------------------
  -- Table structure for oauth2_client
  -- ----------------------------
  DROP TABLE IF EXISTS `oauth2_client`;
  CREATE TABLE `oauth2_client`
  (
      `id`                   bigint UNSIGNED NOT NULL AUTO_INCREMENT,
      `client_id`            varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci   NOT NULL COMMENT 'client id',
      `secret`               varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci   NOT NULL COMMENT 'secret',
      `grant_type`           varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci   NOT NULL COMMENT 'code,password,refresh_token',
      `scope`                varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci   NOT NULL COMMENT 'all||basic_info',
      `platform`             tinyint(1) NOT NULL COMMENT '平台类型 0 WEB 1 APP 2 小程序',
      `access_token_expire`  bigint                                                         NOT NULL COMMENT 'access_token 有效时长 s',
      `refresh_token_expire` bigint                                                         NOT NULL COMMENT 'refresh_token 有效时长 s',
      `redirect_url`         varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '重定向url地址',
      `create_time`          datetime(3) NOT NULL COMMENT '创建时间',
      `update_time`          datetime(3) NULL DEFAULT NULL COMMENT '更新时间',
      `delete_time`          datetime(3) NULL DEFAULT NULL COMMENT '删除时间',
      PRIMARY KEY (`id`) USING BTREE,
      UNIQUE INDEX `c_index` (`client_id`) USING BTREE COMMENT '客户端id 唯一索引'
  ) ENGINE = InnoDB
    CHARACTER SET = utf8mb4
    COLLATE = utf8mb4_0900_ai_ci COMMENT = 'oauth2客户端'
    ROW_FORMAT = DYNAMIC;
  
  -- ----------------------------
  -- Records of oauth2_client
  -- ----------------------------
  INSERT INTO `oauth2_client`
  VALUES (1, 'de0b55913ac7', '939da067-8899-40a0-9c21-15f0b0001add', 'code,password,refresh_token', 'all', 0, 7200,
          2592000, '', now(3), NULL, NULL);
  INSERT INTO `oauth2_client`
  VALUES (2, '068505e613fb', '446d3494-a774-4051-81fc-c76509327283', 'wechat', 'all', 2, 7200,
          7776000, '', now(3), NULL, NULL);
  
  -- ----------------------------
  -- Table structure for role
  -- ----------------------------
  DROP TABLE IF EXISTS `role`;
  CREATE TABLE `role`
  (
      `id`       bigint UNSIGNED NOT NULL AUTO_INCREMENT,
      `organ_id` bigint                                                       NOT NULL COMMENT '机构id',
      `name`     varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '角色名',
      `action`   varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '权限字段',
      PRIMARY KEY (`id`) USING BTREE,
      UNIQUE INDEX `on_index` (`organ_id`, `name`) USING BTREE COMMENT '唯一索引'
  ) ENGINE = InnoDB
    CHARACTER SET = utf8mb4
    COLLATE = utf8mb4_0900_ai_ci COMMENT = '角色表'
    ROW_FORMAT = DYNAMIC;
  
  -- ----------------------------
  -- Records of role
  -- ----------------------------
  INSERT INTO `role`
  VALUES (1, 1, '超级管理员', 'admin');
  
  -- ----------------------------
  -- Table structure for role_menu
  -- ----------------------------
  DROP TABLE IF EXISTS `role_menu`;
  CREATE TABLE `role_menu`
  (
      `id`      bigint UNSIGNED NOT NULL,
      `role_id` bigint NOT NULL COMMENT '角色id',
      `menu_id` bigint NOT NULL COMMENT '菜单id',
      PRIMARY KEY (`id`) USING BTREE,
      UNIQUE INDEX `rm_index` (`role_id`, `menu_id`) USING BTREE COMMENT '唯一索引'
  ) ENGINE = InnoDB
    CHARACTER SET = utf8mb4
    COLLATE = utf8mb4_0900_ai_ci COMMENT = '角色-菜单表'
    ROW_FORMAT = DYNAMIC;
  
  -- ----------------------------
  -- Records of role_menu
  -- ----------------------------
  INSERT INTO `role_menu`
  VALUES (1, 1, 1);
  INSERT INTO `role_menu`
  VALUES (2, 1, 2);
  INSERT INTO `role_menu`
  VALUES (3, 1, 10);
  INSERT INTO `role_menu`
  VALUES (4, 1, 11);
  INSERT INTO `role_menu`
  VALUES (5, 1, 12);
  INSERT INTO `role_menu`
  VALUES (6, 1, 13);
  INSERT INTO `role_menu`
  VALUES (7, 1, 14);
  INSERT INTO `role_menu`
  VALUES (8, 1, 15);
  INSERT INTO `role_menu`
  VALUES (9, 1, 16);
  INSERT INTO `role_menu`
  VALUES (10, 1, 17);
  INSERT INTO `role_menu`
  VALUES (11, 1, 18);
  INSERT INTO `role_menu`
  VALUES (12, 1, 19);
  INSERT INTO `role_menu`
  VALUES (13, 1, 20);
  INSERT INTO `role_menu`
  VALUES (14, 1, 21);
  INSERT INTO `role_menu`
  VALUES (15, 1, 1000);
  INSERT INTO `role_menu`
  VALUES (16, 1, 1001);
  INSERT INTO `role_menu`
  VALUES (17, 1, 1002);
  INSERT INTO `role_menu`
  VALUES (18, 1, 1003);
  INSERT INTO `role_menu`
  VALUES (19, 1, 1004);
  INSERT INTO `role_menu`
  VALUES (20, 1, 1005);
  INSERT INTO `role_menu`
  VALUES (21, 1, 1006);
  INSERT INTO `role_menu`
  VALUES (22, 1, 1007);
  INSERT INTO `role_menu`
  VALUES (23, 1, 1008);
  INSERT INTO `role_menu`
  VALUES (24, 1, 1009);
  INSERT INTO `role_menu`
  VALUES (25, 1, 1010);
  INSERT INTO `role_menu`
  VALUES (26, 1, 1011);
  INSERT INTO `role_menu`
  VALUES (27, 1, 1012);
  INSERT INTO `role_menu`
  VALUES (28, 1, 1013);
  INSERT INTO `role_menu`
  VALUES (29, 1, 1014);
  INSERT INTO `role_menu`
  VALUES (30, 1, 1015);
  INSERT INTO `role_menu`
  VALUES (31, 1, 1016);
  INSERT INTO `role_menu`
  VALUES (32, 1, 1017);
  INSERT INTO `role_menu`
  VALUES (33, 1, 1018);
  INSERT INTO `role_menu`
  VALUES (34, 1, 1019);
  INSERT INTO `role_menu`
  VALUES (35, 1, 1020);
  
  -- ----------------------------
  -- Table structure for organ
  -- ----------------------------
  DROP TABLE IF EXISTS `organ`;
  CREATE TABLE `organ`
  (
      `id`            bigint UNSIGNED NOT NULL AUTO_INCREMENT,
      `pid`           bigint                                                       NOT NULL COMMENT '上级id',
      `agent_id`      bigint                                                       NOT NULL COMMENT '所属代理id, 仅对商户有效 冗余字段',
      `code`          varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '机构编号',
      `name`          varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '机构名称',
      `type`          tinyint(1) NOT NULL DEFAULT 0 COMMENT '机构类型 0 平台 1 代理  2 B端集团商户 3 B端子商户',
      `contact_name`  varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '联系人',
      `contact_phone` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '联系电话',
      `status`        tinyint(1) NOT NULL COMMENT '状态 0 禁用   1 正常',
      `create_time`   datetime(3) NOT NULL COMMENT '创建时间',
      `update_time`   datetime(3) NULL DEFAULT NULL COMMENT '更新时间',
      `delete_time`   datetime(3) NULL DEFAULT NULL COMMENT '删除时间',
      PRIMARY KEY (`id`) USING BTREE,
      UNIQUE INDEX `mc_index` (`code`) USING BTREE COMMENT '机构编号 唯一索引'
  ) ENGINE = InnoDB
    CHARACTER SET = utf8mb4
    COLLATE = utf8mb4_0900_ai_ci COMMENT = '机构表'
    ROW_FORMAT = DYNAMIC;
  
  -- ----------------------------
  -- Records of organ
  -- ----------------------------
  INSERT INTO `organ`
  VALUES (1, 0, 0, 'V0000001', '运营平台', 0, 'admin', '17700000000', 1, now(3), NULL, NULL);
  
  -- ----------------------------
  -- Table structure for user
  -- ----------------------------
  DROP TABLE IF EXISTS `user`;
  CREATE TABLE `user`
  (
      `id`          bigint UNSIGNED NOT NULL,
      `organ_id`    bigint                                                        NOT NULL COMMENT '所属机构id',
      `type`        tinyint(1) NOT NULL COMMENT '账号类型 0管理员 1普通用户',
      `account`     varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci  NOT NULL COMMENT '账号',
      `password`    varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci  NOT NULL COMMENT '密码',
      `phone`       varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci  NOT NULL COMMENT '手机号',
      `openid`      varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci  NOT NULL COMMENT '微信openid',
      `unionid`     varchar(54) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci  NOT NULL COMMENT '微信unionid',
      `nick_name`   varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci  NOT NULL COMMENT '昵称',
      `gender`      tinyint(1) NOT NULL COMMENT '性别 1男 2女 0未知',
      `avatar`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '头像',
      `status`      tinyint(1) NOT NULL COMMENT '状态 0禁用  1正常',
      `create_time` datetime(3) NOT NULL COMMENT '创建时间',
      `update_time` datetime(3) NULL DEFAULT NULL COMMENT '更新时间',
      `delete_time` datetime(3) NULL DEFAULT NULL COMMENT '删除时间',
      PRIMARY KEY (`id`) USING BTREE,
      INDEX         `oa_index` (`organ_id`, `account`) USING BTREE COMMENT '机构id, 账号',
      INDEX         `op_index` (`organ_id`, `phone`) USING BTREE COMMENT '机构id,手机号'
  ) ENGINE = InnoDB
    CHARACTER SET = utf8mb4
    COLLATE = utf8mb4_0900_ai_ci COMMENT = '用户表'
    ROW_FORMAT = DYNAMIC;
  
  -- ----------------------------
  -- Records of user
  -- ----------------------------
  INSERT INTO `user`
  VALUES (1, 1, 0, 'admin', md5('123456'), '17700000000', '', '', '管理员', 1, '', 1,
          now(3), NULL, NULL);
  
  -- ----------------------------
  -- Table structure for user_role
  -- ----------------------------
  DROP TABLE IF EXISTS `user_role`;
  CREATE TABLE `user_role`
  (
      `id`      bigint UNSIGNED NOT NULL AUTO_INCREMENT,
      `user_id` bigint NOT NULL COMMENT '用户id',
      `role_id` bigint NOT NULL COMMENT '角色id',
      PRIMARY KEY (`id`) USING BTREE,
      UNIQUE INDEX `ur_index` (`user_id`, `role_id`) USING BTREE COMMENT '用户id, 角色id'
  ) ENGINE = InnoDB
    CHARACTER SET = utf8mb4
    COLLATE = utf8mb4_0900_ai_ci COMMENT = '用户-角色表'
    ROW_FORMAT = DYNAMIC;
  
  -- ----------------------------
  -- Records of user_role
  -- ----------------------------
  INSERT INTO `user_role`
  VALUES (1, 1, 1);
  
  SET
  FOREIGN_KEY_CHECKS = 1;
  