提交pgsql类

pull/16/head
AndrewFeng 2021-05-14 22:12:29 +08:00
parent d508181b61
commit 8980f29206
3 changed files with 37 additions and 2 deletions

View File

@ -0,0 +1,34 @@
package cn.stylefeng.roses.kernel.config.modular.data;
import cn.hutool.db.Entity;
import cn.hutool.db.handler.EntityListHandler;
import cn.hutool.db.sql.SqlExecutor;
import cn.stylefeng.roses.kernel.config.api.SysConfigDataApi;
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
import lombok.extern.slf4j.Slf4j;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
/**
* Mysql
*
* @author AndrewFeng
* @date 2021/5/14 21:18
*/
@Slf4j
public class PgsqlSysConfigData implements SysConfigDataApi {
@Override
public List<Entity> getConfigs(Connection conn) throws SQLException {
return SqlExecutor.query(conn, getConfigListSql(), new EntityListHandler(), StatusEnum.ENABLE.getCode(), YesOrNotEnum.N.getCode());
}
@Override
public String getConfigListSql() {
return "select config_code, config_value from sys_config where status_flag = ? and del_flag = ?";
}
}

View File

@ -2,6 +2,7 @@ package cn.stylefeng.roses.kernel.config.modular.factory;
import cn.stylefeng.roses.kernel.config.api.SysConfigDataApi;
import cn.stylefeng.roses.kernel.config.modular.data.MysqlSysConfigData;
import cn.stylefeng.roses.kernel.config.modular.data.PgsqlSysConfigData;
import cn.stylefeng.roses.kernel.rule.enums.DbTypeEnum;
import cn.stylefeng.roses.kernel.rule.util.DatabaseTypeUtil;
@ -24,7 +25,7 @@ public class SysConfigDataFactory {
if (DbTypeEnum.MYSQL.equals(dbType)) {
return new MysqlSysConfigData();
} else if (DbTypeEnum.PG_SQL.equals(dbType)) {
// todo
return new PgsqlSysConfigData();
} else if (DbTypeEnum.MS_SQL.equals(dbType)) {
// todo
} else if (DbTypeEnum.ORACLE.equals(dbType)) {

View File

@ -108,7 +108,7 @@ public class ConfigInitListener implements ApplicationListener<ApplicationContex
entityList.forEach(sysConfig -> ConfigContext.me().putConfig(sysConfig.getStr("config_code"), sysConfig.getStr("config_value")));
}
} catch (ClassNotFoundException e) {
log.error("初始化系统配置表失败,找不到com.mysql.cj.jdbc.Driver类", e);
log.error("初始化系统配置表失败,找不到{}类 : {}",driverClassName,e);
throw new ConfigException(ConfigExceptionEnum.CLASS_NOT_FOUND_ERROR);
} catch (SQLException sqlException) {
log.error("初始化系统配置表失败,执行查询语句失败", sqlException);