mirror of https://gitee.com/stylefeng/roses
提交pgsql类
parent
d508181b61
commit
8980f29206
|
@ -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 = ?";
|
||||
}
|
||||
|
||||
}
|
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue