【7.2.5】【db】更新获取dbType的获取方式

pull/37/head
fengshuonan 2022-09-17 15:30:44 +08:00
parent f47bcf8cfb
commit 883a377c3e
2 changed files with 4 additions and 12 deletions

View File

@ -31,16 +31,15 @@ import cn.stylefeng.roses.kernel.auth.api.LoginUserApi;
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
import cn.stylefeng.roses.kernel.auth.api.pojo.login.basic.SimpleRoleInfo;
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
import cn.stylefeng.roses.kernel.db.api.context.DbOperatorContext;
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
import cn.stylefeng.roses.kernel.db.api.pojo.druid.DruidProperties;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
import cn.stylefeng.roses.kernel.rule.constants.TreeConstants;
import cn.stylefeng.roses.kernel.rule.enums.DbTypeEnum;
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
import cn.stylefeng.roses.kernel.rule.tree.factory.DefaultTreeBuildFactory;
import cn.stylefeng.roses.kernel.rule.util.DatabaseTypeUtil;
import cn.stylefeng.roses.kernel.scanner.api.ResourceReportApi;
import cn.stylefeng.roses.kernel.scanner.api.pojo.resource.ReportResourceParam;
import cn.stylefeng.roses.kernel.scanner.api.pojo.resource.ResourceDefinition;
@ -90,9 +89,6 @@ public class SysResourceServiceImpl extends ServiceImpl<SysResourceMapper, SysRe
@Resource(name = "resourceCache")
private CacheOperatorApi<ResourceDefinition> resourceCache;
@Resource
private DruidProperties druidProperties;
@Override
public PageResult<SysResource> findPage(ResourceRequest resourceRequest) {
LambdaQueryWrapper<SysResource> wrapper = createWrapper(resourceRequest);
@ -306,7 +302,7 @@ public class SysResourceServiceImpl extends ServiceImpl<SysResourceMapper, SysRe
}
// 将资源存入库中
DbTypeEnum currentDbType = DatabaseTypeUtil.getDbType(druidProperties.getUrl());
DbTypeEnum currentDbType = DbOperatorContext.me().getCurrentDbType();
if (DbTypeEnum.MYSQL.equals(currentDbType)) {
this.getBaseMapper().insertBatchSomeColumn(allResources);
} else {

View File

@ -26,9 +26,8 @@ package cn.stylefeng.roses.kernel.system.modular.role.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
import cn.stylefeng.roses.kernel.db.api.pojo.druid.DruidProperties;
import cn.stylefeng.roses.kernel.db.api.context.DbOperatorContext;
import cn.stylefeng.roses.kernel.rule.enums.DbTypeEnum;
import cn.stylefeng.roses.kernel.rule.util.DatabaseTypeUtil;
import cn.stylefeng.roses.kernel.system.api.pojo.role.request.SysRoleRequest;
import cn.stylefeng.roses.kernel.system.modular.role.entity.SysRoleResource;
import cn.stylefeng.roses.kernel.system.modular.role.mapper.SysRoleResourceMapper;
@ -56,9 +55,6 @@ public class SysRoleResourceServiceImpl extends ServiceImpl<SysRoleResourceMappe
@Resource(name = "roleResourceCacheApi")
private CacheOperatorApi<List<String>> roleResourceCacheApi;
@Resource
private DruidProperties druidProperties;
@Override
@Transactional(rollbackFor = Exception.class)
public void grantResource(SysRoleRequest sysRoleRequest) {
@ -151,7 +147,7 @@ public class SysRoleResourceServiceImpl extends ServiceImpl<SysRoleResourceMappe
@Override
public void quickSaveAll(List<SysRoleResource> sysRoleResourceList) {
DbTypeEnum currentDbType = DatabaseTypeUtil.getDbType(druidProperties.getUrl());
DbTypeEnum currentDbType = DbOperatorContext.me().getCurrentDbType();
if (DbTypeEnum.MYSQL.equals(currentDbType)) {
this.getBaseMapper().insertBatchSomeColumn(sysRoleResourceList);
} else {