mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-20 18:15:56 +08:00
update 优化 sys_config 适配多租户
This commit is contained in:
parent
edd93d1d38
commit
09780d5817
@ -144,7 +144,6 @@ tenant:
|
||||
# 排除表
|
||||
excludes:
|
||||
- sys_menu
|
||||
- sys_config
|
||||
- sys_tenant
|
||||
- sys_tenant_package
|
||||
- sys_role_dept
|
||||
|
||||
@ -43,4 +43,9 @@ public interface TenantConstants {
|
||||
*/
|
||||
String TENANT_ADMIN_ROLE_NAME = "管理员";
|
||||
|
||||
/**
|
||||
* 默认租户ID
|
||||
*/
|
||||
String DEFAULT_TENANT_ID = "000000";
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ package com.ruoyi.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.mybatis.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.mybatis.core.domain.TenantEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@ -15,7 +15,7 @@ import lombok.EqualsAndHashCode;
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_config")
|
||||
public class SysConfig extends BaseEntity {
|
||||
public class SysConfig extends TenantEntity {
|
||||
|
||||
/**
|
||||
* 参数主键
|
||||
|
||||
@ -52,6 +52,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
private final SysUserRoleMapper sysUserRoleMapper;
|
||||
private final SysDictTypeMapper sysDictTypeMapper;
|
||||
private final SysDictDataMapper sysDictDataMapper;
|
||||
private final SysConfigMapper sysConfigMapper;
|
||||
|
||||
/**
|
||||
* 查询租户
|
||||
@ -160,8 +161,11 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
userRole.setRoleId(roleId);
|
||||
sysUserRoleMapper.insert(userRole);
|
||||
|
||||
List<SysDictType> dictTypeList = sysDictTypeMapper.selectList();
|
||||
List<SysDictData> dictDataList = sysDictDataMapper.selectList();
|
||||
String defaultTenantId = TenantConstants.DEFAULT_TENANT_ID;
|
||||
List<SysDictType> dictTypeList = sysDictTypeMapper.selectList(
|
||||
new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getTenantId, defaultTenantId));
|
||||
List<SysDictData> dictDataList = sysDictDataMapper.selectList(
|
||||
new LambdaQueryWrapper<SysDictData>().eq(SysDictData::getTenantId, defaultTenantId));
|
||||
for (SysDictType dictType : dictTypeList) {
|
||||
dictType.setDictId(null);
|
||||
dictType.setTenantId(tenantId);
|
||||
@ -173,6 +177,14 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
sysDictTypeMapper.insertBatch(dictTypeList);
|
||||
sysDictDataMapper.insertBatch(dictDataList);
|
||||
|
||||
List<SysConfig> sysConfigList = sysConfigMapper.selectList(
|
||||
new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getTenantId, defaultTenantId));
|
||||
for (SysConfig config : sysConfigList) {
|
||||
config.setConfigId(null);
|
||||
config.setTenantId(tenantId);
|
||||
}
|
||||
sysConfigMapper.insertBatch(sysConfigList);
|
||||
|
||||
TenantHelper.disableIgnore();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -791,6 +791,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,
|
||||
config_name varchar2(100) default '',
|
||||
config_key varchar2(100) default '',
|
||||
config_value varchar2(100) default '',
|
||||
@ -806,6 +807,7 @@ alter table sys_config add constraint pk_sys_config primary key (config_id);
|
||||
|
||||
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 '参数键值';
|
||||
@ -817,11 +819,11 @@ 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, sysdate, 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, sysdate, null, null, '初始化密码 123456' );
|
||||
insert into sys_config values(3, '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 103, 1, sysdate, null, null, '深色主题theme-dark,浅色主题theme-light' );
|
||||
insert into sys_config values(5, '账号自助-是否开启用户注册功能', 'sys.account.registerUser', 'false', 'Y', 103, 1, sysdate, null, null, '是否开启注册用户功能(true开启,false关闭)');
|
||||
insert into sys_config values(11, 'OSS预览列表资源开关', 'sys.oss.previewListResource', 'true', 'Y', 103, 1, sysdate, null, null, 'true:开启, false:关闭');
|
||||
insert into sys_config values(1, '000000', '主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', 103, 1, sysdate, 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, sysdate, null, null, '初始化密码 123456' );
|
||||
insert into sys_config values(3, '000000', '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 103, 1, sysdate, null, null, '深色主题theme-dark,浅色主题theme-light' );
|
||||
insert into sys_config values(5, '000000', '账号自助-是否开启用户注册功能', 'sys.account.registerUser', 'false', 'Y', 103, 1, sysdate, null, null, '是否开启注册用户功能(true开启,false关闭)');
|
||||
insert into sys_config values(11, '000000', 'OSS预览列表资源开关', 'sys.oss.previewListResource', 'true', 'Y', 103, 1, sysdate, null, null, 'true:开启, false:关闭');
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
|
||||
@ -810,6 +810,7 @@ drop table if exists sys_config;
|
||||
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,
|
||||
@ -825,6 +826,7 @@ create table if not exists sys_config
|
||||
|
||||
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 '参数键值';
|
||||
@ -836,11 +838,11 @@ 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,浅色主题theme-light' );
|
||||
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,浅色主题theme-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:关闭');
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
|
||||
@ -607,6 +607,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 '租户编号',
|
||||
config_name varchar(100) default '' comment '参数名称',
|
||||
config_key varchar(100) default '' comment '参数键名',
|
||||
config_value varchar(500) default '' comment '参数键值',
|
||||
@ -620,11 +621,11 @@ create table sys_config (
|
||||
primary key (config_id)
|
||||
) engine=innodb comment = '参数配置表';
|
||||
|
||||
insert into sys_config values(1, '主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', 103, 1, sysdate(), 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, sysdate(), null, null, '初始化密码 123456' );
|
||||
insert into sys_config values(3, '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 103, 1, sysdate(), null, null, '深色主题theme-dark,浅色主题theme-light' );
|
||||
insert into sys_config values(5, '账号自助-是否开启用户注册功能', 'sys.account.registerUser', 'false', 'Y', 103, 1, sysdate(), null, null, '是否开启注册用户功能(true开启,false关闭)');
|
||||
insert into sys_config values(11, 'OSS预览列表资源开关', 'sys.oss.previewListResource', 'true', 'Y', 103, 1, sysdate(), null, null, 'true:开启, false:关闭');
|
||||
insert into sys_config values(1, '000000', '主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', 103, 1, sysdate(), 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, sysdate(), null, null, '初始化密码 123456' );
|
||||
insert into sys_config values(3, '000000', '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 103, 1, sysdate(), null, null, '深色主题theme-dark,浅色主题theme-light' );
|
||||
insert into sys_config values(5, '000000', '账号自助-是否开启用户注册功能', 'sys.account.registerUser', 'false', 'Y', 103, 1, sysdate(), null, null, '是否开启注册用户功能(true开启,false关闭)');
|
||||
insert into sys_config values(11, '000000', 'OSS预览列表资源开关', 'sys.oss.previewListResource', 'true', 'Y', 103, 1, sysdate(), null, null, 'true:开启, false:关闭');
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
|
||||
@ -585,6 +585,7 @@ GO
|
||||
CREATE TABLE sys_config
|
||||
(
|
||||
config_id bigint NOT NULL,
|
||||
tenant_id nvarchar(20) NOT NULL,
|
||||
config_name nvarchar(100) DEFAULT '' NULL,
|
||||
config_key nvarchar(100) DEFAULT '' NULL,
|
||||
config_value nvarchar(500) DEFAULT '' NULL,
|
||||
@ -608,6 +609,12 @@ EXEC sys.sp_addextendedproperty
|
||||
'TABLE', N'sys_config',
|
||||
'COLUMN', N'config_id'
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty
|
||||
'MS_Description', N'租户编号' ,
|
||||
'SCHEMA', N'dbo',
|
||||
'TABLE', N'sys_config',
|
||||
'COLUMN', N'tenant_id'
|
||||
GO
|
||||
EXEC sys.sp_addextendedproperty
|
||||
'MS_Description', N'参数名称' ,
|
||||
'SCHEMA', N'dbo',
|
||||
@ -674,15 +681,15 @@ EXEC sys.sp_addextendedproperty
|
||||
'TABLE', N'sys_config'
|
||||
GO
|
||||
|
||||
INSERT sys_config VALUES (1, N'主框架页-默认皮肤样式名称', N'sys.index.skinName', N'skin-blue', N'Y', 103, 1, getdate(), NULL, NULL, N'蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow')
|
||||
INSERT sys_config VALUES (1, N'000000', N'主框架页-默认皮肤样式名称', N'sys.index.skinName', N'skin-blue', N'Y', 103, 1, getdate(), NULL, NULL, N'蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow')
|
||||
GO
|
||||
INSERT sys_config VALUES (2, N'用户管理-账号初始密码', N'sys.user.initPassword', N'123456', N'Y', 103, 1, getdate(), NULL, NULL, N'初始化密码 123456')
|
||||
INSERT sys_config VALUES (2, N'000000', N'用户管理-账号初始密码', N'sys.user.initPassword', N'123456', N'Y', 103, 1, getdate(), NULL, NULL, N'初始化密码 123456')
|
||||
GO
|
||||
INSERT sys_config VALUES (3, N'主框架页-侧边栏主题', N'sys.index.sideTheme', N'theme-dark', N'Y', 103, 1, getdate(), NULL, NULL, N'深色主题theme-dark,浅色主题theme-light')
|
||||
INSERT sys_config VALUES (3, N'000000', N'主框架页-侧边栏主题', N'sys.index.sideTheme', N'theme-dark', N'Y', 103, 1, getdate(), NULL, NULL, N'深色主题theme-dark,浅色主题theme-light')
|
||||
GO
|
||||
INSERT sys_config VALUES (5, N'账号自助-是否开启用户注册功能', N'sys.account.registerUser', N'false', N'Y', 103, 1, getdate(), NULL, NULL, N'是否开启注册用户功能(true开启,false关闭)')
|
||||
INSERT sys_config VALUES (5, N'000000', N'账号自助-是否开启用户注册功能', N'sys.account.registerUser', N'false', N'Y', 103, 1, getdate(), NULL, NULL, N'是否开启注册用户功能(true开启,false关闭)')
|
||||
GO
|
||||
INSERT sys_config VALUES (11, N'OSS预览列表资源开关', N'sys.oss.previewListResource', N'true', N'Y', 103, 1, getdate(), NULL, NULL, N'true:开启, false:关闭');
|
||||
INSERT sys_config VALUES (11, N'000000', N'OSS预览列表资源开关', N'sys.oss.previewListResource', N'true', N'Y', 103, 1, getdate(), NULL, NULL, N'true:开启, false:关闭');
|
||||
GO
|
||||
|
||||
CREATE TABLE sys_dept
|
||||
|
||||
Loading…
Reference in New Issue
Block a user