diff --git a/src/test/java/youhong/ai/mymapper/command/constant/CommandConsTant.java b/src/test/java/youhong/ai/mymapper/command/constant/CommandConsTant.java index db07d2d..2dd6fff 100644 --- a/src/test/java/youhong/ai/mymapper/command/constant/CommandConsTant.java +++ b/src/test/java/youhong/ai/mymapper/command/constant/CommandConsTant.java @@ -33,4 +33,7 @@ public class CommandConsTant { public static final String VARIABLE_PREPARED_STATEMENT = "#{"; + + public static final char[] COMMAND_PRE_FIX = new char[]{'m', 'y', '-'}; + } diff --git a/src/test/java/youhong/ai/mymapper/util/ParseSqlUtil.java b/src/test/java/youhong/ai/mymapper/util/ParseSqlUtil.java index d44a1fa..49f0667 100644 --- a/src/test/java/youhong/ai/mymapper/util/ParseSqlUtil.java +++ b/src/test/java/youhong/ai/mymapper/util/ParseSqlUtil.java @@ -22,8 +22,6 @@ import java.util.Objects; */ public class ParseSqlUtil { - private final char[] commandPrefix = new char[]{'m', 'y', '-'}; - public final static ThreadLocal> PARSE_PARAM_LOCALE = new ThreadLocal<>(); public final static ThreadLocal> PARSE_TEMP_PARAM_LOCALE = new ThreadLocal<>(); @@ -75,7 +73,7 @@ public class ParseSqlUtil { String tempSql = parseStatement(sqlBuilder.toString()); sqlBuilder.delete(0, sqlBuilder.length()); sqlBuilder.append(tempSql); - i += commandPrefix.length + 1; + i += CommandConsTant.COMMAND_PRE_FIX.length + 1; SqlCommandDefinition commandDefinition = parseCommand(chars, i); sqlBuilder.append(commandDefinition.getCommandContent()); i += commandDefinition.getCommandLength(); @@ -139,10 +137,10 @@ public class ParseSqlUtil { } private boolean checkCommand(char[] chars, int index) { - if (index + commandPrefix.length + 1 >= chars.length) { + if (index + CommandConsTant.COMMAND_PRE_FIX.length + 1 >= chars.length) { return false; } - for (char prefix : commandPrefix) { + for (char prefix : CommandConsTant.COMMAND_PRE_FIX) { if (prefix != chars[++index]) { return false; }