【8.0】【system】封装获取租户id的配置

pull/57/head
fengshuonan 2023-08-31 01:03:20 +08:00
parent 6e216f911f
commit 1e49102fda
3 changed files with 19 additions and 1 deletions

View File

@ -72,4 +72,9 @@ public interface SysConstants {
*/
Long DEFAULT_SYS_CACHE_TIMEOUT_SECONDS = 3600L;
/**
* ID
*/
Long DEFAULT_ROOT_TENANT_ID = 1L;
}

View File

@ -46,4 +46,14 @@ public class SysConfigExpander {
return ConfigContext.me().getSysConfigValueWithDefault("SYS_DEFAULT_PASSWORD", String.class, SysConstants.DEFAULT_LOGIN_PASSWORD);
}
/**
* id
*
* @author fengshuonan
* @since 2023/8/31 0:55
*/
public static Long getDefaultRootTenantId() {
return ConfigContext.me().getSysConfigValueWithDefault("DEFAULT_ROOT_TENANT_ID", Long.class, SysConstants.DEFAULT_ROOT_TENANT_ID);
}
}

View File

@ -25,6 +25,7 @@
package cn.stylefeng.roses.kernel.sys.starter.init;
import cn.stylefeng.roses.kernel.sys.api.constants.SysConstants;
import cn.stylefeng.roses.kernel.sys.api.expander.SysConfigExpander;
import cn.stylefeng.roses.kernel.sys.modular.menu.entity.SysMenu;
import cn.stylefeng.roses.kernel.sys.modular.menu.entity.SysMenuOptions;
import cn.stylefeng.roses.kernel.sys.modular.menu.service.SysMenuOptionsService;
@ -73,9 +74,11 @@ public class InitAdminService {
@Transactional(rollbackFor = Exception.class)
public void initSuperAdmin() {
// 找到后台管理员角色id
// 找到默认系统租户下,后台管理员角色id
LambdaQueryWrapper<SysRole> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysRole::getRoleCode, SysConstants.BACKEND_ADMIN_ROLE_CODE);
// 默认根租户
queryWrapper.eq(SysRole::getTenantId, SysConfigExpander.getDefaultRootTenantId());
queryWrapper.select(SysRole::getRoleId);
SysRole superAdminRole = sysRoleService.getOne(queryWrapper);