mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 12:12:08 +08:00
enhancement #I61D1N 解析增加 enable 逻辑,完成 sql 改造
This commit is contained in:
@@ -49,16 +49,20 @@ public abstract class AbstractSqlRead implements SqlRead {
|
||||
// 设置游标拉取数量
|
||||
stmt.setFetchSize(SqlReadConstant.FETCH_SIZE_MAX);
|
||||
stmt.setString(1, config.getApplicationName());
|
||||
ParameterMetaData parameterMetaData = stmt.getParameterMetaData();
|
||||
if (parameterMetaData.getParameterCount() == 2) {
|
||||
stmt.setBoolean(2, true);
|
||||
}
|
||||
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
String xml = buildXmlElement(rs);
|
||||
String uniqueKey = buildXmlElementUniqueKey(rs);
|
||||
|
||||
if (hasEnableFiled()){
|
||||
boolean enable = getEnableFiledValue(rs);
|
||||
// 如果停用,直接跳过
|
||||
if (!enable){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
result.put(uniqueKey, xml);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -71,6 +75,16 @@ public abstract class AbstractSqlRead implements SqlRead {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否包含启停字段
|
||||
*/
|
||||
public abstract boolean hasEnableFiled();
|
||||
|
||||
/**
|
||||
* 获取启停字段对应的字段值
|
||||
*/
|
||||
public abstract boolean getEnableFiledValue(ResultSet rs) throws SQLException;
|
||||
|
||||
public abstract String buildQuerySql();
|
||||
|
||||
public abstract String buildXmlElement(ResultSet rs) throws SQLException;
|
||||
|
||||
@@ -23,6 +23,20 @@ public class ChainRead extends AbstractSqlRead {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEnableFiled() {
|
||||
String chainEnableField = super.config.getChainEnableField();
|
||||
return StrUtil.isNotBlank(chainEnableField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnableFiledValue(ResultSet rs) throws SQLException {
|
||||
String chainEnableField = super.config.getChainEnableField();
|
||||
byte enable = rs.getByte(chainEnableField);
|
||||
|
||||
return enable == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String buildQuerySql() {
|
||||
String chainTableName = super.config.getChainTableName();
|
||||
@@ -30,7 +44,7 @@ public class ChainRead extends AbstractSqlRead {
|
||||
String chainNameField = super.config.getChainNameField();
|
||||
String chainApplicationNameField = super.config.getChainApplicationNameField();
|
||||
String applicationName = super.config.getApplicationName();
|
||||
String chainEnableField = super.config.getChainEnableField();
|
||||
|
||||
|
||||
if (StrUtil.isBlank(chainTableName)) {
|
||||
throw new ELSQLException("You did not define the chainTableName property");
|
||||
@@ -43,10 +57,6 @@ public class ChainRead extends AbstractSqlRead {
|
||||
String sqlCmd = StrUtil.format(SqlReadConstant.SQL_PATTERN, chainNameField, elDataField, chainTableName,
|
||||
chainApplicationNameField);
|
||||
|
||||
if (StrUtil.isNotBlank(chainEnableField)){
|
||||
sqlCmd = StrUtil.format("{} {}", sqlCmd, StrUtil.format(SqlReadConstant.SQL_ENABLE_PATTERN, chainEnableField));
|
||||
}
|
||||
|
||||
return sqlCmd;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,20 @@ public class ScriptRead extends AbstractSqlRead {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEnableFiled() {
|
||||
String scriptEnableField = super.config.getScriptEnableField();
|
||||
return StrUtil.isNotBlank(scriptEnableField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnableFiledValue(ResultSet rs) throws SQLException {
|
||||
String scriptEnableField = super.config.getScriptEnableField();
|
||||
byte enable = rs.getByte(scriptEnableField);
|
||||
|
||||
return enable == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String buildQuerySql() {
|
||||
String scriptLanguageField = super.config.getScriptLanguageField();
|
||||
@@ -40,7 +54,7 @@ public class ScriptRead extends AbstractSqlRead {
|
||||
String scriptTypeField = super.config.getScriptTypeField();
|
||||
String scriptApplicationNameField = super.config.getScriptApplicationNameField();
|
||||
String applicationName = super.config.getApplicationName();
|
||||
String scriptEnableField = super.config.getScriptEnableField();
|
||||
|
||||
|
||||
if (StrUtil.isBlank(applicationName) || StrUtil.isBlank(scriptApplicationNameField)) {
|
||||
throw new ELSQLException("You did not define the applicationName or scriptApplicationNameField property");
|
||||
@@ -73,10 +87,6 @@ public class ScriptRead extends AbstractSqlRead {
|
||||
);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(scriptEnableField)){
|
||||
sqlCmd = StrUtil.format("{} {}", sqlCmd, StrUtil.format(SqlReadConstant.SQL_ENABLE_PATTERN, scriptEnableField));
|
||||
}
|
||||
|
||||
return sqlCmd;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user