From 45ac0f23e12ac2a45c6affe9e39d0897e4fad618 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期四, 16 二月 2023 17:06:10 +0800
Subject: [PATCH] !286 合并 多租户功能 * add 新增 ruoyi-common-tenant 多租户模块 全框架适配多租户改动 * update 优化 隐藏页面主键 * remove 移除 缓存列表功能(多租户缓存功能繁杂多样 没有办法在页面管理) * update 重构 全局缓存KEY 与 常用缓存KEY做区分 * update 重构 OssFactory 加载方式 改为每次比对配置做实例更新 * update 优化 SaTokenDao 改为 Bean 注入 便于扩展 * update 重构 项目初始化数据改为懒加载 不提供热加载 * update 重构 验证码开关使用配置文件(经调查少有动态开启需求) * update 优化 启用 sqlserver 高版本语法 简化sql脚本语法 * update 优化 DataPermissionHelper 增加 开启/关闭 忽略数据权限功能 * update 优化 连接池增加 keepaliveTime 探活参数 * update 优化 调整连接池最长生命周期 防止出现警告 * update 优化 代码生成页面模板 校验不必要的表单数据 * add 新增 StringUtils splitTo 与 splitList 方法 优化业务代码

---
 script/sql/postgres/postgres_ry_vue_5.X.sql |  717 +++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 426 insertions(+), 291 deletions(-)

diff --git a/script/sql/postgres/postgres_ry_vue_5.X.sql b/script/sql/postgres/postgres_ry_vue_5.X.sql
index a50251f..4ad90df 100644
--- a/script/sql/postgres/postgres_ry_vue_5.X.sql
+++ b/script/sql/postgres/postgres_ry_vue_5.X.sql
@@ -1,10 +1,106 @@
 -- ----------------------------
+-- 绉熸埛琛�
+-- ----------------------------
+drop table if exists sys_tenant;
+create table if not exists sys_tenant
+(
+    id                int8,
+    tenant_id         varchar(20)   not null,
+    contact_user_name varchar(20)   default null::varchar,
+    contact_phone     varchar(20)   default null::varchar,
+    company_name      varchar(50)   default null::varchar,
+    license_number    varchar(30)   default null::varchar,
+    address           varchar(200)  default null::varchar,
+    intro             varchar(200)  default null::varchar,
+    domain            varchar(200)  default null::varchar,
+    remark            varchar(200)  default null::varchar,
+    package_id        int8,
+    expire_time       timestamp,
+    account_count     int4          default -1,
+    status            char          default '0'::bpchar,
+    del_flag          char          default '0'::bpchar,
+    create_dept       int8,
+    create_by         int8,
+    create_time       timestamp,
+    update_by         int8,
+    update_time       timestamp,
+    constraint "pk_sys_tenant" primary key (id)
+);
+
+
+comment on table   sys_tenant                    is '绉熸埛琛�';
+comment on column  sys_tenant.tenant_id          is '绉熸埛缂栧彿';
+comment on column  sys_tenant.contact_phone      is '鑱旂郴鐢佃瘽';
+comment on column  sys_tenant.company_name       is '浼佷笟鍚嶇О';
+comment on column  sys_tenant.company_name       is '鑱旂郴浜�';
+comment on column  sys_tenant.license_number     is '缁熶竴绀句細淇$敤浠g爜';
+comment on column  sys_tenant.address            is '鍦板潃';
+comment on column  sys_tenant.intro              is '浼佷笟绠�浠�';
+comment on column  sys_tenant.domain             is '鍩熷悕';
+comment on column  sys_tenant.remark             is '澶囨敞';
+comment on column  sys_tenant.package_id         is '绉熸埛濂楅缂栧彿';
+comment on column  sys_tenant.expire_time        is '杩囨湡鏃堕棿';
+comment on column  sys_tenant.account_count      is '鐢ㄦ埛鏁伴噺锛�-1涓嶉檺鍒讹級';
+comment on column  sys_tenant.status             is '绉熸埛鐘舵�侊紙0姝e父 1鍋滅敤锛�';
+comment on column  sys_tenant.del_flag           is '鍒犻櫎鏍囧織锛�0浠h〃瀛樺湪 2浠h〃鍒犻櫎锛�';
+comment on column  sys_tenant.create_dept        is '鍒涘缓閮ㄩ棬';
+comment on column  sys_tenant.create_by          is '鍒涘缓鑰�';
+comment on column  sys_tenant.create_time        is '鍒涘缓鏃堕棿';
+comment on column  sys_tenant.update_by          is '鏇存柊鑰�';
+comment on column  sys_tenant.update_time        is '鏇存柊鏃堕棿';
+
+
+-- ----------------------------
+-- 鍒濆鍖�-绉熸埛琛ㄦ暟鎹�
+-- ----------------------------
+
+insert into sys_tenant values(1, '000000', '绠$悊缁�', '15888888888', 'XXX鏈夐檺鍏徃', null, null, '澶氱鎴烽�氱敤鍚庡彴绠$悊绠$悊绯荤粺', null, null, null, null, -1, '0', '0', 103, 1, now(), null, null);
+
+
+-- ----------------------------
+-- 绉熸埛濂楅琛�
+-- ----------------------------
+drop table if exists sys_tenant_package;
+create table if not exists sys_tenant_package
+(
+    package_id          int8,
+    package_name        varchar(20)     default ''::varchar,
+    menu_ids            varchar(3000)   default ''::varchar,
+    remark              varchar(200)    default ''::varchar,
+    menu_check_strictly bool            default true,
+    status              char            default '0'::bpchar,
+    del_flag            char            default '0'::bpchar,
+    create_dept         int8,
+    create_by           int8,
+    create_time         timestamp,
+    update_by           int8,
+    update_time         timestamp,
+    constraint "pk_sys_tenant_package" primary key (package_id)
+);
+
+
+comment on table   sys_tenant_package                    is '绉熸埛濂楅琛�';
+comment on column  sys_tenant_package.package_id         is '绉熸埛濂楅id';
+comment on column  sys_tenant_package.package_name       is '濂楅鍚嶇О';
+comment on column  sys_tenant_package.menu_ids           is '鍏宠仈鑿滃崟id';
+comment on column  sys_tenant_package.remark             is '澶囨敞';
+comment on column  sys_tenant_package.status             is '鐘舵�侊紙0姝e父 1鍋滅敤锛�';
+comment on column  sys_tenant_package.del_flag           is '鍒犻櫎鏍囧織锛�0浠h〃瀛樺湪 2浠h〃鍒犻櫎锛�';
+comment on column  sys_tenant_package.create_dept        is '鍒涘缓閮ㄩ棬';
+comment on column  sys_tenant_package.create_by          is '鍒涘缓鑰�';
+comment on column  sys_tenant_package.create_time        is '鍒涘缓鏃堕棿';
+comment on column  sys_tenant_package.update_by          is '鏇存柊鑰�';
+comment on column  sys_tenant_package.update_time        is '鏇存柊鏃堕棿';
+
+
+-- ----------------------------
 -- 1銆侀儴闂ㄨ〃
 -- ----------------------------
 drop table if exists sys_dept;
 create table if not exists sys_dept
 (
     dept_id     int8,
+    tenant_id   varchar(20) not null,
     parent_id   int8        default 0,
     ancestors   varchar(500)default ''::varchar,
     dept_name   varchar(30) default ''::varchar,
@@ -22,36 +118,37 @@
     constraint "sys_dept_pk" primary key (dept_id)
 );
 
-comment on table sys_dept is '閮ㄩ棬琛�';
-comment on column sys_dept.dept_id is '閮ㄩ棬ID';
-comment on column sys_dept.parent_id is '鐖堕儴闂↖D';
-comment on column sys_dept.ancestors is '绁栫骇鍒楄〃';
-comment on column sys_dept.dept_name is '閮ㄩ棬鍚嶇О';
-comment on column sys_dept.order_num is '鏄剧ず椤哄簭';
-comment on column sys_dept.leader is '璐熻矗浜�';
-comment on column sys_dept.phone is '鑱旂郴鐢佃瘽';
-comment on column sys_dept.email is '閭';
-comment on column sys_dept.status is '閮ㄩ棬鐘舵�侊紙0姝e父 1鍋滅敤锛�';
-comment on column sys_dept.del_flag is '鍒犻櫎鏍囧織锛�0浠h〃瀛樺湪 2浠h〃鍒犻櫎锛�';
+comment on table sys_dept               is '閮ㄩ棬琛�';
+comment on column sys_dept.dept_id      is '閮ㄩ棬ID';
+comment on column sys_dept.tenant_id    is '绉熸埛缂栧彿';
+comment on column sys_dept.parent_id    is '鐖堕儴闂↖D';
+comment on column sys_dept.ancestors    is '绁栫骇鍒楄〃';
+comment on column sys_dept.dept_name    is '閮ㄩ棬鍚嶇О';
+comment on column sys_dept.order_num    is '鏄剧ず椤哄簭';
+comment on column sys_dept.leader       is '璐熻矗浜�';
+comment on column sys_dept.phone        is '鑱旂郴鐢佃瘽';
+comment on column sys_dept.email        is '閭';
+comment on column sys_dept.status       is '閮ㄩ棬鐘舵�侊紙0姝e父 1鍋滅敤锛�';
+comment on column sys_dept.del_flag     is '鍒犻櫎鏍囧織锛�0浠h〃瀛樺湪 2浠h〃鍒犻櫎锛�';
 comment on column sys_dept.create_dept  is '鍒涘缓閮ㄩ棬';
-comment on column sys_dept.create_by is '鍒涘缓鑰�';
-comment on column sys_dept.create_time is '鍒涘缓鏃堕棿';
-comment on column sys_dept.update_by is '鏇存柊鑰�';
-comment on column sys_dept.update_time is '鏇存柊鏃堕棿';
+comment on column sys_dept.create_by    is '鍒涘缓鑰�';
+comment on column sys_dept.create_time  is '鍒涘缓鏃堕棿';
+comment on column sys_dept.update_by    is '鏇存柊鑰�';
+comment on column sys_dept.update_time  is '鏇存柊鏃堕棿';
 
 -- ----------------------------
 -- 鍒濆鍖�-閮ㄩ棬琛ㄦ暟鎹�
 -- ----------------------------
