Commit 35f3c618 authored by Spencer Chang's avatar Spencer Chang

[fix] 修复当*是计算符号时不支持sql查询问题

parent a7d6df93
......@@ -54,7 +54,7 @@ public class SysDpDownloadLogServiceImpl implements SysDpDownloadLogService {
for (int i = 1; i <= length - 1;i++){
LocalDate tmp = LocalDate.now().minusDays(i);
Date date = Date.from(tmp.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
downloadFiles[i] = logPath + "leaf-" + DateUtil.format(new Date(),"yyyy-MM-dd") + ".log";
downloadFiles[i] = logPath + "leaf-" + DateUtil.format(date,"yyyy-MM-dd") + ".log";
}
// 查找日志目录下所有文件
List<String> files = new ArrayList<>(30);
......
......@@ -7,6 +7,7 @@ package com.hand.hls.dp.util;
*/
public interface SqlConstantUtils {
String SQL_STAR = "*";
String SQL_COMMA = ",";
String SQL_SELECT = "select";
String SQL_FROM = "from";
String SQL_FROM_UPPER = "FROM";
......
......@@ -60,7 +60,18 @@ public class SqlUtils {
for (String condition : conditions) {
if (StringUtils.containsIgnoreCase(sql, condition)) {
return true;
if (StringUtils.equals(condition, SqlConstantUtils.SQL_STAR)){
String tmpSql = sql;
int count = StringUtils.countMatches(tmpSql, SqlConstantUtils.SQL_STAR);
for (int i = 0; i < count; i++) {
tmpSql = StringUtils.trim(StringUtils.substring(tmpSql, SqlConstantUtils.SQL_STAR));
ifStringUtils.startsWithIgnoreCase(tmpSql, SqlConstantUtils.SQL_FROM) || StringUtils.startsWithIgnoreCase(tmpSql, SqlConstantUtils.SQL_COMMA){
return true;
}
}
} else {
return true;
}
}
}
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment