【7.2.5】【db】更新获取当前数据库类型的接口

pull/37/head
fengshuonan 2022-09-17 15:29:29 +08:00
parent e477aa2427
commit f47bcf8cfb
2 changed files with 22 additions and 0 deletions

View File

@ -24,6 +24,8 @@
*/ */
package cn.stylefeng.roses.kernel.db.api; package cn.stylefeng.roses.kernel.db.api;
import cn.stylefeng.roses.kernel.rule.enums.DbTypeEnum;
import java.util.Set; import java.util.Set;
/** /**
@ -34,6 +36,14 @@ import java.util.Set;
*/ */
public interface DbOperatorApi { public interface DbOperatorApi {
/**
*
*
* @author fengshuonan
* @date 2022/9/17 15:27
*/
DbTypeEnum getCurrentDbType();
/** /**
* SelectCount SQL * SelectCount SQL
* *

View File

@ -27,9 +27,13 @@ package cn.stylefeng.roses.kernel.db.mp.dboperator;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.stylefeng.roses.kernel.db.api.DbOperatorApi; import cn.stylefeng.roses.kernel.db.api.DbOperatorApi;
import cn.stylefeng.roses.kernel.db.api.pojo.druid.DruidProperties;
import cn.stylefeng.roses.kernel.rule.enums.DbTypeEnum;
import cn.stylefeng.roses.kernel.rule.util.DatabaseTypeUtil;
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner; import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -43,6 +47,14 @@ import java.util.stream.Collectors;
@Service @Service
public class DbOperatorImpl implements DbOperatorApi { public class DbOperatorImpl implements DbOperatorApi {
@Resource
private DruidProperties druidProperties;
@Override
public DbTypeEnum getCurrentDbType() {
return DatabaseTypeUtil.getDbType(druidProperties.getUrl());
}
@Override @Override
public int selectCount(String sql, Object... args) { public int selectCount(String sql, Object... args) {
long selectCount = SqlRunner.db().selectCount(sql, args); long selectCount = SqlRunner.db().selectCount(sql, args);