-insert into sys_dept values(100,  0,   '0',          '鑻ヤ緷绉戞妧',   0, '鑻ヤ緷', '15888888888', 'ry@qq.com', '0', '0', 103, 1, now(), null, null);
-insert into sys_dept values(101,  100, '0,100',      '娣卞湷鎬诲叕鍙�', 1, '鑻ヤ緷', '15888888888', 'ry@qq.com', '0', '0', 103, 1, now(), null, null);
-insert into sys_dept values(102,  100, '0,100',      '闀挎矙鍒嗗叕鍙�', 2, '鑻ヤ緷', '15888888888', 'ry@qq.com', '0', '0', 103, 1, now(), null, null);
-insert into sys_dept values(103,  101, '0,100,101',  '鐮斿彂閮ㄩ棬',   1, '鑻ヤ緷', '15888888888', 'ry@qq.com', '0', '0', 103, 1, now(), null, null);
-insert into sys_dept values(104,  101, '0,100,101',  '甯傚満閮ㄩ棬',   2, '鑻ヤ緷', '15888888888', 'ry@qq.com', '0', '0', 103, 1, now(), null, null);
-insert into sys_dept values(105,  101, '0,100,101',  '娴嬭瘯閮ㄩ棬',   3, '鑻ヤ緷', '15888888888', 'ry@qq.com', '0', '0', 103, 1, now(), null, null);
-insert into sys_dept values(106,  101, '0,100,101',  '璐㈠姟閮ㄩ棬',   4, '鑻ヤ緷', '15888888888', 'ry@qq.com', '0', '0', 103, 1, now(), null, null);
-insert into sys_dept values(107,  101, '0,100,101',  '杩愮淮閮ㄩ棬',   5, '鑻ヤ緷', '15888888888', 'ry@qq.com', '0', '0', 103, 1, now(), null, null);
-insert into sys_dept values(108,  102, '0,100,102',  '甯傚満閮ㄩ棬',   1, '鑻ヤ緷', '15888888888', 'ry@qq.com', '0', '0', 103, 1, now(), null, null);
-insert into sys_dept values(109,  102, '0,100,102',  '璐㈠姟閮ㄩ棬',   2, '鑻ヤ緷', '15888888888', 'ry@qq.com', '0', '0', 103, 1, now(), null, null);
+insert into sys_dept values(100, '000000', 0,   '0',          'XXX绉戞妧',   0, '鐤媯鐨勭嫯瀛怢i', '15888888888', 'xxx@qq.com', '0', '0', 103, 1, now(), null, null);
+insert into sys_dept values(101, '000000', 100, '0,100',      '娣卞湷鎬诲叕鍙�', 1, '鐤媯鐨勭嫯瀛怢i', '15888888888', 'xxx@qq.com', '0', '0', 103, 1, now(), null, null);
+insert into sys_dept values(102, '000000', 100, '0,100',      '闀挎矙鍒嗗叕鍙�', 2, '鐤媯鐨勭嫯瀛怢i', '15888888888', 'xxx@qq.com', '0', '0', 103, 1, now(), null, null);
+insert into sys_dept values(103, '000000', 101, '0,100,101',  '鐮斿彂閮ㄩ棬',   1, '鐤媯鐨勭嫯瀛怢i', '15888888888', 'xxx@qq.com', '0', '0', 103, 1, now(), null, null);
+insert into sys_dept values(104, '000000', 101, '0,100,101',  '甯傚満閮ㄩ棬',   2, '鐤媯鐨勭嫯瀛怢i', '15888888888', 'xxx@qq.com', '0', '0', 103, 1, now(), null, null);
+insert into sys_dept values(105, '000000', 101, '0,100,101',  '娴嬭瘯閮ㄩ棬',   3, '鐤媯鐨勭嫯瀛怢i', '15888888888', 'xxx@qq.com', '0', '0', 103, 1, now(), null, null);
+insert into sys_dept values(106, '000000', 101, '0,100,101',  '璐㈠姟閮ㄩ棬',   4, '鐤媯鐨勭嫯瀛怢i', '15888888888', 'xxx@qq.com', '0', '0', 103, 1, now(), null, null);
+insert into sys_dept values(107, '000000', 101, '0,100,101',  '杩愮淮閮ㄩ棬',   5, '鐤媯鐨勭嫯瀛怢i', '15888888888', 'xxx@qq.com', '0', '0', 103, 1, now(), null, null);
+insert into sys_dept values(108, '000000', 102, '0,100,102',  '甯傚満閮ㄩ棬',   1, '鐤媯鐨勭嫯瀛怢i', '15888888888', 'xxx@qq.com', '0', '0', 103, 1, now(), null, null);
+insert into sys_dept values(109, '000000', 102, '0,100,102',  '璐㈠姟閮ㄩ棬',   2, '鐤媯鐨勭嫯瀛怢i', '15888888888', 'xxx@qq.com', '0', '0', 103, 1, now(), null, null);
 
 -- ----------------------------
 -- 2銆佺敤鎴蜂俊鎭〃
@@ -60,9 +157,10 @@
 create table if not exists sys_user
 (
     user_id     int8,
+    tenant_id   varchar(20)  not null,
     dept_id     int8,
-    user_name   varchar(30) not null,
-    nick_name   varchar(30) not null,
+    user_name   varchar(30)  not null,
+    nick_name   varchar(30)  not null,
     user_type   varchar(10)  default 'sys_user'::varchar,
     email       varchar(50)  default ''::varchar,
     phonenumber varchar(11)  default ''::varchar,
@@ -82,34 +180,35 @@
     constraint "sys_user_pk" primary key (user_id)
 );
 
-comment on table sys_user is '鐢ㄦ埛淇℃伅琛�';
-comment on column sys_user.user_id is '鐢ㄦ埛ID';
-comment on column sys_user.dept_id is '閮ㄩ棬ID';
-comment on column sys_user.user_name is '鐢ㄦ埛璐﹀彿';
-comment on column sys_user.nick_name is '鐢ㄦ埛鏄电О';
-comment on column sys_user.user_type is '鐢ㄦ埛绫诲瀷锛坰ys_user绯荤粺鐢ㄦ埛锛�';
-comment on column sys_user.email is '鐢ㄦ埛閭';
-comment on column sys_user.phonenumber is '鎵嬫満鍙风爜';
-comment on column sys_user.sex is '鐢ㄦ埛鎬у埆锛�0鐢� 1濂� 2鏈煡锛�';
-comment on column sys_user.avatar is '澶村儚鍦板潃';
-comment on column sys_user.password is '瀵嗙爜';
-comment on column sys_user.status is '甯愬彿鐘舵�侊紙0姝e父 1鍋滅敤锛�';
-comment on column sys_user.del_flag is '鍒犻櫎鏍囧織锛�0浠h〃瀛樺湪 2浠h〃鍒犻櫎锛�';
-comment on column sys_user.login_ip is '鏈�鍚庣櫥闄咺P';
-comment on column sys_user.login_date is '鏈�鍚庣櫥闄嗘椂闂�';
+comment on table sys_user               is '鐢ㄦ埛淇℃伅琛�';
+comment on column sys_user.user_id      is '鐢ㄦ埛ID';
+comment on column sys_user.tenant_id    is '绉熸埛缂栧彿';
+comment on column sys_user.dept_id      is '閮ㄩ棬ID';
+comment on column sys_user.user_name    is '鐢ㄦ埛璐﹀彿';
+comment on column sys_user.nick_name    is '鐢ㄦ埛鏄电О';
+comment on column sys_user.user_type    is '鐢ㄦ埛绫诲瀷锛坰ys_user绯荤粺鐢ㄦ埛锛�';
+comment on column sys_user.email        is '鐢ㄦ埛閭';
+comment on column sys_user.phonenumber  is '鎵嬫満鍙风爜';
+comment on column sys_user.sex          is '鐢ㄦ埛鎬у埆锛�0鐢� 1濂� 2鏈煡锛�';
+comment on column sys_user.avatar       is '澶村儚鍦板潃';
+comment on column sys_user.password     is '瀵嗙爜';
+comment on column sys_user.status       is '甯愬彿鐘舵�侊紙0姝e父 1鍋滅敤锛�';
+comment on column sys_user.del_flag     is '鍒犻櫎鏍囧織锛�0浠h〃瀛樺湪 2浠h〃鍒犻櫎锛�';
+comment on column sys_user.login_ip     is '鏈�鍚庣櫥闄咺P';
+comment on column sys_user.login_date   is '鏈�鍚庣櫥闄嗘椂闂�';
 comment on column sys_user.create_dept  is '鍒涘缓閮ㄩ棬';
-comment on column sys_user.create_by is '鍒涘缓鑰�';
-comment on column sys_user.create_time is '鍒涘缓鏃堕棿';
-comment on column sys_user.update_by is '鏇存柊鑰�';
-comment on column sys_user.update_time is '鏇存柊鏃堕棿';
-comment on column sys_user.remark is '澶囨敞';
+comment on column sys_user.create_by    is '鍒涘缓鑰�';
+comment on column sys_user.create_time  is '鍒涘缓鏃堕棿';
+comment on column sys_user.update_by    is '鏇存柊鑰�';
+comment on column sys_user.update_time  is '鏇存柊鏃堕棿';
+comment on column sys_user.remark       is '澶囨敞';
 
 -- ----------------------------
 
 -- 鍒濆鍖�-鐢ㄦ埛淇℃伅琛ㄦ暟鎹�
 -- ----------------------------
-insert into sys_user values(1,  103, 'admin', '鐤媯鐨勭嫯瀛怢i', 'sys_user', 'crazyLionLi@163.com', '15888888888', '1', null, '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '127.0.0.1', now(), 103, 1, now(), null, null, '绠$悊鍛�');
-insert into sys_user values(2,  105, 'ry',    '鐤媯鐨勭嫯瀛怢i', 'sys_user', 'crazyLionLi@qq.com',  '15666666666', '1', null, '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '127.0.0.1', now(), 103, 1, now(), null, null, '娴嬭瘯鍛�');
+insert into sys_user values(1, '000000', 103, 'admin', '鐤媯鐨勭嫯瀛怢i', 'sys_user', 'crazyLionLi@163.com', '15888888888', '1', null, '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '127.0.0.1', now(), 103, 1, now(), null, null, '绠$悊鍛�');
+insert into sys_user values(2, '000000', 105, 'lionli', '鐤媯鐨勭嫯瀛怢i', 'sys_user', 'crazyLionLi@qq.com',  '15666666666', '1', null, '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '127.0.0.1', now(), 103, 1, now(), null, null, '娴嬭瘯鍛�');
 
 
 -- ----------------------------
@@ -119,6 +218,7 @@
 create table if not exists sys_post
 (
     post_id     int8,
+    tenant_id   varchar(20) not null,
     post_code   varchar(64) not null,
     post_name   varchar(50) not null,
     post_sort   int4        not null,
@@ -132,26 +232,27 @@
     constraint "sys_post_pk" primary key (post_id)
 );
 
-comment on table sys_post is '宀椾綅淇℃伅琛�';
-comment on column sys_post.post_id is '宀椾綅ID';
-comment on column sys_post.post_code is '宀椾綅缂栫爜';
-comment on column sys_post.post_name is '宀椾綅鍚嶇О';
-comment on column sys_post.post_sort is '鏄剧ず椤哄簭';
-comment on column sys_post.status is '鐘舵�侊紙0姝e父 1鍋滅敤锛�';
+comment on table sys_post               is '宀椾綅淇℃伅琛�';
+comment on column sys_post.post_id      is '宀椾綅ID';
+comment on column sys_post.tenant_id    is '绉熸埛缂栧彿';
+comment on column sys_post.post_code    is '宀椾綅缂栫爜';
+comment on column sys_post.post_name    is '宀椾綅鍚嶇О';
+comment on column sys_post.post_sort    is '鏄剧ず椤哄簭';
+comment on column sys_post.status       is '鐘舵�侊紙0姝e父 1鍋滅敤锛�';
 comment on column sys_post.create_dept  is '鍒涘缓閮ㄩ棬';
-comment on column sys_post.create_by is '鍒涘缓鑰�';
-comment on column sys_post.create_time is '鍒涘缓鏃堕棿';
-comment on column sys_post.update_by is '鏇存柊鑰�';
-comment on column sys_post.update_time is '鏇存柊鏃堕棿';
-comment on column sys_post.remark is '澶囨敞';
+comment on column sys_post.create_by    is '鍒涘缓鑰�';
+comment on column sys_post.create_time  is '鍒涘缓鏃堕棿';
+comment on column sys_post.update_by    is '鏇存柊鑰�';
+comment on column sys_post.update_time  is '鏇存柊鏃堕棿';
+comment on column sys_post.remark       is '澶囨敞';
 
 -- ----------------------------
 -- 鍒濆鍖�-宀椾綅淇℃伅琛ㄦ暟鎹�
 -- ----------------------------
-insert into sys_post values(1, 'ceo',  '钁d簨闀�',    1, '0', 103, 1, now(), null, null, '');
-insert into sys_post values(2, 'se',   '椤圭洰缁忕悊',  2, '0', 103, 1, now(), null, null, '');
-insert into sys_post values(3, 'hr',   '浜哄姏璧勬簮',  3, '0', 103, 1, now(), null, null, '');
-insert into sys_post values(4, 'user', '鏅�氬憳宸�',  4, '0', 103, 1, now(), null, null, '');
+insert into sys_post values(1, '000000', 'ceo',  '钁d簨闀�',    1, '0', 103, 1, now(), null, null, '');
+insert into sys_post values(2, '000000', 'se',   '椤圭洰缁忕悊',  2, '0', 103, 1, now(), null, null, '');
+insert into sys_post values(3, '000000', 'hr',   '浜哄姏璧勬簮',  3, '0', 103, 1, now(), null, null, '');
+insert into sys_post values(4, '000000', 'user', '鏅�氬憳宸�',  4, '0', 103, 1, now(), null, null, '');
 
 -- ----------------------------
 -- 4銆佽鑹蹭俊鎭〃
@@ -160,6 +261,7 @@
 create table if not exists sys_role
 (
     role_id             int8,
+    tenant_id           varchar(20)  not null,
     role_name           varchar(30)  not null,
     role_key            varchar(100) not null,
     role_sort           int4         not null,
@@ -177,28 +279,29 @@
     constraint "sys_role_pk" primary key (role_id)
 );
 
-comment on table sys_role is '瑙掕壊淇℃伅琛�';
-comment on column sys_role.role_id is '瑙掕壊ID';
-comment on column sys_role.role_name is '瑙掕壊鍚嶇О';
-comment on column sys_role.role_key is '瑙掕壊鏉冮檺瀛楃涓�';
-comment on column sys_role.role_sort is '鏄剧ず椤哄簭';
-comment on column sys_role.data_scope is '鏁版嵁鑼冨洿锛�1锛氬叏閮ㄦ暟鎹潈闄� 2锛氳嚜瀹氭暟鎹潈闄� 3锛氭湰閮ㄩ棬鏁版嵁鏉冮檺 4锛氭湰閮ㄩ棬鍙婁互涓嬫暟鎹潈闄愶級';
-comment on column sys_role.menu_check_strictly is '鑿滃崟鏍戦�夋嫨椤规槸鍚﹀叧鑱旀樉绀�';
-comment on column sys_role.dept_check_strictly is '閮ㄩ棬鏍戦�夋嫨椤规槸鍚﹀叧鑱旀樉绀�';
-comment on column sys_role.status is '瑙掕壊鐘舵�侊紙0姝e父 1鍋滅敤锛�';
-comment on column sys_role.del_flag is '鍒犻櫎鏍囧織锛�0浠h〃瀛樺湪 2浠h〃鍒犻櫎锛�';
-comment on column sys_role.create_dept is '鍒涘缓閮ㄩ棬';
-comment on column sys_role.create_by is '鍒涘缓鑰�';
-comment on column sys_role.create_time is '鍒涘缓鏃堕棿';
-comment on column sys_role.update_by is '鏇存柊鑰�';
-comment on column sys_role.update_time is '鏇存柊鏃堕棿';
-comment on column sys_role.remark is '澶囨敞';
+comment on table sys_role                       is '瑙掕壊淇℃伅琛�';
+comment on column sys_role.role_id              is '瑙掕壊ID';
+comment on column sys_role.tenant_id            is '绉熸埛缂栧彿';
+comment on column sys_role.role_name            is '瑙掕壊鍚嶇О';
+comment on column sys_role.role_key             is '瑙掕壊鏉冮檺瀛楃涓�';
+comment on column sys_role.role_sort            is '鏄剧ず椤哄簭';
+comment on column sys_role.data_scope           is '鏁版嵁鑼冨洿锛�1锛氬叏閮ㄦ暟鎹潈闄� 2锛氳嚜瀹氭暟鎹潈闄� 3锛氭湰閮ㄩ棬鏁版嵁鏉冮檺 4锛氭湰閮ㄩ棬鍙婁互涓嬫暟鎹潈闄愶級';
+comment on column sys_role.menu_check_strictly  is '鑿滃崟鏍戦�夋嫨椤规槸鍚﹀叧鑱旀樉绀�';
+comment on column sys_role.dept_check_strictly  is '閮ㄩ棬鏍戦�夋嫨椤规槸鍚﹀叧鑱旀樉绀�';
+comment on column sys_role.status               is '瑙掕壊鐘舵�侊紙0姝e父 1鍋滅敤锛�';
+comment on column sys_role.del_flag             is '鍒犻櫎鏍囧織锛�0浠h〃瀛樺湪 2浠h〃鍒犻櫎锛�';
+comment on column sys_role.create_dept          is '鍒涘缓閮ㄩ棬';
+comment on column sys_role.create_by            is '鍒涘缓鑰�';
+comment on column sys_role.create_time          is '鍒涘缓鏃堕棿';
+comment on column sys_role.update_by            is '鏇存柊鑰�';
+comment on column sys_role.update_time          is '鏇存柊鏃堕棿';
+comment on column sys_role.remark               is '澶囨敞';
 
 -- ----------------------------
 -- 鍒濆鍖�-瑙掕壊淇℃伅琛ㄦ暟鎹�
 -- ----------------------------
-insert into sys_role values('1', '瓒呯骇绠$悊鍛�',  'admin',  1, '1', 't', 't', '0', '0', 103, 1, now(), null, null, '瓒呯骇绠$悊鍛�');
-insert into sys_role values('2', '鏅�氳鑹�',    'common', 2, '2', 't', 't', '0', '0', 103, 1, now(), null, null, '鏅�氳鑹�');
+insert into sys_role values('1', '000000', '瓒呯骇绠$悊鍛�',  'superadmin',  1, '1', 't', 't', '0', '0', 103, 1, now(), null, null, '瓒呯骇绠$悊鍛�');
+insert into sys_role values('2', '000000', '鏅�氳鑹�',    'common', 2, '2', 't', 't', '0', '0', 103, 1, now(), null, null, '鏅�氳鑹�');
 
 
 -- ----------------------------
@@ -230,57 +333,60 @@
     constraint "sys_menu_pk" primary key (menu_id)
 );
 
-comment on table sys_menu is '鑿滃崟鏉冮檺琛�';
-comment on column sys_menu.menu_id is '鑿滃崟ID';
-comment on column sys_menu.menu_name is '鑿滃崟鍚嶇О';
-comment on column sys_menu.parent_id is '鐖惰彍鍗旾D';
-comment on column sys_menu.order_num is '鏄剧ず椤哄簭';
-comment on column sys_menu.path is '璺敱鍦板潃';
-comment on column sys_menu.component is '缁勪欢璺緞';
-comment on column sys_menu.query_param is '璺敱鍙傛暟';
-comment on column sys_menu.is_frame is '鏄惁涓哄閾撅紙0鏄� 1鍚︼級';
-comment on column sys_menu.is_cache is '鏄惁缂撳瓨锛�0缂撳瓨 1涓嶇紦瀛橈級';
-comment on column sys_menu.menu_type is '鑿滃崟绫诲瀷锛圡鐩綍 C鑿滃崟 F鎸夐挳锛�';
-comment on column sys_menu.visible is '鏄剧ず鐘舵�侊紙0鏄剧ず 1闅愯棌锛�';
-comment on column sys_menu.status is '鑿滃崟鐘舵�侊紙0姝e父 1鍋滅敤锛�';
-comment on column sys_menu.perms is '鏉冮檺鏍囪瘑';
-comment on column sys_menu.icon is '鑿滃崟鍥炬爣';
-comment on column sys_menu.create_dept is '鍒涘缓閮ㄩ棬';
-comment on column sys_menu.create_by is '鍒涘缓鑰�';
-comment on column sys_menu.create_time is '鍒涘缓鏃堕棿';
-comment on column sys_menu.update_by is '鏇存柊鑰�';
-comment on column sys_menu.update_time is '鏇存柊鏃堕棿';
-comment on column sys_menu.remark is '澶囨敞';
+comment on table sys_menu               is '鑿滃崟鏉冮檺琛�';
+comment on column sys_menu.menu_id      is '鑿滃崟ID';
+comment on column sys_menu.menu_name    is '鑿滃崟鍚嶇О';
+comment on column sys_menu.parent_id    is '鐖惰彍鍗旾D';
+comment on column sys_menu.order_num    is '鏄剧ず椤哄簭';
+comment on column sys_menu.path         is '璺敱鍦板潃';
+comment on column sys_menu.component    is '缁勪欢璺緞';
+comment on column sys_menu.query_param  is '璺敱鍙傛暟';
+comment on column sys_menu.is_frame     is '鏄惁涓哄閾撅紙0鏄� 1鍚︼級';
+comment on column sys_menu.is_cache     is '鏄惁缂撳瓨锛�0缂撳瓨 1涓嶇紦瀛橈級';
+comment on column sys_menu.menu_type    is '鑿滃崟绫诲瀷锛圡鐩綍 C鑿滃崟 F鎸夐挳锛�';
+comment on column sys_menu.visible      is '鏄剧ず鐘舵�侊紙0鏄剧ず 1闅愯棌锛�';
+comment on column sys_menu.status       is '鑿滃崟鐘舵�侊紙0姝e父 1鍋滅敤锛�';
+comment on column sys_menu.perms        is '鏉冮檺鏍囪瘑';
+comment on column sys_menu.icon         is '鑿滃崟鍥炬爣';
+comment on column sys_menu.create_dept  is '鍒涘缓閮ㄩ棬';
+comment on column sys_menu.create_by    is '鍒涘缓鑰�';
+comment on column sys_menu.create_time  is '鍒涘缓鏃堕棿';
+comment on column sys_menu.update_by    is '鏇存柊鑰�';
+comment on column sys_menu.update_time  is '鏇存柊鏃堕棿';
+comment on column sys_menu.remark       is '澶囨敞';
 
 -- ----------------------------
 -- 鍒濆鍖�-鑿滃崟淇℃伅琛ㄦ暟鎹�
 -- ----------------------------
 -- 涓�绾ц彍鍗�
 insert into sys_menu values('1', '绯荤粺绠$悊', '0', '1', 'system',           null, '', '1', '0', 'M', '0', '0', '', 'system',   103, 1, now(), null, null, '绯荤粺绠$悊鐩綍');
-insert into sys_menu values('2', '绯荤粺鐩戞帶', '0', '2', 'monitor',          null, '', '1', '0', 'M', '0', '0', '', 'monitor',  103, 1, now(), null, null, '绯荤粺鐩戞帶鐩綍');
-insert into sys_menu values('3', '绯荤粺宸ュ叿', '0', '3', 'tool',             null, '', '1', '0', 'M', '0', '0', '', 'tool',     103, 1, now(), null, null, '绯荤粺宸ュ叿鐩綍');
-insert into sys_menu values('4', 'PLUS瀹樼綉', '0', '4', 'https://gitee.com/JavaLionLi/RuoYi-Vue-Plus', null, '', '0', '0', 'M', '0', '0', '', 'guide',    103, 1, now(), null, null, 'RuoYi-Vue-Plus瀹樼綉鍦板潃');
+insert into sys_menu values('6', '绯荤粺绠$悊', '0', '2', 'tenant',           null, '', '1', '0', 'M', '0', '0', '', 'chart',    103, 1, now(), null, null, '绉熸埛绠$悊鐩綍');
+insert into sys_menu values('2', '绯荤粺鐩戞帶', '0', '3', 'monitor',          null, '', '1', '0', 'M', '0', '0', '', 'monitor',  103, 1, now(), null, null, '绯荤粺鐩戞帶鐩綍');
+insert into sys_menu values('3', '绯荤粺宸ュ叿', '0', '4', 'tool',             null, '', '1', '0', 'M', '0', '0', '', 'tool',     103, 1, now(), null, null, '绯荤粺宸ュ叿鐩綍');
+insert into sys_menu values('4', 'PLUS瀹樼綉', '0', '5', 'https://gitee.com/JavaLionLi/RuoYi-Vue-Plus', null, '', '0', '0', 'M', '0', '0', '', 'guide',    103, 1, now(), null, null, 'RuoYi-Vue-Plus瀹樼綉鍦板潃');
 -- 浜岀骇鑿滃崟
-insert into sys_menu values('100',  '鐢ㄦ埛绠$悊', '1',   '1', 'user',       'system/user/index',        '', '1', '0', 'C', '0', '0', 'system:user:list',        'user',          103, 1, now(), null, null, '鐢ㄦ埛绠$悊鑿滃崟');
-insert into sys_menu values('101',  '瑙掕壊绠$悊', '1',   '2', 'role',       'system/role/index',        '', '1', '0', 'C', '0', '0', 'system:role:list',        'peoples',       103, 1, now(), null, null, '瑙掕壊绠$悊鑿滃崟');
-insert into sys_menu values('102',  '鑿滃崟绠$悊', '1',   '3', 'menu',       'system/menu/index',        '', '1', '0', 'C', '0', '0', 'system:menu:list',        'tree-table',    103, 1, now(), null, null, '鑿滃崟绠$悊鑿滃崟');
-insert into sys_menu values('103',  '閮ㄩ棬绠$悊', '1',   '4', 'dept',       'system/dept/index',        '', '1', '0', 'C', '0', '0', 'system:dept:list',        'tree',          103, 1, now(), null, null, '閮ㄩ棬绠$悊鑿滃崟');
-insert into sys_menu values('104',  '宀椾綅绠$悊', '1',   '5', 'post',       'system/post/index',        '', '1', '0', 'C', '0', '0', 'system:post:list',        'post',          103, 1, now(), null, null, '宀椾綅绠$悊鑿滃崟');
-insert into sys_menu values('105',  '瀛楀吀绠$悊', '1',   '6', 'dict',       'system/dict/index',        '', '1', '0', 'C', '0', '0', 'system:dict:list',        'dict',          103, 1, now(), null, null, '瀛楀吀绠$悊鑿滃崟');
-insert into sys_menu values('106',  '鍙傛暟璁剧疆', '1',   '7', 'config',     'system/config/index',      '', '1', '0', 'C', '0', '0', 'system:config:list',      'edit',          103, 1, now(), null, null, '鍙傛暟璁剧疆鑿滃崟');
-insert into sys_menu values('107',  '閫氱煡鍏憡', '1',   '8', 'notice',     'system/notice/index',      '', '1', '0', 'C', '0', '0', 'system:notice:list',      'message',       103, 1, now(), null, null, '閫氱煡鍏憡鑿滃崟');
-insert into sys_menu values('108',  '鏃ュ織绠$悊', '1',   '9', 'log',        '',                         '', '1', '0', 'M', '0', '0', '',                        'log',           103, 1, now(), null, null, '鏃ュ織绠$悊鑿滃崟');
-insert into sys_menu values('109',  '鍦ㄧ嚎鐢ㄦ埛', '2',   '1', 'online',     'monitor/online/index',     '', '1', '0', 'C', '0', '0', 'monitor:online:list',     'online',        103, 1, now(), null, null, '鍦ㄧ嚎鐢ㄦ埛鑿滃崟');
-insert into sys_menu values('112',  '缂撳瓨鍒楄〃', '2',   '6', 'cacheList',  'monitor/cache/list',       '', '1', '0', 'C', '0', '0', 'monitor:cache:list',      'redis-list',    103, 1, now(), null, null, '缂撳瓨鍒楄〃鑿滃崟');
-insert into sys_menu values('113',  '缂撳瓨鐩戞帶', '2',   '5', 'cache',      'monitor/cache/index',      '', '1', '0', 'C', '0', '0', 'monitor:cache:list',      'redis',         103, 1, now(), null, null, '缂撳瓨鐩戞帶鑿滃崟');
-insert into sys_menu values('114',  '琛ㄥ崟鏋勫缓', '3',   '1', 'build',      'tool/build/index',         '', '1', '0', 'C', '0', '0', 'tool:build:list',         'build',         103, 1, now(), null, null, '琛ㄥ崟鏋勫缓鑿滃崟');
-insert into sys_menu values('115',  '浠g爜鐢熸垚', '3',   '2', 'gen',        'tool/gen/index',           '', '1', '0', 'C', '0', '0', 'tool:gen:list',           'code',          103, 1, now(), null, null, '浠g爜鐢熸垚鑿滃崟');
+insert into sys_menu values('100',  '鐢ㄦ埛绠$悊',     '1',   '1', 'user',             'system/user/index',            '', '1', '0', 'C', '0', '0', 'system:user:list',            'user',          103, 1, now(), null, null, '鐢ㄦ埛绠$悊鑿滃崟');
+insert into sys_menu values('101',  '瑙掕壊绠$悊',     '1',   '2', 'role',             'system/role/index',            '', '1', '0', 'C', '0', '0', 'system:role:list',            'peoples',       103, 1, now(), null, null, '瑙掕壊绠$悊鑿滃崟');
+insert into sys_menu values('102',  '鑿滃崟绠$悊',     '1',   '3', 'menu',             'system/menu/index',            '', '1', '0', 'C', '0', '0', 'system:menu:list',            'tree-table',    103, 1, now(), null, null, '鑿滃崟绠$悊鑿滃崟');
+insert into sys_menu values('103',  '閮ㄩ棬绠$悊',     '1',   '4', 'dept',             'system/dept/index',            '', '1', '0', 'C', '0', '0', 'system:dept:list',            'tree',          103, 1, now(), null, null, '閮ㄩ棬绠$悊鑿滃崟');
+insert into sys_menu values('104',  '宀椾綅绠$悊',     '1',   '5', 'post',             'system/post/index',            '', '1', '0', 'C', '0', '0', 'system:post:list',            'post',          103, 1, now(), null, null, '宀椾綅绠$悊鑿滃崟');
+insert into sys_menu values('105',  '瀛楀吀绠$悊',     '1',   '6', 'dict',             'system/dict/index',            '', '1', '0', 'C', '0', '0', 'system:dict:list',            'dict',          103, 1, now(), null, null, '瀛楀吀绠$悊鑿滃崟');
+insert into sys_menu values('106',  '鍙傛暟璁剧疆',     '1',   '7', 'config',           'system/config/index',          '', '1', '0', 'C', '0', '0', 'system:config:list',          'edit',          103, 1, now(), null, null, '鍙傛暟璁剧疆鑿滃崟');
+insert into sys_menu values('107',  '閫氱煡鍏憡',     '1',   '8', 'notice',           'system/notice/index',          '', '1', '0', 'C', '0', '0', 'system:notice:list',          'message',       103, 1, now(), null, null, '閫氱煡鍏憡鑿滃崟');
+insert into sys_menu values('108',  '鏃ュ織绠$悊',     '1',   '9', 'log',              '',                             '', '1', '0', 'M', '0', '0', '',                            'log',           103, 1, now(), null, null, '鏃ュ織绠$悊鑿滃崟');
+insert into sys_menu values('109',  '鍦ㄧ嚎鐢ㄦ埛',     '2',   '1', 'online',           'monitor/online/index',         '', '1', '0', 'C', '0', '0', 'monitor:online:list',         'online',        103, 1, now(), null, null, '鍦ㄧ嚎鐢ㄦ埛鑿滃崟');
+insert into sys_menu values('113',  '缂撳瓨鐩戞帶',     '2',   '5', 'cache',            'monitor/cache/index',          '', '1', '0', 'C', '0', '0', 'monitor:cache:list',          'redis',         103, 1, now(), null, null, '缂撳瓨鐩戞帶鑿滃崟');
+insert into sys_menu values('114',  '琛ㄥ崟鏋勫缓',     '3',   '1', 'build',            'tool/build/index',             '', '1', '0', 'C', '0', '0', 'tool:build:list',             'build',         103, 1, now(), null, null, '琛ㄥ崟鏋勫缓鑿滃崟');
+insert into sys_menu values('115',  '浠g爜鐢熸垚',     '3',   '2', 'gen',              'tool/gen/index',               '', '1', '0', 'C', '0', '0', 'tool:gen:list',               'code',          103, 1, now(), null, null, '浠g爜鐢熸垚鑿滃崟');
+insert into sys_menu values('121',  '绉熸埛绠$悊',     '6',   '1', 'tenant',           'system/tenant/index',          '', '1', '0', 'C', '0', '0', 'system:tenant:list',          'list',          103, 1, now(), null, null, '绉熸埛绠$悊鑿滃崟');
+insert into sys_menu values('122',  '绉熸埛濂楅绠$悊',  '6',   '2', 'tenantPackage',    'system/tenantPackage/index',   '', '1', '0', 'C', '0', '0', 'system:tenantPackage:list',   'form',          103, 1, now(), null, null, '绉熸埛濂楅绠$悊鑿滃崟');
+
 -- springboot-admin鐩戞帶
-insert into sys_menu values('117',  'Admin鐩戞帶', '2',  '5', 'Admin',      'monitor/admin/index',      '', '1', '0', 'C', '0', '0', 'monitor:admin:list',      'dashboard',     103, 1, now(), null, null, 'Admin鐩戞帶鑿滃崟');
+insert into sys_menu values('117',  'Admin鐩戞帶',   '2',   '5',  'Admin',            'monitor/admin/index',         '', '1', '0', 'C', '0', '0', 'monitor:admin:list',          'dashboard',     103, 1, now(), null, null, 'Admin鐩戞帶鑿滃崟');
 -- oss鑿滃崟
-insert into sys_menu values('118',  '鏂囦欢绠$悊', '1', '10', 'oss', 'system/oss/index', '', '1', '0', 'C', '0', '0', 'system:oss:list', 'upload', 103, 1, now(), null, null, '鏂囦欢绠$悊鑿滃崟');
+insert into sys_menu values('118',  '鏂囦欢绠$悊',     '1',   '10', 'oss',              'system/oss/index',            '', '1', '0', 'C', '0', '0', 'system:oss:list',             'upload',        103, 1, now(), null, null, '鏂囦欢绠$悊鑿滃崟');
 -- xxl-job-admin鎺у埗鍙�
-insert into sys_menu values('120',  '浠诲姟璋冨害涓績', '2',  '5', 'XxlJob',      'monitor/xxljob/index',      '', '1', '0', 'C', '0', '0', 'monitor:xxljob:list',      'job',     103, 1, now(), null, null, 'Xxl-Job鎺у埗鍙拌彍鍗�');
+insert into sys_menu values('120',  '浠诲姟璋冨害涓績',  '2',   '5',  'XxlJob',           'monitor/xxljob/index',        '', '1', '0', 'C', '0', '0', 'monitor:xxljob:list',         'job',           103, 1, now(), null, null, 'Xxl-Job鎺у埗鍙拌彍鍗�');
 
 -- 涓夌骇鑿滃崟
 insert into sys_menu values('500',  '鎿嶄綔鏃ュ織', '108', '1', 'operlog',    'monitor/operlog/index',    '', '1', '0', 'C', '0', '0', 'monitor:operlog:list',    'form',          103, 1, now(), null, null, '鎿嶄綔鏃ュ織鑿滃崟');
@@ -359,6 +465,18 @@
 insert into sys_menu values('1603', '鏂囦欢鍒犻櫎', '118', '4', '#', '', '', '1', '0', 'F', '0', '0', 'system:oss:remove',       '#', 103, 1, now(), null, null, '');
 insert into sys_menu values('1604', '閰嶇疆娣诲姞', '118', '5', '#', '', '', '1', '0', 'F', '0', '0', 'system:oss:add',          '#', 103, 1, now(), null, null, '');
 insert into sys_menu values('1605', '閰嶇疆缂栬緫', '118', '6', '#', '', '', '1', '0', 'F', '0', '0', 'system:oss:edit',         '#', 103, 1, now(), null, null, '');
+-- 绉熸埛绠$悊鐩稿叧鎸夐挳
+insert into sys_menu values('1606', '绉熸埛鏌ヨ', '121', '1', '#', '', '', '1', '0', 'F', '0', '0', 'system:tenant:query',   '#', 103, 1, now(), null, null, '');
+insert into sys_menu values('1607', '绉熸埛鏂板', '121', '2', '#', '', '', '1', '0', 'F', '0', '0', 'system:tenant:add',     '#', 103, 1, now(), null, null, '');
+insert into sys_menu values('1608', '绉熸埛淇敼', '121', '3', '#', '', '', '1', '0', 'F', '0', '0', 'system:tenant:edit',    '#', 103, 1, now(), null, null, '');
+insert into sys_menu values('1609', '绉熸埛鍒犻櫎', '121', '4', '#', '', '', '1', '0', 'F', '0', '0', 'system:tenant:remove',  '#', 103, 1, now(), null, null, '');
+insert into sys_menu values('1610', '绉熸埛瀵煎嚭', '121', '5', '#', '', '', '1', '0', 'F', '0', '0', 'system:tenant:export',  '#', 103, 1, now(), null, null, '');
+-- 绉熸埛濂楅绠$悊鐩稿叧鎸夐挳
+insert into sys_menu values('1611', '绉熸埛濂楅鏌ヨ', '122', '1', '#', '', '', '1', '0', 'F', '0', '0', 'system:tenantPackage:query',   '#', 103, 1, now(), null, null, '');
+insert into sys_menu values('1612', '绉熸埛濂楅鏂板', '122', '2', '#', '', '', '1', '0', 'F', '0', '0', 'system:tenantPackage:add',     '#', 103, 1, now(), null, null, '');
+insert into sys_menu values('1613', '绉熸埛濂楅淇敼', '122', '3', '#', '', '', '1', '0', 'F', '0', '0', 'system:tenantPackage:edit',    '#', 103, 1, now(), null, null, '');
+insert into sys_menu values('1614', '绉熸埛濂楅鍒犻櫎', '122', '4', '#', '', '', '1', '0', 'F', '0', '0', 'system:tenantPackage:remove',  '#', 103, 1, now(), null, null, '');
+insert into sys_menu values('1615', '绉熸埛濂楅瀵煎嚭', '122', '5', '#', '', '', '1', '0', 'F', '0', '0', 'system:tenantPackage:export',  '#', 103, 1, now(), null, null, '');
 
 
 -- ----------------------------
@@ -372,9 +490,9 @@
     constraint sys_user_role_pk primary key (user_id, role_id)
 );
 
-comment on table sys_user_role is '鐢ㄦ埛鍜岃鑹插叧鑱旇〃';
-comment on column sys_user_role.user_id is '鐢ㄦ埛ID';
-comment on column sys_user_role.role_id is '瑙掕壊ID';
+comment on table sys_user_role              is '鐢ㄦ埛鍜岃鑹插叧鑱旇〃';
+comment on column sys_user_role.user_id     is '鐢ㄦ埛ID';
+comment on column sys_user_role.role_id     is '瑙掕壊ID';
 
 -- ----------------------------
 -- 鍒濆鍖�-鐢ㄦ埛鍜岃鑹插叧鑱旇〃鏁版嵁
@@ -394,9 +512,9 @@
     constraint sys_role_menu_pk primary key (role_id, menu_id)
 );
 
-comment on table sys_role_menu is '瑙掕壊鍜岃彍鍗曞叧鑱旇〃';
-comment on column sys_role_menu.role_id is '瑙掕壊ID';
-comment on column sys_role_menu.menu_id is '鑿滃崟ID';
+comment on table sys_role_menu              is '瑙掕壊鍜岃彍鍗曞叧鑱旇〃';
+comment on column sys_role_menu.role_id     is '瑙掕壊ID';
+comment on column sys_role_menu.menu_id     is '鑿滃崟ID';
 
 -- ----------------------------
 -- 鍒濆鍖�-瑙掕壊鍜岃彍鍗曞叧鑱旇〃鏁版嵁
@@ -492,9 +610,9 @@
     constraint sys_role_dept_pk primary key (role_id, dept_id)
 );
 
-comment on table sys_role_dept is '瑙掕壊鍜岄儴闂ㄥ叧鑱旇〃';
-comment on column sys_role_dept.role_id is '瑙掕壊ID';
-comment on column sys_role_dept.dept_id is '閮ㄩ棬ID';
+comment on table sys_role_dept              is '瑙掕壊鍜岄儴闂ㄥ叧鑱旇〃';
+comment on column sys_role_dept.role_id     is '瑙掕壊ID';
+comment on column sys_role_dept.dept_id     is '閮ㄩ棬ID';
 
 -- ----------------------------
 -- 鍒濆鍖�-瑙掕壊鍜岄儴闂ㄥ叧鑱旇〃鏁版嵁
@@ -515,9 +633,9 @@
     constraint sys_user_post_pk primary key (user_id, post_id)
 );
 
-comment on table sys_user_post is '鐢ㄦ埛涓庡矖浣嶅叧鑱旇〃';
-comment on column sys_user_post.user_id is '鐢ㄦ埛ID';
-comment on column sys_user_post.post_id is '宀椾綅ID';
+comment on table sys_user_post              is '鐢ㄦ埛涓庡矖浣嶅叧鑱旇〃';
+comment on column sys_user_post.user_id     is '鐢ㄦ埛ID';
+comment on column sys_user_post.post_id     is '宀椾綅ID';
 
 -- ----------------------------
 -- 鍒濆鍖�-鐢ㄦ埛涓庡矖浣嶅叧鑱旇〃鏁版嵁
@@ -533,6 +651,7 @@
 create table if not exists sys_oper_log
 (
     oper_id        int8,
+    tenant_id      varchar(20)   not null,
     title          varchar(50)   default ''::varchar,
     business_type  int4          default 0,
     method         varchar(100)  default ''::varchar,
@@ -551,23 +670,24 @@
     constraint sys_oper_log_pk primary key (oper_id)
 );
 
-comment on table sys_oper_log is '鎿嶄綔鏃ュ織璁板綍';
-comment on column sys_oper_log.oper_id is '鏃ュ織涓婚敭';
-comment on column sys_oper_log.title is '妯″潡鏍囬';
-comment on column sys_oper_log.business_type is '涓氬姟绫诲瀷锛�0鍏跺畠 1鏂板 2淇敼 3鍒犻櫎锛�';
-comment on column sys_oper_log.method is '鏂规硶鍚嶇О';
-comment on column sys_oper_log.request_method is '璇锋眰鏂瑰紡';
-comment on column sys_oper_log.operator_type is '鎿嶄綔绫诲埆锛�0鍏跺畠 1鍚庡彴鐢ㄦ埛 2鎵嬫満绔敤鎴凤級';
-comment on column sys_oper_log.oper_name is '鎿嶄綔浜哄憳';
-comment on column sys_oper_log.dept_name is '閮ㄩ棬鍚嶇О';
-comment on column sys_oper_log.oper_url is '璇锋眰URL';
-comment on column sys_oper_log.oper_ip is '涓绘満鍦板潃';
-comment on column sys_oper_log.oper_location is '鎿嶄綔鍦扮偣';
-comment on column sys_oper_log.oper_param is '璇锋眰鍙傛暟';
-comment on column sys_oper_log.json_result is '杩斿洖鍙傛暟';
-comment on column sys_oper_log.status is '鎿嶄綔鐘舵�侊紙0姝e父 1寮傚父锛�';
-comment on column sys_oper_log.error_msg is '閿欒娑堟伅';
-comment on column sys_oper_log.oper_time is '鎿嶄綔鏃堕棿';
+comment on table sys_oper_log                   is '鎿嶄綔鏃ュ織璁板綍';
+comment on column sys_oper_log.oper_id          is '鏃ュ織涓婚敭';
+comment on column sys_oper_log.tenant_id        is '绉熸埛缂栧彿';
+comment on column sys_oper_log.title            is '妯″潡鏍囬';
+comment on column sys_oper_log.business_type    is '涓氬姟绫诲瀷锛�0鍏跺畠 1鏂板 2淇敼 3鍒犻櫎锛�';
+comment on column sys_oper_log.method           is '鏂规硶鍚嶇О';
+comment on column sys_oper_log.request_method   is '璇锋眰鏂瑰紡';
+comment on column sys_oper_log.operator_type    is '鎿嶄綔绫诲埆锛�0鍏跺畠 1鍚庡彴鐢ㄦ埛 2鎵嬫満绔敤鎴凤級';
+comment on column sys_oper_log.oper_name        is '鎿嶄綔浜哄憳';
+comment on column sys_oper_log.dept_name        is '閮ㄩ棬鍚嶇О';
+comment on column sys_oper_log.oper_url         is '璇锋眰URL';
+comment on column sys_oper_log.oper_ip          is '涓绘満鍦板潃';
+comment on column sys_oper_log.oper_location    is '鎿嶄綔鍦扮偣';
+comment on column sys_oper_log.oper_param       is '璇锋眰鍙傛暟';
+comment on column sys_oper_log.json_result      is '杩斿洖鍙傛暟';
+comment on column sys_oper_log.status           is '鎿嶄綔鐘舵�侊紙0姝e父 1寮傚父锛�';
+comment on column sys_oper_log.error_msg        is '閿欒娑堟伅';
+comment on column sys_oper_log.oper_time        is '鎿嶄綔鏃堕棿';
 
 -- ----------------------------
 -- 11銆佸瓧鍏哥被鍨嬭〃
@@ -576,6 +696,7 @@
 create table if not exists sys_dict_type
 (
     dict_id     int8,
+    tenant_id   varchar(20)  not null,
     dict_name   varchar(100) default ''::varchar,
     dict_type   varchar(100) default ''::varchar,
     status      char         default '0'::bpchar,
@@ -588,26 +709,29 @@
     constraint sys_dict_type_pk primary key (dict_id)
 );
 
-comment on table sys_dict_type is '瀛楀吀绫诲瀷琛�';
-comment on column sys_dict_type.dict_id is '瀛楀吀涓婚敭';
-comment on column sys_dict_type.dict_name is '瀛楀吀鍚嶇О';
-comment on column sys_dict_type.dict_type is '瀛楀吀绫诲瀷';
-comment on column sys_dict_type.status is '鐘舵�侊紙0姝e父 1鍋滅敤锛�';
-comment on column sys_dict_type.create_dept is '鍒涘缓閮ㄩ棬';
-comment on column sys_dict_type.create_by is '鍒涘缓鑰�';
-comment on column sys_dict_type.create_time is '鍒涘缓鏃堕棿';
-comment on column sys_dict_type.update_by is '鏇存柊鑰�';
-comment on column sys_dict_type.update_time is '鏇存柊鏃堕棿';
-comment on column sys_dict_type.remark is '澶囨敞';
+CREATE UNIQUE INDEX sys_dict_type_index1 ON sys_dict_type (tenant_id, dict_type);
 
-insert into sys_dict_type values(1,  '鐢ㄦ埛鎬у埆', 'sys_user_sex',        '0', 103, 1, now(), null, null, '鐢ㄦ埛鎬у埆鍒楄〃');
-insert into sys_dict_type values(2,  '鑿滃崟鐘舵��', 'sys_show_hide',       '0', 103, 1, now(), null, null, '鑿滃崟鐘舵�佸垪琛�');
-insert into sys_dict_type values(3,  '绯荤粺寮�鍏�', 'sys_normal_disable',  '0', 103, 1, now(), null, null, '绯荤粺寮�鍏冲垪琛�');
-insert into sys_dict_type values(6,  '绯荤粺鏄惁', 'sys_yes_no',          '0', 103, 1, now(), null, null, '绯荤粺鏄惁鍒楄〃');
-insert into sys_dict_type values(7,  '閫氱煡绫诲瀷', 'sys_notice_type',     '0', 103, 1, now(), null, null, '閫氱煡绫诲瀷鍒楄〃');
-insert into sys_dict_type values(8,  '閫氱煡鐘舵��', 'sys_notice_status',   '0', 103, 1, now(), null, null, '閫氱煡鐘舵�佸垪琛�');
-insert into sys_dict_type values(9,  '鎿嶄綔绫诲瀷', 'sys_oper_type',       '0', 103, 1, now(), null, null, '鎿嶄綔绫诲瀷鍒楄〃');
-insert into sys_dict_type values(10, '绯荤粺鐘舵��', 'sys_common_status',   '0', 103, 1, now(), null, null, '鐧诲綍鐘舵�佸垪琛�');
+comment on table sys_dict_type                  is '瀛楀吀绫诲瀷琛�';
+comment on column sys_dict_type.dict_id         is '瀛楀吀涓婚敭';
+comment on column sys_dict_type.tenant_id       is '绉熸埛缂栧彿';
+comment on column sys_dict_type.dict_name       is '瀛楀吀鍚嶇О';
+comment on column sys_dict_type.dict_type       is '瀛楀吀绫诲瀷';
+comment on column sys_dict_type.status          is '鐘舵�侊紙0姝e父 1鍋滅敤锛�';
+comment on column sys_dict_type.create_dept     is '鍒涘缓閮ㄩ棬';
+comment on column sys_dict_type.create_by       is '鍒涘缓鑰�';
+comment on column sys_dict_type.create_time     is '鍒涘缓鏃堕棿';
+comment on column sys_dict_type.update_by       is '鏇存柊鑰�';
+comment on column sys_dict_type.update_time     is '鏇存柊鏃堕棿';
+comment on column sys_dict_type.remark          is '澶囨敞';
+
+insert into sys_dict_type values(1, '000000', '鐢ㄦ埛鎬у埆', 'sys_user_sex',        '0', 103, 1, now(), null, null, '鐢ㄦ埛鎬у埆鍒楄〃');
+insert into sys_dict_type values(2, '000000', '鑿滃崟鐘舵��', 'sys_show_hide',       '0', 103, 1, now(), null, null, '鑿滃崟鐘舵�佸垪琛�');
+insert into sys_dict_type values(3, '000000', '绯荤粺寮�鍏�', 'sys_normal_disable',  '0', 103, 1, now(), null, null, '绯荤粺寮�鍏冲垪琛�');
+insert into sys_dict_type values(6, '000000', '绯荤粺鏄惁', 'sys_yes_no',          '0', 103, 1, now(), null, null, '绯荤粺鏄惁鍒楄〃');
+insert into sys_dict_type values(7, '000000', '閫氱煡绫诲瀷', 'sys_notice_type',     '0', 103, 1, now(), null, null, '閫氱煡绫诲瀷鍒楄〃');
+insert into sys_dict_type values(8, '000000', '閫氱煡鐘舵��', 'sys_notice_status',   '0', 103, 1, now(), null, null, '閫氱煡鐘舵�佸垪琛�');
+insert into sys_dict_type values(9, '000000', '鎿嶄綔绫诲瀷', 'sys_oper_type',       '0', 103, 1, now(), null, null, '鎿嶄綔绫诲瀷鍒楄〃');
+insert into sys_dict_type values(10, '000000', '绯荤粺鐘舵��', 'sys_common_status',   '0', 103, 1, now(), null, null, '鐧诲綍鐘舵�佸垪琛�');
 
 
 -- ----------------------------
