【fix sonar】FreemarkerParseFactory文件

This commit is contained in:
梁琦涛
2023-03-03 15:02:54 +08:00
parent a182bf32e8
commit 431ef59d21
@@ -22,6 +22,10 @@ import java.util.regex.Pattern;
@Slf4j
public class FreemarkerParseFactory {
private FreemarkerParseFactory(){
}
private static final String ENCODE = "utf-8";
/**
* 参数格式化工具类
@@ -100,8 +104,6 @@ public class FreemarkerParseFactory {
} catch (Exception e) {
log.error(e.getMessage(), e.fillInStackTrace());
log.error("发送一次的模板key:{ " + tplName + " }");
//System.err.println(e.getMessage());
//System.err.println("模板名:{ "+ tplName +" }");
throw new RuntimeException("解析SQL模板异常");
}
}
@@ -132,8 +134,6 @@ public class FreemarkerParseFactory {
} catch (Exception e) {
log.error(e.getMessage(), e.fillInStackTrace());
log.error("发送一次的模板key:{ " + tplContent + " }");
//System.err.println(e.getMessage());
//System.err.println("模板内容:{ "+ tplContent +" }");
throw new RuntimeException("解析SQL模板异常");
}
}
@@ -144,8 +144,8 @@ public class FreemarkerParseFactory {
private static String getSqlText(String sql) {
// 将注释替换成""
sql = p.matcher(sql).replaceAll("");
sql = sql.replaceAll("\\n", " ").replaceAll("\\t", " ")
.replaceAll("\\s{1,}", " ").trim();
sql = sql.replace("\\n", " ").replace("\\t", " ")
.replace("\\s{1,}", " ").trim();
// 去掉 最后是 where这样的问题
if (sql.endsWith("where") || sql.endsWith("where ")) {
sql = sql.substring(0, sql.lastIndexOf("where"));
@@ -168,4 +168,4 @@ public class FreemarkerParseFactory {
}
return sql;
}
}
}