mirror of https://gitee.com/stylefeng/roses
【7.2.5】【db】更新获取当前数据库类型的接口
parent
e477aa2427
commit
f47bcf8cfb
|
@ -24,6 +24,8 @@
|
|||
*/
|
||||
package cn.stylefeng.roses.kernel.db.api;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.enums.DbTypeEnum;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -34,6 +36,14 @@ import java.util.Set;
|
|||
*/
|
||||
public interface DbOperatorApi {
|
||||
|
||||
/**
|
||||
* 获取当前数据库连接的数据库类型
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2022/9/17 15:27
|
||||
*/
|
||||
DbTypeEnum getCurrentDbType();
|
||||
|
||||
/**
|
||||
* 返回SelectCount SQL执行的结果
|
||||
*
|
||||
|
|
|
@ -27,9 +27,13 @@ package cn.stylefeng.roses.kernel.db.mp.dboperator;
|
|||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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 org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -43,6 +47,14 @@ import java.util.stream.Collectors;
|
|||
@Service
|
||||
public class DbOperatorImpl implements DbOperatorApi {
|
||||
|
||||
@Resource
|
||||
private DruidProperties druidProperties;
|
||||
|
||||
@Override
|
||||
public DbTypeEnum getCurrentDbType() {
|
||||
return DatabaseTypeUtil.getDbType(druidProperties.getUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int selectCount(String sql, Object... args) {
|
||||
long selectCount = SqlRunner.db().selectCount(sql, args);
|
||||
|
|
Loading…
Reference in New Issue