Procházet zdrojové kódy

fix 修复 关闭租户后 插入数据报无租户ID问题 使用默认值兼容

疯狂的狮子Li před 2 roky
rodič
revize
c82bde9792

+ 12 - 12
script/sql/oracle/oracle_ry_vue_5.X.sql

@@ -92,7 +92,7 @@ comment on column  sys_tenant_package.update_time        is '更新时间';
 -- ----------------------------
 create table sys_dept (
   dept_id           number(20)      not null,
-  tenant_id         varchar2(20)    not null,
+  tenant_id         varchar2(20)    default '000000',
   parent_id         number(20)      default 0,
   ancestors         varchar2(500)   default '',
   dept_name         varchar2(30)    default '',
@@ -149,7 +149,7 @@ insert into sys_dept values(109, '000000', 102, '0,100,102',  '财务部门',
 -- ----------------------------
 create table sys_user (
   user_id           number(20)      not null,
-  tenant_id         varchar2(20)    not null,
+  tenant_id         varchar2(20)    default '000000',
   dept_id           number(20)      default null,
   user_name         varchar2(40)    not null,
   nick_name         varchar2(40)    not null,
@@ -208,7 +208,7 @@ insert into sys_user values(2, '000000', 105, 'lionli', '疯狂的狮子Li', 'sy
 -- ----------------------------
 create table sys_post (
   post_id           number(20)      not null,
-  tenant_id         varchar2(20)    not null,
+  tenant_id         varchar2(20)    default '000000',
   post_code         varchar2(64)    not null,
   post_name         varchar2(50)    not null,
   post_sort         number(4)       not null,
@@ -251,7 +251,7 @@ insert into sys_post values(4, '000000', 'user', '普通员工',  4, '0', 103, 1
 -- ----------------------------
 create table sys_role (
   role_id              number(20)      not null,
-  tenant_id            varchar2(20)    not null,
+  tenant_id            varchar2(20)    default '000000',
   role_name            varchar2(30)    not null,
   role_key             varchar2(100)   not null,
   role_sort            number(4)       not null,
@@ -634,7 +634,7 @@ insert into sys_user_post values ('2', '2');
 -- ----------------------------
 create table sys_oper_log (
   oper_id           number(20)      not null,
-  tenant_id         varchar2(20)    not null,
+  tenant_id         varchar2(20)    default '000000',
   title             varchar2(50)    default '',
   business_type     number(2)       default 0,
   method            varchar2(100)   default '',
@@ -684,7 +684,7 @@ comment on column sys_oper_log.cost_time      is '消耗时间';
 -- ----------------------------
 create table sys_dict_type (
   dict_id           number(20)      not null,
-  tenant_id         varchar2(20)    not null,
+  tenant_id         varchar2(20)    default '000000',
   dict_name         varchar2(100)   default '',
   dict_type         varchar2(100)   default '',
   status            char(1)         default '0',
@@ -727,7 +727,7 @@ insert into sys_dict_type values(10, '000000', '系统状态', 'sys_common_statu
 -- ----------------------------
 create table sys_dict_data (
   dict_code        number(20)      not null,
-  tenant_id        varchar2(20)    not null,
+  tenant_id        varchar2(20)    default '000000',
   dict_sort        number(4)       default 0,
   dict_label       varchar2(100)   default '',
   dict_value       varchar2(100)   default '',
@@ -796,7 +796,7 @@ insert into sys_dict_data values(28, '000000', 2,  '失败',     '1',       'sys
 -- ----------------------------
 create table sys_config (
   config_id         number(20)     not null,
-  tenant_id         varchar2(20)   not null,
+  tenant_id         varchar2(20)   default '000000',
   config_name       varchar2(100)  default '',
   config_key        varchar2(100)  default '',
   config_value      varchar2(100)  default '',
@@ -836,7 +836,7 @@ insert into sys_config values(11, '000000', 'OSS预览列表资源开关',
 -- ----------------------------
 create table sys_logininfor (
   info_id         number(20)     not null,
-  tenant_id       varchar2(20)   not null,
+  tenant_id       varchar2(20)   default '000000',
   user_name       varchar2(50)   default '',
   ipaddr          varchar2(128)  default '',
   login_location  varchar2(255)  default '',
@@ -869,7 +869,7 @@ comment on column sys_logininfor.login_time     is '访问时间';
 -- ----------------------------
 create table sys_notice (
   notice_id         number(20)      not null,
-  tenant_id         varchar2(20)    not null,
+  tenant_id         varchar2(20)    default '000000',
   notice_title      varchar2(50)    not null,
   notice_type       char(1)         not null,
   notice_content    clob            default null,
@@ -1020,7 +1020,7 @@ comment on column gen_table_column.update_time    is '更新时间';
 -- ----------------------------
 create table sys_oss (
   oss_id          number(20)    not null,
-  tenant_id       varchar2(20)  not null,
+  tenant_id       varchar2(20)  default '000000',
   file_name       varchar(255)  not null,
   original_name   varchar(255)  not null,
   file_suffix     varchar(10)   not null,
@@ -1055,7 +1055,7 @@ comment on column sys_oss.update_by         is '更新者';
 -- ----------------------------
 create table sys_oss_config (
   oss_config_id   number(20)    not null,
-  tenant_id       varchar2(20)  not null,
+  tenant_id       varchar2(20)  default '000000',
   config_key      varchar(20)   not null,
   access_key      varchar(255)  default '',
   secret_key      varchar(255)  default '',

+ 12 - 12
script/sql/postgres/postgres_ry_vue_5.X.sql

@@ -100,7 +100,7 @@ drop table if exists sys_dept;
 create table if not exists sys_dept
 (
     dept_id     int8,
-    tenant_id   varchar(20) not null,
+    tenant_id   varchar(20) default '000000'::varchar,
     parent_id   int8        default 0,
     ancestors   varchar(500)default ''::varchar,
     dept_name   varchar(30) default ''::varchar,
@@ -157,7 +157,7 @@ drop table if exists sys_user;
 create table if not exists sys_user
 (
     user_id     int8,
-    tenant_id   varchar(20)  not null,
+    tenant_id   varchar(20)  default '000000'::varchar,
     dept_id     int8,
     user_name   varchar(30)  not null,
     nick_name   varchar(30)  not null,
@@ -218,7 +218,7 @@ drop table if exists sys_post;
 create table if not exists sys_post
 (
     post_id     int8,
-    tenant_id   varchar(20) not null,
+    tenant_id   varchar(20) default '000000'::varchar,
     post_code   varchar(64) not null,
     post_name   varchar(50) not null,
     post_sort   int4        not null,
@@ -261,7 +261,7 @@ drop table if exists sys_role;
 create table if not exists sys_role
 (
     role_id             int8,
-    tenant_id           varchar(20)  not null,
+    tenant_id           varchar(20)  default '000000'::varchar,
     role_name           varchar(30)  not null,
     role_key            varchar(100) not null,
     role_sort           int4         not null,
@@ -651,7 +651,7 @@ drop table if exists sys_oper_log;
 create table if not exists sys_oper_log
 (
     oper_id        int8,
-    tenant_id      varchar(20)   not null,
+    tenant_id      varchar(20)   default '000000'::varchar,
     title          varchar(50)   default ''::varchar,
     business_type  int4          default 0,
     method         varchar(100)  default ''::varchar,
@@ -702,7 +702,7 @@ drop table if exists sys_dict_type;
 create table if not exists sys_dict_type
 (
     dict_id     int8,
-    tenant_id   varchar(20)  not null,
+    tenant_id   varchar(20)  default '000000'::varchar,
     dict_name   varchar(100) default ''::varchar,
     dict_type   varchar(100) default ''::varchar,
     status      char         default '0'::bpchar,
@@ -747,7 +747,7 @@ drop table if exists sys_dict_data;
 create table if not exists sys_dict_data
 (
     dict_code   int8,
-    tenant_id   varchar(20)  not null,
+    tenant_id   varchar(20)  default '000000'::varchar,
     dict_sort   int4         default 0,
     dict_label  varchar(100) default ''::varchar,
     dict_value  varchar(100) default ''::varchar,
@@ -817,7 +817,7 @@ drop table if exists sys_config;
 create table if not exists sys_config
 (
     config_id    int8,
-    tenant_id    varchar(20)  not null,
+    tenant_id    varchar(20)  default '000000'::varchar,
     config_name  varchar(100) default ''::varchar,
     config_key   varchar(100) default ''::varchar,
     config_value varchar(500) default ''::varchar,
@@ -859,7 +859,7 @@ drop table if exists sys_logininfor;
 create table if not exists sys_logininfor
 (
     info_id        int8,
-    tenant_id      varchar(20)  not null,
+    tenant_id      varchar(20)  default '000000'::varchar,
     user_name      varchar(50)  default ''::varchar,
     ipaddr         varchar(128) default ''::varchar,
     login_location varchar(255) default ''::varchar,
@@ -893,7 +893,7 @@ drop table if exists sys_notice;
 create table if not exists sys_notice
 (
     notice_id      int8,
-    tenant_id      varchar(20)  not null,
+    tenant_id      varchar(20)  default '000000'::varchar,
     notice_title   varchar(50)  not null,
     notice_type    char         not null,
     notice_content text,
@@ -1045,7 +1045,7 @@ drop table if exists sys_oss;
 create table if not exists sys_oss
 (
     oss_id        int8,
-    tenant_id     varchar(20)  not null,
+    tenant_id     varchar(20)  default '000000'::varchar,
     file_name     varchar(255) default ''::varchar not null,
     original_name varchar(255) default ''::varchar not null,
     file_suffix   varchar(10)  default ''::varchar not null,
@@ -1080,7 +1080,7 @@ drop table if exists sys_oss_config;
 create table if not exists sys_oss_config
 (
     oss_config_id int8,
-    tenant_id     varchar(20)  not null,
+    tenant_id     varchar(20)  default '000000'::varchar,
     config_key    varchar(20)  default ''::varchar not null,
     access_key    varchar(255) default ''::varchar,
     secret_key    varchar(255) default ''::varchar,

+ 12 - 12
script/sql/ry_vue_5.X.sql

@@ -62,7 +62,7 @@ create table sys_tenant_package (
 drop table if exists sys_dept;
 create table sys_dept (
   dept_id           bigint(20)      not null                   comment '部门id',
-  tenant_id         varchar(20)     not null                   comment '租户编号',
+  tenant_id         varchar(20)     default '000000'           comment '租户编号',
   parent_id         bigint(20)      default 0                  comment '父部门id',
   ancestors         varchar(500)    default ''                 comment '祖级列表',
   dept_name         varchar(30)     default ''                 comment '部门名称',
@@ -103,7 +103,7 @@ insert into sys_dept values(109, '000000', 102, '0,100,102',  '财务部门',
 drop table if exists sys_user;
 create table sys_user (
   user_id           bigint(20)      not null                   comment '用户ID',
-  tenant_id         varchar(20)     not null                   comment '租户编号',
+  tenant_id         varchar(20)     default '000000'           comment '租户编号',
   dept_id           bigint(20)      default null               comment '部门ID',
   user_name         varchar(30)     not null                   comment '用户账号',
   nick_name         varchar(30)     not null                   comment '用户昵称',
@@ -140,7 +140,7 @@ drop table if exists sys_post;
 create table sys_post
 (
   post_id       bigint(20)      not null                   comment '岗位ID',
-  tenant_id     varchar(20)     not null                   comment '租户编号',
+  tenant_id     varchar(20)     default '000000'           comment '租户编号',
   post_code     varchar(64)     not null                   comment '岗位编码',
   post_name     varchar(50)     not null                   comment '岗位名称',
   post_sort     int(4)          not null                   comment '显示顺序',
@@ -169,7 +169,7 @@ insert into sys_post values(4, '000000', 'user', '普通员工',  4, '0', 103, 1
 drop table if exists sys_role;
 create table sys_role (
   role_id              bigint(20)      not null                   comment '角色ID',
-  tenant_id            varchar(20)     not null                   comment '租户编号',
+  tenant_id            varchar(20)     default '000000'           comment '租户编号',
   role_name            varchar(30)     not null                   comment '角色名称',
   role_key             varchar(100)    not null                   comment '角色权限字符串',
   role_sort            int(4)          not null                   comment '显示顺序',
@@ -498,7 +498,7 @@ insert into sys_user_post values ('2', '2');
 drop table if exists sys_oper_log;
 create table sys_oper_log (
   oper_id           bigint(20)      not null                   comment '日志主键',
-  tenant_id         varchar(20)     not null                   comment '租户编号',
+  tenant_id         varchar(20)     default '000000'           comment '租户编号',
   title             varchar(50)     default ''                 comment '模块标题',
   business_type     int(2)          default 0                  comment '业务类型(0其它 1新增 2修改 3删除)',
   method            varchar(100)    default ''                 comment '方法名称',
@@ -529,7 +529,7 @@ drop table if exists sys_dict_type;
 create table sys_dict_type
 (
   dict_id          bigint(20)      not null                   comment '字典主键',
-  tenant_id        varchar(20)     not null                   comment '租户编号',
+  tenant_id        varchar(20)     default '000000'           comment '租户编号',
   dict_name        varchar(100)    default ''                 comment '字典名称',
   dict_type        varchar(100)    default ''                 comment '字典类型',
   status           char(1)         default '0'                comment '状态(0正常 1停用)',
@@ -560,7 +560,7 @@ drop table if exists sys_dict_data;
 create table sys_dict_data
 (
   dict_code        bigint(20)      not null                   comment '字典编码',
-  tenant_id        varchar(20)     not null                   comment '租户编号',
+  tenant_id        varchar(20)     default '000000'           comment '租户编号',
   dict_sort        int(4)          default 0                  comment '字典排序',
   dict_label       varchar(100)    default ''                 comment '字典标签',
   dict_value       varchar(100)    default ''                 comment '字典键值',
@@ -611,7 +611,7 @@ insert into sys_dict_data values(28, '000000', 2,  '失败',     '1',       'sys
 drop table if exists sys_config;
 create table sys_config (
   config_id         bigint(20)      not null                   comment '参数主键',
-  tenant_id         varchar(20)    not null                    comment '租户编号',
+  tenant_id         varchar(20)     default '000000'           comment '租户编号',
   config_name       varchar(100)    default ''                 comment '参数名称',
   config_key        varchar(100)    default ''                 comment '参数键名',
   config_value      varchar(500)    default ''                 comment '参数键值',
@@ -638,7 +638,7 @@ insert into sys_config values(11, '000000', 'OSS预览列表资源开关',
 drop table if exists sys_logininfor;
 create table sys_logininfor (
   info_id        bigint(20)     not null                  comment '访问ID',
-  tenant_id      varchar(20)    not null                  comment '租户编号',
+  tenant_id      varchar(20)    default '000000'          comment '租户编号',
   user_name      varchar(50)    default ''                comment '用户账号',
   ipaddr         varchar(128)   default ''                comment '登录IP地址',
   login_location varchar(255)   default ''                comment '登录地点',
@@ -659,7 +659,7 @@ create table sys_logininfor (
 drop table if exists sys_notice;
 create table sys_notice (
   notice_id         bigint(20)      not null                   comment '公告ID',
-  tenant_id         varchar(20)     not null                   comment '租户编号',
+  tenant_id         varchar(20)     default '000000'           comment '租户编号',
   notice_title      varchar(50)     not null                   comment '公告标题',
   notice_type       char(1)         not null                   comment '公告类型(1通知 2公告)',
   notice_content    longblob        default null               comment '公告内容',
@@ -747,7 +747,7 @@ create table gen_table_column (
 drop table if exists sys_oss;
 create table sys_oss (
   oss_id          bigint(20)   not null                   comment '对象存储主键',
-  tenant_id       varchar(20)  not null                   comment '租户编号',
+  tenant_id       varchar(20)           default '000000'  comment '租户编号',
   file_name       varchar(255) not null default ''        comment '文件名',
   original_name   varchar(255) not null default ''        comment '原名',
   file_suffix     varchar(10)  not null default ''        comment '文件后缀名',
@@ -767,7 +767,7 @@ create table sys_oss (
 drop table if exists sys_oss_config;
 create table sys_oss_config (
   oss_config_id   bigint(20)    not null                  comment '主建',
-  tenant_id       varchar(20)   not null                  comment '租户编号',
+  tenant_id       varchar(20)             default '000000'comment '租户编号',
   config_key      varchar(20)   not null  default ''      comment '配置key',
   access_key      varchar(255)            default ''      comment 'accessKey',
   secret_key      varchar(255)            default ''      comment '秘钥',

+ 23 - 23
script/sql/sqlserver/sqlserver_ry_vue_5.X.sql

@@ -592,7 +592,7 @@ GO
 CREATE TABLE sys_config
 (
     config_id    bigint                      NOT NULL,
-    tenant_id    nvarchar(20)                NOT NULL,
+    tenant_id    nvarchar(20)  DEFAULT '000000'  NULL,
     config_name  nvarchar(100) DEFAULT ''    NULL,
     config_key   nvarchar(100) DEFAULT ''    NULL,
     config_value nvarchar(500) DEFAULT ''    NULL,
@@ -702,7 +702,7 @@ GO
 CREATE TABLE sys_dept
 (
     dept_id     bigint                     NOT NULL,
-    tenant_id   nvarchar(20)               NOT NULL,
+    tenant_id   nvarchar(20) DEFAULT ('000000') NULL,
     parent_id   bigint       DEFAULT ((0)) NULL,
     ancestors   nvarchar(500)DEFAULT ''    NULL,
     dept_name   nvarchar(30) DEFAULT ''    NULL,
@@ -850,7 +850,7 @@ GO
 CREATE TABLE sys_dict_data
 (
     dict_code   bigint                      NOT NULL,
-    tenant_id   nvarchar(20)                NOT NULL,
+    tenant_id   nvarchar(20)  DEFAULT ('000000') NULL,
     dict_sort   int           DEFAULT ((0)) NULL,
     dict_label  nvarchar(100) DEFAULT ''    NULL,
     dict_value  nvarchar(100) DEFAULT ''    NULL,
@@ -1036,7 +1036,7 @@ GO
 CREATE TABLE sys_dict_type
 (
     dict_id     bigint                      NOT NULL,
-    tenant_id   nvarchar(20)                NOT NULL,
+    tenant_id   nvarchar(20)  DEFAULT ('000000') NULL,
     dict_name   nvarchar(100) DEFAULT ''    NULL,
     dict_type   nvarchar(100) DEFAULT ''    NULL,
     status      nchar(1)      DEFAULT ('0') NULL,
@@ -1152,7 +1152,7 @@ GO
 CREATE TABLE sys_logininfor
 (
     info_id        bigint                      NOT NULL,
-    tenant_id      nvarchar(20)                NOT NULL,
+    tenant_id      nvarchar(20)  DEFAULT ('000000') NULL,
     user_name      nvarchar(50)  DEFAULT ''    NULL,
     ipaddr         nvarchar(128) DEFAULT ''    NULL,
     login_location nvarchar(255) DEFAULT ''    NULL,
@@ -1591,7 +1591,7 @@ GO
 CREATE TABLE sys_notice
 (
     notice_id      bigint                     NOT NULL,
-    tenant_id      nvarchar(20)               NOT NULL,
+    tenant_id      nvarchar(20) DEFAULT ('000000') NULL,
     notice_title   nvarchar(50)               NOT NULL,
     notice_type    nchar(1)                   NOT NULL,
     notice_content nvarchar(max)              NULL,
@@ -1696,7 +1696,7 @@ GO
 CREATE TABLE sys_oper_log
 (
     oper_id        bigint                       NOT NULL,
-    tenant_id      nvarchar(20)                 NOT NULL,
+    tenant_id      nvarchar(20)   DEFAULT ('000000') NULL,
     title          nvarchar(50)   DEFAULT ''    NULL,
     business_type  int            DEFAULT ((0)) NULL,
     method         nvarchar(100)  DEFAULT ''    NULL,
@@ -1843,18 +1843,18 @@ GO
 
 CREATE TABLE sys_post
 (
-    post_id     bigint                  NOT NULL,
-    tenant_id   nvarchar(20)            NOT NULL,
-    post_code   nvarchar(64)            NOT NULL,
-    post_name   nvarchar(50)            NOT NULL,
-    post_sort   int                     NOT NULL,
-    status      nchar(1)                NOT NULL,
-    create_dept bigint                  NULL,
-    create_by   bigint                  NULL,
-    create_time datetime2(7)            NULL,
-    update_by   bigint                  NULL,
-    update_time datetime2(7)            NULL,
-    remark      nvarchar(500)           NULL,
+    post_id     bigint                          NOT NULL,
+    tenant_id   nvarchar(20) DEFAULT ('000000') NULL,
+    post_code   nvarchar(64)                    NOT NULL,
+    post_name   nvarchar(50)                    NOT NULL,
+    post_sort   int                             NOT NULL,
+    status      nchar(1)                        NOT NULL,
+    create_dept bigint                          NULL,
+    create_by   bigint                          NULL,
+    create_time datetime2(7)                    NULL,
+    update_by   bigint                          NULL,
+    update_time datetime2(7)                    NULL,
+    remark      nvarchar(500)                   NULL,
     CONSTRAINT PK__sys_post__3ED7876668E2D081 PRIMARY KEY CLUSTERED (post_id)
         WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
         ON [PRIMARY]
@@ -1952,7 +1952,7 @@ GO
 CREATE TABLE sys_role
 (
     role_id             bigint                     NOT NULL,
-    tenant_id           nvarchar(20)               NOT NULL,
+    tenant_id           nvarchar(20) DEFAULT ('000000') NULL,
     role_name           nvarchar(30)               NOT NULL,
     role_key            nvarchar(100)              NOT NULL,
     role_sort           int                        NOT NULL,
@@ -2314,7 +2314,7 @@ GO
 CREATE TABLE sys_user
 (
     user_id     bigint                             NOT NULL,
-    tenant_id   nvarchar(20)                       NOT NULL,
+    tenant_id   nvarchar(20)  DEFAULT ('000000')   NULL,
     dept_id     bigint                             NULL,
     user_name   nvarchar(30)                       NOT NULL,
     nick_name   nvarchar(30)                       NOT NULL,
@@ -2549,7 +2549,7 @@ GO
 CREATE TABLE sys_oss
 (
     oss_id        bigint                          NOT NULL,
-    tenant_id     nvarchar(20)                    NOT NULL,
+    tenant_id     nvarchar(20)  DEFAULT ('000000') NULL,
     file_name     nvarchar(255) DEFAULT ''        NOT NULL,
     original_name nvarchar(255) DEFAULT ''        NOT NULL,
     file_suffix   nvarchar(10)  DEFAULT ''        NOT NULL,
@@ -2648,7 +2648,7 @@ GO
 CREATE TABLE sys_oss_config
 (
     oss_config_id bigint                      NOT NULL,
-    tenant_id     nvarchar(20)                NOT NULL,
+    tenant_id     nvarchar(20)  DEFAULT ('000000') NULL,
     config_key    nvarchar(20)  DEFAULT ''    NOT NULL,
     access_key    nvarchar(255) DEFAULT ''    NULL,
     secret_key    nvarchar(255) DEFAULT ''    NULL,