@@ -617,6 +741,7 @@
 create table if not exists sys_dict_data
 (
     dict_code   int8,
+    tenant_id   varchar(20)  not null,
     dict_sort   int4         default 0,
     dict_label  varchar(100) default ''::varchar,
     dict_value  varchar(100) default ''::varchar,
@@ -634,48 +759,49 @@
     constraint sys_dict_data_pk primary key (dict_code)
 );
 
-comment on table sys_dict_data is '瀛楀吀鏁版嵁琛�';
-comment on column sys_dict_data.dict_code is '瀛楀吀缂栫爜';
-comment on column sys_dict_data.dict_sort is '瀛楀吀鎺掑簭';
-comment on column sys_dict_data.dict_label is '瀛楀吀鏍囩';
-comment on column sys_dict_data.dict_value is '瀛楀吀閿��';
-comment on column sys_dict_data.dict_type is '瀛楀吀绫诲瀷';
-comment on column sys_dict_data.css_class is '鏍峰紡灞炴�э紙鍏朵粬鏍峰紡鎵╁睍锛�';
-comment on column sys_dict_data.list_class is '琛ㄦ牸鍥炴樉鏍峰紡';
-comment on column sys_dict_data.is_default is '鏄惁榛樿锛圷鏄� N鍚︼級';
-comment on column sys_dict_data.status is '鐘舵�侊紙0姝e父 1鍋滅敤锛�';
-comment on column sys_dict_data.create_dept is '鍒涘缓閮ㄩ棬';
-comment on column sys_dict_data.create_by is '鍒涘缓鑰�';
-comment on column sys_dict_data.create_time is '鍒涘缓鏃堕棿';
-comment on column sys_dict_data.update_by is '鏇存柊鑰�';
-comment on column sys_dict_data.update_time is '鏇存柊鏃堕棿';
-comment on column sys_dict_data.remark is '澶囨敞';
+comment on table sys_dict_data                  is '瀛楀吀鏁版嵁琛�';
+comment on column sys_dict_data.dict_code       is '瀛楀吀缂栫爜';
+comment on column sys_dict_type.tenant_id       is '绉熸埛缂栧彿';
+comment on column sys_dict_data.dict_sort       is '瀛楀吀鎺掑簭';
+comment on column sys_dict_data.dict_label      is '瀛楀吀鏍囩';
+comment on column sys_dict_data.dict_value      is '瀛楀吀閿��';
+comment on column sys_dict_data.dict_type       is '瀛楀吀绫诲瀷';
+comment on column sys_dict_data.css_class       is '鏍峰紡灞炴�э紙鍏朵粬鏍峰紡鎵╁睍锛�';
+comment on column sys_dict_data.list_class      is '琛ㄦ牸鍥炴樉鏍峰紡';
+comment on column sys_dict_data.is_default      is '鏄惁榛樿锛圷鏄� N鍚︼級';
+comment on column sys_dict_data.status          is '鐘舵�侊紙0姝e父 1鍋滅敤锛�';
+comment on column sys_dict_data.create_dept     is '鍒涘缓閮ㄩ棬';
+comment on column sys_dict_data.create_by       is '鍒涘缓鑰�';
+comment on column sys_dict_data.create_time     is '鍒涘缓鏃堕棿';
+comment on column sys_dict_data.update_by       is '鏇存柊鑰�';
+comment on column sys_dict_data.update_time     is '鏇存柊鏃堕棿';
+comment on column sys_dict_data.remark          is '澶囨敞';
 
-insert into sys_dict_data values(1,  1,  '鐢�',       '0',       'sys_user_sex',        '',   '',        'Y', '0', 103, 1, now(), null, null, '鎬у埆鐢�');
-insert into sys_dict_data values(2,  2,  '濂�',       '1',       'sys_user_sex',        '',   '',        'N', '0', 103, 1, now(), null, null, '鎬у埆濂�');
-insert into sys_dict_data values(3,  3,  '鏈煡',     '2',       'sys_user_sex',        '',   '',        'N', '0', 103, 1, now(), null, null, '鎬у埆鏈煡');
-insert into sys_dict_data values(4,  1,  '鏄剧ず',     '0',       'sys_show_hide',       '',   'primary', 'Y', '0', 103, 1, now(), null, null, '鏄剧ず鑿滃崟');
-insert into sys_dict_data values(5,  2,  '闅愯棌',     '1',       'sys_show_hide',       '',   'danger',  'N', '0', 103, 1, now(), null, null, '闅愯棌鑿滃崟');
-insert into sys_dict_data values(6,  1,  '姝e父',     '0',       'sys_normal_disable',  '',   'primary', 'Y', '0', 103, 1, now(), null, null, '姝e父鐘舵��');
-insert into sys_dict_data values(7,  2,  '鍋滅敤',     '1',       'sys_normal_disable',  '',   'danger',  'N', '0', 103, 1, now(), null, null, '鍋滅敤鐘舵��');
-insert into sys_dict_data values(12, 1,  '鏄�',       'Y',       'sys_yes_no',          '',   'primary', 'Y', '0', 103, 1, now(), null, null, '绯荤粺榛樿鏄�');
-insert into sys_dict_data values(13, 2,  '鍚�',       'N',       'sys_yes_no',          '',   'danger',  'N', '0', 103, 1, now(), null, null, '绯荤粺榛樿鍚�');
-insert into sys_dict_data values(14, 1,  '閫氱煡',     '1',       'sys_notice_type',     '',   'warning', 'Y', '0', 103, 1, now(), null, null, '閫氱煡');
-insert into sys_dict_data values(15, 2,  '鍏憡',     '2',       'sys_notice_type',     '',   'success', 'N', '0', 103, 1, now(), null, null, '鍏憡');
-insert into sys_dict_data values(16, 1,  '姝e父',     '0',       'sys_notice_status',   '',   'primary', 'Y', '0', 103, 1, now(), null, null, '姝e父鐘舵��');
-insert into sys_dict_data values(17, 2,  '鍏抽棴',     '1',       'sys_notice_status',   '',   'danger',  'N', '0', 103, 1, now(), null, null, '鍏抽棴鐘舵��');
-insert into sys_dict_data values(29, 99, '鍏朵粬',     '0',       'sys_oper_type',       '',   'info',    'N', '0', 103, 1, now(), null, null, '鍏朵粬鎿嶄綔');
-insert into sys_dict_data values(18, 1,  '鏂板',     '1',       'sys_oper_type',       '',   'info',    'N', '0', 103, 1, now(), null, null, '鏂板鎿嶄綔');
-insert into sys_dict_data values(19, 2,  '淇敼',     '2',       'sys_oper_type',       '',   'info',    'N', '0', 103, 1, now(), null, null, '淇敼鎿嶄綔');
-insert into sys_dict_data values(20, 3,  '鍒犻櫎',     '3',       'sys_oper_type',       '',   'danger',  'N', '0', 103, 1, now(), null, null, '鍒犻櫎鎿嶄綔');
-insert into sys_dict_data values(21, 4,  '鎺堟潈',     '4',       'sys_oper_type',       '',   'primary', 'N', '0', 103, 1, now(), null, null, '鎺堟潈鎿嶄綔');
-insert into sys_dict_data values(22, 5,  '瀵煎嚭',     '5',       'sys_oper_type',       '',   'warning', 'N', '0', 103, 1, now(), null, null, '瀵煎嚭鎿嶄綔');
-insert into sys_dict_data values(23, 6,  '瀵煎叆',     '6',       'sys_oper_type',       '',   'warning', 'N', '0', 103, 1, now(), null, null, '瀵煎叆鎿嶄綔');
-insert into sys_dict_data values(24, 7,  '寮洪��',     '7',       'sys_oper_type',       '',   'danger',  'N', '0', 103, 1, now(), null, null, '寮洪��鎿嶄綔');
-insert into sys_dict_data values(25, 8,  '鐢熸垚浠g爜', '8',       'sys_oper_type',       '',   'warning', 'N', '0', 103, 1, now(), null, null, '鐢熸垚鎿嶄綔');
-insert into sys_dict_data values(26, 9,  '娓呯┖鏁版嵁', '9',       'sys_oper_type',       '',   'danger',  'N', '0', 103, 1, now(), null, null, '娓呯┖鎿嶄綔');
-insert into sys_dict_data values(27, 1,  '鎴愬姛',     '0',       'sys_common_status',   '',   'primary', 'N', '0', 103, 1, now(), null, null, '姝e父鐘舵��');
-insert into sys_dict_data values(28, 2,  '澶辫触',     '1',       'sys_common_status',   '',   'danger',  'N', '0', 103, 1, now(), null, null, '鍋滅敤鐘舵��');
+insert into sys_dict_data values(1, '000000', 1,  '鐢�',       '0',       'sys_user_sex',        '',   '',        'Y', '0', 103, 1, now(), null, null, '鎬у埆鐢�');
+insert into sys_dict_data values(2, '000000', 2,  '濂�',       '1',       'sys_user_sex',        '',   '',        'N', '0', 103, 1, now(), null, null, '鎬у埆濂�');
+insert into sys_dict_data values(3, '000000', 3,  '鏈煡',     '2',       'sys_user_sex',        '',   '',        'N', '0', 103, 1, now(), null, null, '鎬у埆鏈煡');
+insert into sys_dict_data values(4, '000000', 1,  '鏄剧ず',     '0',       'sys_show_hide',       '',   'primary', 'Y', '0', 103, 1, now(), null, null, '鏄剧ず鑿滃崟');
+insert into sys_dict_data values(5, '000000', 2,  '闅愯棌',     '1',       'sys_show_hide',       '',   'danger',  'N', '0', 103, 1, now(), null, null, '闅愯棌鑿滃崟');
+insert into sys_dict_data values(6, '000000', 1,  '姝e父',     '0',       'sys_normal_disable',  '',   'primary', 'Y', '0', 103, 1, now(), null, null, '姝e父鐘舵��');
+insert into sys_dict_data values(7, '000000', 2,  '鍋滅敤',     '1',       'sys_normal_disable',  '',   'danger',  'N', '0', 103, 1, now(), null, null, '鍋滅敤鐘舵��');
+insert into sys_dict_data values(12, '000000', 1,  '鏄�',       'Y',       'sys_yes_no',          '',   'primary', 'Y', '0', 103, 1, now(), null, null, '绯荤粺榛樿鏄�');
+insert into sys_dict_data values(13, '000000', 2,  '鍚�',       'N',       'sys_yes_no',          '',   'danger',  'N', '0', 103, 1, now(), null, null, '绯荤粺榛樿鍚�');
+insert into sys_dict_data values(14, '000000', 1,  '閫氱煡',     '1',       'sys_notice_type',     '',   'warning', 'Y', '0', 103, 1, now(), null, null, '閫氱煡');
+insert into sys_dict_data values(15, '000000', 2,  '鍏憡',     '2',       'sys_notice_type',     '',   'success', 'N', '0', 103, 1, now(), null, null, '鍏憡');
+insert into sys_dict_data values(16, '000000', 1,  '姝e父',     '0',       'sys_notice_status',   '',   'primary', 'Y', '0', 103, 1, now(), null, null, '姝e父鐘舵��');
+insert into sys_dict_data values(17, '000000', 2,  '鍏抽棴',     '1',       'sys_notice_status',   '',   'danger',  'N', '0', 103, 1, now(), null, null, '鍏抽棴鐘舵��');
+insert into sys_dict_data values(29, '000000', 99, '鍏朵粬',     '0',       'sys_oper_type',       '',   'info',    'N', '0', 103, 1, now(), null, null, '鍏朵粬鎿嶄綔');
+insert into sys_dict_data values(18, '000000', 1,  '鏂板',     '1',       'sys_oper_type',       '',   'info',    'N', '0', 103, 1, now(), null, null, '鏂板鎿嶄綔');
+insert into sys_dict_data values(19, '000000', 2,  '淇敼',     '2',       'sys_oper_type',       '',   'info',    'N', '0', 103, 1, now(), null, null, '淇敼鎿嶄綔');
+insert into sys_dict_data values(20, '000000', 3,  '鍒犻櫎',     '3',       'sys_oper_type',       '',   'danger',  'N', '0', 103, 1, now(), null, null, '鍒犻櫎鎿嶄綔');
+insert into sys_dict_data values(21, '000000', 4,  '鎺堟潈',     '4',       'sys_oper_type',       '',   'primary', 'N', '0', 103, 1, now(), null, null, '鎺堟潈鎿嶄綔');
+insert into sys_dict_data values(22, '000000', 5,  '瀵煎嚭',     '5',       'sys_oper_type',       '',   'warning', 'N', '0', 103, 1, now(), null, null, '瀵煎嚭鎿嶄綔');
+insert into sys_dict_data values(23, '000000', 6,  '瀵煎叆',     '6',       'sys_oper_type',       '',   'warning', 'N', '0', 103, 1, now(), null, null, '瀵煎叆鎿嶄綔');
+insert into sys_dict_data values(24, '000000', 7,  '寮洪��',     '7',       'sys_oper_type',       '',   'danger',  'N', '0', 103, 1, now(), null, null, '寮洪��鎿嶄綔');
+insert into sys_dict_data values(25, '000000', 8,  '鐢熸垚浠g爜', '8',       'sys_oper_type',       '',   'warning', 'N', '0', 103, 1, now(), null, null, '鐢熸垚鎿嶄綔');
+insert into sys_dict_data values(26, '000000', 9,  '娓呯┖鏁版嵁', '9',       'sys_oper_type',       '',   'danger',  'N', '0', 103, 1, now(), null, null, '娓呯┖鎿嶄綔');
+insert into sys_dict_data values(27, '000000', 1,  '鎴愬姛',     '0',       'sys_common_status',   '',   'primary', 'N', '0', 103, 1, now(), null, null, '姝e父鐘舵��');
+insert into sys_dict_data values(28, '000000', 2,  '澶辫触',     '1',       'sys_common_status',   '',   'danger',  'N', '0', 103, 1, now(), null, null, '鍋滅敤鐘舵��');
 
 
 -- ----------------------------
@@ -685,6 +811,7 @@
 create table if not exists sys_config
 (
     config_id    int8,
+    tenant_id    varchar(20)  not null,
     config_name  varchar(100) default ''::varchar,
     config_key   varchar(100) default ''::varchar,
     config_value varchar(500) default ''::varchar,
@@ -698,25 +825,25 @@
     constraint sys_config_pk primary key (config_id)
 );
 
-comment on table sys_config is '鍙傛暟閰嶇疆琛�';
-comment on column sys_config.config_id is '鍙傛暟涓婚敭';
-comment on column sys_config.config_name is '鍙傛暟鍚嶇О';
-comment on column sys_config.config_key is '鍙傛暟閿悕';
-comment on column sys_config.config_value is '鍙傛暟閿��';
-comment on column sys_config.config_type is '绯荤粺鍐呯疆锛圷鏄� N鍚︼級';
-comment on column sys_config.create_dept   is '鍒涘缓閮ㄩ棬';
-comment on column sys_config.create_by is '鍒涘缓鑰�';
-comment on column sys_config.create_time is '鍒涘缓鏃堕棿';
-comment on column sys_config.update_by is '鏇存柊鑰�';
-comment on column sys_config.update_time is '鏇存柊鏃堕棿';
-comment on column sys_config.remark is '澶囨敞';
+comment on table sys_config                 is '鍙傛暟閰嶇疆琛�';
+comment on column sys_config.config_id      is '鍙傛暟涓婚敭';
+comment on column sys_config.tenant_id      is '绉熸埛缂栧彿';
+comment on column sys_config.config_name    is '鍙傛暟鍚嶇О';
+comment on column sys_config.config_key     is '鍙傛暟閿悕';
+comment on column sys_config.config_value   is '鍙傛暟閿��';
+comment on column sys_config.config_type    is '绯荤粺鍐呯疆锛圷鏄� N鍚︼級';
+comment on column sys_config.create_dept    is '鍒涘缓閮ㄩ棬';
+comment on column sys_config.create_by      is '鍒涘缓鑰�';
+comment on column sys_config.create_time    is '鍒涘缓鏃堕棿';
+comment on column sys_config.update_by      is '鏇存柊鑰�';
+comment on column sys_config.update_time    is '鏇存柊鏃堕棿';
+comment on column sys_config.remark         is '澶囨敞';
 
-insert into sys_config values(1, '涓绘鏋堕〉-榛樿鐨偆鏍峰紡鍚嶇О',     'sys.index.skinName',            'skin-blue',     'Y', 103, 1, now(), null, null, '钃濊壊 skin-blue銆佺豢鑹� skin-green銆佺传鑹� skin-purple銆佺孩鑹� skin-red銆侀粍鑹� skin-yellow' );
-insert into sys_config values(2, '鐢ㄦ埛绠$悊-璐﹀彿鍒濆瀵嗙爜',         'sys.user.initPassword',         '123456',        'Y', 103, 1, now(), null, null, '鍒濆鍖栧瘑鐮� 123456' );
-insert into sys_config values(3, '涓绘鏋堕〉-渚ц竟鏍忎富棰�',           'sys.index.sideTheme',           'theme-dark',    'Y', 103, 1, now(), null, null, '娣辫壊涓婚theme-dark锛屾祬鑹蹭富棰榯heme-light' );
-insert into sys_config values(4, '璐﹀彿鑷姪-楠岃瘉鐮佸紑鍏�',           'sys.account.captchaEnabled',    'true',          'Y', 103, 1, now(), null, null, '鏄惁寮�鍚獙璇佺爜鍔熻兘锛坱rue寮�鍚紝false鍏抽棴锛�');
-insert into sys_config values(5, '璐﹀彿鑷姪-鏄惁寮�鍚敤鎴锋敞鍐屽姛鑳�',   'sys.account.registerUser',      'false',         'Y', 103, 1, now(), null, null, '鏄惁寮�鍚敞鍐岀敤鎴峰姛鑳斤紙true寮�鍚紝false鍏抽棴锛�');
-insert into sys_config values(11, 'OSS棰勮鍒楄〃璧勬簮寮�鍏�',          'sys.oss.previewListResource',   'true',          'Y', 103, 1, now(), null, null, 'true:寮�鍚�, false:鍏抽棴');
+insert into sys_config values(1, '000000', '涓绘鏋堕〉-榛樿鐨偆鏍峰紡鍚嶇О',     'sys.index.skinName',            'skin-blue',     'Y', 103, 1, now(), null, null, '钃濊壊 skin-blue銆佺豢鑹� skin-green銆佺传鑹� skin-purple銆佺孩鑹� skin-red銆侀粍鑹� skin-yellow' );
+insert into sys_config values(2, '000000', '鐢ㄦ埛绠$悊-璐﹀彿鍒濆瀵嗙爜',         'sys.user.initPassword',         '123456',        'Y', 103, 1, now(), null, null, '鍒濆鍖栧瘑鐮� 123456' );
+insert into sys_config values(3, '000000', '涓绘鏋堕〉-渚ц竟鏍忎富棰�',           'sys.index.sideTheme',           'theme-dark',    'Y', 103, 1, now(), null, null, '娣辫壊涓婚theme-dark锛屾祬鑹蹭富棰榯heme-light' );
+insert into sys_config values(5, '000000', '璐﹀彿鑷姪-鏄惁寮�鍚敤鎴锋敞鍐屽姛鑳�',   'sys.account.registerUser',      'false',         'Y', 103, 1, now(), null, null, '鏄惁寮�鍚敞鍐岀敤鎴峰姛鑳斤紙true寮�鍚紝false鍏抽棴锛�');
+insert into sys_config values(11, '000000', 'OSS棰勮鍒楄〃璧勬簮寮�鍏�',          'sys.oss.previewListResource',   'true',          'Y', 103, 1, now(), null, null, 'true:寮�鍚�, false:鍏抽棴');
 
 
 -- ----------------------------
@@ -726,6 +853,7 @@
 create table if not exists sys_logininfor
 (
     info_id        int8,
+    tenant_id      varchar(20)  not null,
     user_name      varchar(50)  default ''::varchar,
     ipaddr         varchar(128) default ''::varchar,
     login_location varchar(255) default ''::varchar,
@@ -737,16 +865,17 @@
     constraint sys_logininfor_pk primary key (info_id)
 );
 
-comment on table sys_logininfor is '绯荤粺璁块棶璁板綍';
-comment on column sys_logininfor.info_id is '璁块棶ID';
-comment on column sys_logininfor.user_name is '鐢ㄦ埛璐﹀彿';
-comment on column sys_logininfor.ipaddr is '鐧诲綍IP鍦板潃';
+comment on table sys_logininfor                 is '绯荤粺璁块棶璁板綍';
+comment on column sys_logininfor.info_id        is '璁块棶ID';
+comment on column sys_logininfor.tenant_id      is '绉熸埛缂栧彿';
+comment on column sys_logininfor.user_name      is '鐢ㄦ埛璐﹀彿';
+comment on column sys_logininfor.ipaddr         is '鐧诲綍IP鍦板潃';
 comment on column sys_logininfor.login_location is '鐧诲綍鍦扮偣';
-comment on column sys_logininfor.browser is '娴忚鍣ㄧ被鍨�';
-comment on column sys_logininfor.os is '鎿嶄綔绯荤粺';
-comment on column sys_logininfor.status is '鐧诲綍鐘舵�侊紙0鎴愬姛 1澶辫触锛�';
-comment on column sys_logininfor.msg is '鎻愮ず娑堟伅';
-comment on column sys_logininfor.login_time is '璁块棶鏃堕棿';
+comment on column sys_logininfor.browser        is '娴忚鍣ㄧ被鍨�';
+comment on column sys_logininfor.os             is '鎿嶄綔绯荤粺';
+comment on column sys_logininfor.status         is '鐧诲綍鐘舵�侊紙0鎴愬姛 1澶辫触锛�';
+comment on column sys_logininfor.msg            is '鎻愮ず娑堟伅';
+comment on column sys_logininfor.login_time     is '璁块棶鏃堕棿';
 
 -- ----------------------------
 -- 17銆侀�氱煡鍏憡琛�
@@ -755,8 +884,9 @@
 create table if not exists sys_notice
 (
     notice_id      int8,
-    notice_title   varchar(50) not null,
-    notice_type    char        not null,
+    tenant_id      varchar(20)  not null,
+    notice_title   varchar(50)  not null,
+    notice_type    char         not null,
     notice_content text,
     status         char         default '0'::bpchar,
     create_dept    int8,
@@ -768,24 +898,25 @@
     constraint sys_notice_pk primary key (notice_id)
 );
 
-comment on table sys_notice is '閫氱煡鍏憡琛�';
-comment on column sys_notice.notice_id is '鍏憡ID';
-comment on column sys_notice.notice_title is '鍏憡鏍囬';
-comment on column sys_notice.notice_type is '鍏憡绫诲瀷锛�1閫氱煡 2鍏憡锛�';
+comment on table sys_notice                 is '閫氱煡鍏憡琛�';
+comment on column sys_notice.notice_id      is '鍏憡ID';
+comment on column sys_notice.tenant_id      is '绉熸埛缂栧彿';
+comment on column sys_notice.notice_title   is '鍏憡鏍囬';
+comment on column sys_notice.notice_type    is '鍏憡绫诲瀷锛�1閫氱煡 2鍏憡锛�';
 comment on column sys_notice.notice_content is '鍏憡鍐呭';
