慢查询打印limit

This commit is contained in:
iqudoo
2026-04-16 01:02:53 +08:00
parent b85966c535
commit c048da1faf
3 changed files with 30 additions and 0 deletions

View File

@@ -259,6 +259,24 @@ public class TapeMybatisGeneratorPlugin extends PluginAdapter {
);
FormatTools.addMethodWithBestPosition(topLevelClass, getOffset);
Method getLimitString = ElementTools.generateMethod(
"getLimitString",
JavaVisibility.PUBLIC,
stringType
);
getLimitString = ElementTools.generateMethodBody(
getLimitString,
"if (getRows() != null) {",
"if (getOffset() != null) {",
"return getOffset() + \",\" + getRows();",
"} else {",
"return getRows() + \"\";",
"}",
"}",
"return null;"
);
FormatTools.addMethodWithBestPosition(topLevelClass, getLimitString);
Method getWhereString = ElementTools.generateMethod(
"getWhereString",
JavaVisibility.PUBLIC,

View File

@@ -1057,6 +1057,9 @@ public class TapeRepositoryGeneratorPlugin extends PluginAdapter {
method.addBodyLine("if (example.getOrderByClause() != null) {");
method.addBodyLine("exampleString += \"\\n\\t|-> order by: \" + example.getOrderByClause();");
method.addBodyLine("}");
method.addBodyLine("if (example.getLimitString() != null) {");
method.addBodyLine("exampleString += \"\\n\\t|-> limit: \" + example.getLimitString();");
method.addBodyLine("}");
method.addBodyLine("LOGGER." + slowQueryLoggerLevel + "(\"[SQL] select " + modelClassName + " valid list primary key use long time\" +");
method.addBodyLine(" \"\\n\\t|-> use time\" + findPrimaryKeyTime + \"ms\" +");
method.addBodyLine(" exampleString +");
@@ -1089,6 +1092,9 @@ public class TapeRepositoryGeneratorPlugin extends PluginAdapter {
method.addBodyLine("if (example.getOrderByClause() != null) {");
method.addBodyLine("exampleString += \"\\n\\t|-> order by: \" + example.getOrderByClause();");
method.addBodyLine("}");
method.addBodyLine("if (example.getLimitString() != null) {");
method.addBodyLine("exampleString += \"\\n\\t|-> limit: \" + example.getLimitString();");
method.addBodyLine("}");
method.addBodyLine("LOGGER." + slowQueryLoggerLevel + "(\"[SQL] select " + modelClassName + " valid list use long time\" +");
method.addBodyLine(" \"\\n\\t|-> use time\" + useTime + \"ms\" +");
method.addBodyLine(" exampleString +");
@@ -1128,6 +1134,9 @@ public class TapeRepositoryGeneratorPlugin extends PluginAdapter {
method.addBodyLine("if (example.getOrderByClause() != null) {");
method.addBodyLine("exampleString += \"\\n\\t|-> order by: \" + example.getOrderByClause();");
method.addBodyLine("}");
method.addBodyLine("if (example.getLimitString() != null) {");
method.addBodyLine("exampleString += \"\\n\\t|-> limit: \" + example.getLimitString();");
method.addBodyLine("}");
method.addBodyLine("LOGGER." + slowQueryLoggerLevel + "(\"[SQL] select " + modelClassName + " trash list primary key use long time\" +");
method.addBodyLine(" \"\\n\\t|-> use time\" + findPrimaryKeyTime + \"ms\" +");
method.addBodyLine(" exampleString +");
@@ -1160,6 +1169,9 @@ public class TapeRepositoryGeneratorPlugin extends PluginAdapter {
method.addBodyLine("if (example.getOrderByClause() != null) {");
method.addBodyLine("exampleString += \"\\n\\t|-> order by: \" + example.getOrderByClause();");
method.addBodyLine("}");
method.addBodyLine("if (example.getLimitString() != null) {");
method.addBodyLine("exampleString += \"\\n\\t|-> limit: \" + example.getLimitString();");
method.addBodyLine("}");
method.addBodyLine("LOGGER." + slowQueryLoggerLevel + "(\"[SQL] select " + modelClassName + " trash list use long time\" +");
method.addBodyLine(" \"\\n\\t|-> use time\" + useTime + \"ms\" +");
method.addBodyLine(" exampleString +");