init commit

This commit is contained in:
Jeremy Liang
2026-02-04 04:54:55 +08:00
parent ce1514fd39
commit 4c86f8dd1d
2 changed files with 15 additions and 10 deletions

View File

@@ -347,8 +347,8 @@ public class TapeRepositoryGeneratorPlugin extends PluginAdapter {
// 原有方法生成逻辑(无修改)
generateFindAnyByIdMethod(implClass, modelClassName, mapperFieldName, exampleClassName);
generateFindValidByIdMethod(implClass, modelClassName, exampleClassName);
generateFindTrashByIdMethod(implClass, modelClassName, exampleClassName);
generateFindValidByIdMethod(implClass, modelClassName, mapperFieldName, exampleClassName);
generateFindTrashByIdMethod(implClass, modelClassName, mapperFieldName, exampleClassName);
generateInsertMethod(implClass, modelClassName, mapperFieldName, introspectedTable);
generateUpdateMethod(implClass, modelClassName, exampleClassName, mapperFieldName, introspectedTable, hasBLOBColumns);
generateDeleteByIdMethod(implClass, modelClassName, mapperFieldName);
@@ -509,6 +509,7 @@ public class TapeRepositoryGeneratorPlugin extends PluginAdapter {
method.setReturnType(new FullyQualifiedJavaType(modelClassName));
method.addParameter(new Parameter(new FullyQualifiedJavaType("long"), "id"));
method.addException(new FullyQualifiedJavaType("Throwable"));
method.addBodyLine(modelClassName + " aDo = " + mapperFieldName + ".selectByPrimaryKey(id);");
method.addBodyLine("if (aDo != null && aDo.getIsDelete() == 1) {");
method.addBodyLine(" return null;");
@@ -518,7 +519,7 @@ public class TapeRepositoryGeneratorPlugin extends PluginAdapter {
implClass.addMethod(method);
}
private void generateFindValidByIdMethod(TopLevelClass implClass, String modelClassName, String exampleClassName) {
private void generateFindValidByIdMethod(TopLevelClass implClass, String modelClassName, String mapperFieldName, String exampleClassName) {
Method method = new Method("findValidById");
method.addAnnotation("@Override");
method.setVisibility(JavaVisibility.PUBLIC);
@@ -526,14 +527,16 @@ public class TapeRepositoryGeneratorPlugin extends PluginAdapter {
method.addParameter(new Parameter(new FullyQualifiedJavaType("long"), "id"));
method.addException(new FullyQualifiedJavaType("Throwable"));
method.addBodyLine(exampleClassName + " doExample = new " + exampleClassName + "();");
method.addBodyLine("doExample.createCriteria().andGuidEqualTo(id);");
method.addBodyLine("return findValidOne(doExample);");
method.addBodyLine(modelClassName + " aDo = " + mapperFieldName + ".selectByPrimaryKey(id);");
method.addBodyLine("if (aDo != null && (aDo.getIsDelete() == 1 || aDo.getIsHidden() == 1)) {");
method.addBodyLine(" return null;");
method.addBodyLine("}");
method.addBodyLine("return aDo;");
implClass.addMethod(method);
}
private void generateFindTrashByIdMethod(TopLevelClass implClass, String modelClassName, String exampleClassName) {
private void generateFindTrashByIdMethod(TopLevelClass implClass, String modelClassName, String mapperFieldName, String exampleClassName) {
Method method = new Method("findTrashById");
method.addAnnotation("@Override");
method.setVisibility(JavaVisibility.PUBLIC);
@@ -541,9 +544,11 @@ public class TapeRepositoryGeneratorPlugin extends PluginAdapter {
method.addParameter(new Parameter(new FullyQualifiedJavaType("long"), "id"));
method.addException(new FullyQualifiedJavaType("Throwable"));
method.addBodyLine(exampleClassName + " doExample = new " + exampleClassName + "();");
method.addBodyLine("doExample.createCriteria().andGuidEqualTo(id);");
method.addBodyLine("return findTrashOne(doExample);");
method.addBodyLine(modelClassName + " aDo = " + mapperFieldName + ".selectByPrimaryKey(id);");
method.addBodyLine("if (aDo != null && (aDo.getIsDelete() == 1 || aDo.getIsHidden() == 0)) {");
method.addBodyLine(" return null;");
method.addBodyLine("}");
method.addBodyLine("return aDo;");
implClass.addMethod(method);
}