-comment on column sys_notice.status is '鍏憡鐘舵�侊紙0姝e父 1鍏抽棴锛�';
-comment on column sys_notice.create_dept is '鍒涘缓閮ㄩ棬';
-comment on column sys_notice.create_by is '鍒涘缓鑰�';
-comment on column sys_notice.create_time is '鍒涘缓鏃堕棿';
-comment on column sys_notice.update_by is '鏇存柊鑰�';
-comment on column sys_notice.update_time is '鏇存柊鏃堕棿';
-comment on column sys_notice.remark is '澶囨敞';
+comment on column sys_notice.status         is '鍏憡鐘舵�侊紙0姝e父 1鍏抽棴锛�';
+comment on column sys_notice.create_dept    is '鍒涘缓閮ㄩ棬';
+comment on column sys_notice.create_by      is '鍒涘缓鑰�';
+comment on column sys_notice.create_time    is '鍒涘缓鏃堕棿';
+comment on column sys_notice.update_by      is '鏇存柊鑰�';
+comment on column sys_notice.update_time    is '鏇存柊鏃堕棿';
+comment on column sys_notice.remark         is '澶囨敞';
 
 -- ----------------------------
 -- 鍒濆鍖�-鍏憡淇℃伅琛ㄦ暟鎹�
 -- ----------------------------
-insert into sys_notice values('1', '娓╅Θ鎻愰啋锛�2018-07-01 鏂扮増鏈彂甯冨暒', '2', '鏂扮増鏈唴瀹�', '0', 103, 1, now(), null, null, '绠$悊鍛�');
-insert into sys_notice values('2', '缁存姢閫氱煡锛�2018-07-01 绯荤粺鍑屾櫒缁存姢', '1', '缁存姢鍐呭',   '0', 103, 1, now(), null, null, '绠$悊鍛�');
+insert into sys_notice values('1', '000000', '娓╅Θ鎻愰啋锛�2018-07-01 鏂扮増鏈彂甯冨暒', '2', '鏂扮増鏈唴瀹�', '0', 103, 1, now(), null, null, '绠$悊鍛�');
+insert into sys_notice values('2', '000000', '缁存姢閫氱煡锛�2018-07-01 绯荤粺鍑屾櫒缁存姢', '1', '缁存姢鍐呭',   '0', 103, 1, now(), null, null, '绠$悊鍛�');
 
 
 -- ----------------------------
@@ -904,6 +1035,7 @@
 create table if not exists sys_oss
 (
     oss_id        int8,
+    tenant_id     varchar(20)  not null,
     file_name     varchar(255) default ''::varchar not null,
     original_name varchar(255) default ''::varchar not null,
     file_suffix   varchar(10)  default ''::varchar not null,
@@ -917,18 +1049,19 @@
     constraint sys_oss_pk primary key (oss_id)
 );
 
-comment on table sys_oss is 'OSS瀵硅薄瀛樺偍琛�';
-comment on column sys_oss.oss_id is '瀵硅薄瀛樺偍涓婚敭';
-comment on column sys_oss.file_name is '鏂囦欢鍚�';
-comment on column sys_oss.original_name is '鍘熷悕';
-comment on column sys_oss.file_suffix is '鏂囦欢鍚庣紑鍚�';
-comment on column sys_oss.url is 'URL鍦板潃';
-comment on column sys_oss.create_by is '涓婁紶浜�';
-comment on column sys_oss.create_dept  is '鍒涘缓閮ㄩ棬';
-comment on column sys_oss.create_time is '鍒涘缓鏃堕棿';
-comment on column sys_oss.update_by is '鏇存柊鑰�';
-comment on column sys_oss.update_time is '鏇存柊鏃堕棿';
-comment on column sys_oss.service is '鏈嶅姟鍟�';
+comment on table sys_oss                    is 'OSS瀵硅薄瀛樺偍琛�';
+comment on column sys_oss.oss_id            is '瀵硅薄瀛樺偍涓婚敭';
+comment on column sys_oss.tenant_id         is '绉熸埛缂栫爜';
+comment on column sys_oss.file_name         is '鏂囦欢鍚�';
+comment on column sys_oss.original_name     is '鍘熷悕';
+comment on column sys_oss.file_suffix       is '鏂囦欢鍚庣紑鍚�';
+comment on column sys_oss.url               is 'URL鍦板潃';
+comment on column sys_oss.create_by         is '涓婁紶浜�';
+comment on column sys_oss.create_dept       is '鍒涘缓閮ㄩ棬';
+comment on column sys_oss.create_time       is '鍒涘缓鏃堕棿';
+comment on column sys_oss.update_by         is '鏇存柊鑰�';
+comment on column sys_oss.update_time       is '鏇存柊鏃堕棿';
+comment on column sys_oss.service           is '鏈嶅姟鍟�';
 
 -- ----------------------------
 -- OSS瀵硅薄瀛樺偍鍔ㄦ�侀厤缃〃
@@ -937,6 +1070,7 @@
 create table if not exists sys_oss_config
 (
     oss_config_id int8,
+    tenant_id     varchar(20)  not null,
     config_key    varchar(20)  default ''::varchar not null,
     access_key    varchar(255) default ''::varchar,
     secret_key    varchar(255) default ''::varchar,
@@ -958,32 +1092,33 @@
     constraint sys_oss_config_pk primary key (oss_config_id)
 );
 
-comment on table sys_oss_config is '瀵硅薄瀛樺偍閰嶇疆琛�';
-comment on column sys_oss_config.oss_config_id is '涓诲缓';
-comment on column sys_oss_config.config_key is '閰嶇疆key';
-comment on column sys_oss_config.access_key is 'accessKey';
-comment on column sys_oss_config.secret_key is '绉橀挜';
-comment on column sys_oss_config.bucket_name is '妗跺悕绉�';
-comment on column sys_oss_config.prefix is '鍓嶇紑';
-comment on column sys_oss_config.endpoint is '璁块棶绔欑偣';
-comment on column sys_oss_config.domain is '鑷畾涔夊煙鍚�';
-comment on column sys_oss_config.is_https is '鏄惁https锛圷=鏄�,N=鍚︼級';
-comment on column sys_oss_config.region is '鍩�';
-comment on column sys_oss_config.access_policy is '妗舵潈闄愮被鍨�(0=private 1=public 2=custom)';
-comment on column sys_oss_config.status is '鐘舵�侊紙0=姝e父,1=鍋滅敤锛�';
-comment on column sys_oss_config.ext1 is '鎵╁睍瀛楁';
-comment on column sys_oss_config.create_dept is '鍒涘缓閮ㄩ棬';
-comment on column sys_oss_config.create_by is '鍒涘缓鑰�';
-comment on column sys_oss_config.create_time is '鍒涘缓鏃堕棿';
-comment on column sys_oss_config.update_by is '鏇存柊鑰�';
-comment on column sys_oss_config.update_time is '鏇存柊鏃堕棿';
-comment on column sys_oss_config.remark is '澶囨敞';
+comment on table sys_oss_config                 is '瀵硅薄瀛樺偍閰嶇疆琛�';
+comment on column sys_oss_config.oss_config_id  is '涓诲缓';
+comment on column sys_oss_config.tenant_id      is '绉熸埛缂栫爜';
+comment on column sys_oss_config.config_key     is '閰嶇疆key';
+comment on column sys_oss_config.access_key     is 'accessKey';
+comment on column sys_oss_config.secret_key     is '绉橀挜';
+comment on column sys_oss_config.bucket_name    is '妗跺悕绉�';
+comment on column sys_oss_config.prefix         is '鍓嶇紑';
+comment on column sys_oss_config.endpoint       is '璁块棶绔欑偣';
+comment on column sys_oss_config.domain         is '鑷畾涔夊煙鍚�';
+comment on column sys_oss_config.is_https       is '鏄惁https锛圷=鏄�,N=鍚︼級';
+comment on column sys_oss_config.region         is '鍩�';
+comment on column sys_oss_config.access_policy  is '妗舵潈闄愮被鍨�(0=private 1=public 2=custom)';
+comment on column sys_oss_config.status         is '鐘舵�侊紙0=姝e父,1=鍋滅敤锛�';
+comment on column sys_oss_config.ext1           is '鎵╁睍瀛楁';
+comment on column sys_oss_config.create_dept    is '鍒涘缓閮ㄩ棬';
+comment on column sys_oss_config.create_by      is '鍒涘缓鑰�';
+comment on column sys_oss_config.create_time    is '鍒涘缓鏃堕棿';
+comment on column sys_oss_config.update_by      is '鏇存柊鑰�';
+comment on column sys_oss_config.update_time    is '鏇存柊鏃堕棿';
+comment on column sys_oss_config.remark         is '澶囨敞';
 
-insert into sys_oss_config values (1, 'minio',  'ruoyi',            'ruoyi123',        'ruoyi',             '', '127.0.0.1:9000',                      '','N', '',            '1', '0', '', 103, 1, now(), 1, now(), null);
-insert into sys_oss_config values (2, 'qiniu',  'XXXXXXXXXXXXXXX',  'XXXXXXXXXXXXXXX', 'ruoyi',             '', 's3-cn-north-1.qiniucs.com',           '','N', '',            '1', '1', '', 103, 1, now(), 1, now(), null);
-insert into sys_oss_config values (3, 'aliyun', 'XXXXXXXXXXXXXXX',  'XXXXXXXXXXXXXXX', 'ruoyi',             '', 'oss-cn-beijing.aliyuncs.com',         '','N', '',            '1', '1', '', 103, 1, now(), 1, now(), null);
-insert into sys_oss_config values (4, 'qcloud', 'XXXXXXXXXXXXXXX',  'XXXXXXXXXXXXXXX', 'ruoyi-1250000000',  '', 'cos.ap-beijing.myqcloud.com',         '','N', 'ap-beijing',  '1', '1', '', 103, 1, now(), 1, now(), null);
-insert into sys_oss_config values (5, 'image',  'ruoyi',            'ruoyi123',        'ruoyi',             'image', '127.0.0.1:9000',                 '','N', '',            '1', '1', '', 103, 1, now(), 1, now(), NULL);
+insert into sys_oss_config values (1, '000000', 'minio',  'ruoyi',            'ruoyi123',        'ruoyi',             '', '127.0.0.1:9000',                      '','N', '',            '1', '0', '', 103, 1, now(), 1, now(), null);
+insert into sys_oss_config values (2, '000000', 'qiniu',  'XXXXXXXXXXXXXXX',  'XXXXXXXXXXXXXXX', 'ruoyi',             '', 's3-cn-north-1.qiniucs.com',           '','N', '',            '1', '1', '', 103, 1, now(), 1, now(), null);
+insert into sys_oss_config values (3, '000000', 'aliyun', 'XXXXXXXXXXXXXXX',  'XXXXXXXXXXXXXXX', 'ruoyi',             '', 'oss-cn-beijing.aliyuncs.com',         '','N', '',            '1', '1', '', 103, 1, now(), 1, now(), null);
+insert into sys_oss_config values (4, '000000', 'qcloud', 'XXXXXXXXXXXXXXX',  'XXXXXXXXXXXXXXX', 'ruoyi-1250000000',  '', 'cos.ap-beijing.myqcloud.com',         '','N', 'ap-beijing',  '1', '1', '', 103, 1, now(), 1, now(), null);
+insert into sys_oss_config values (5, '000000', 'image',  'ruoyi',            'ruoyi123',        'ruoyi',             'image', '127.0.0.1:9000',                 '','N', '',            '1', '1', '', 103, 1, now(), 1, now(), NULL);
 
 -- 瀛楃涓茶嚜鍔ㄨ浆鏃堕棿 閬垮厤妗嗘灦鏃堕棿鏌ヨ鎶ラ敊闂
 create or replace function cast_varchar_to_timestamp(varchar) returns timestamptz as $$

--
Gitblit v1.9.3