mirror of https://gitee.com/stylefeng/roses
【8.0】【system】封装获取租户id的配置
parent
6e216f911f
commit
1e49102fda
|
@ -72,4 +72,9 @@ public interface SysConstants {
|
|||
*/
|
||||
Long DEFAULT_SYS_CACHE_TIMEOUT_SECONDS = 3600L;
|
||||
|
||||
/**
|
||||
* 默认租户ID
|
||||
*/
|
||||
Long DEFAULT_ROOT_TENANT_ID = 1L;
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue