Explorar el Código

生成代码调整为模块化存储

hubin hace 1 año
padre
commit
36a6c02d2a

+ 24 - 0
aizuda-generator/src/main/resources/templates/mapper.java.vm

@@ -0,0 +1,24 @@
+package ${package.Mapper};
+
+import ${package.Entity}.${entity};
+import ${superMapperClassPackage};
+#if(${mapperAnnotationClass})
+import ${mapperAnnotationClass.name};
+#end
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ * $!{table.comment} Mapper 接口
+ * </p>
+ *
+ * @author ${author}
+ * @since ${date}
+ */
+#if(${mapperAnnotationClass})
+@${mapperAnnotationClass.simpleName}
+#end
+@Mapper
+public interface ${table.mapperName} extends ${superMapperClass}<${entity}> {
+
+}

+ 26 - 2
aizuda-generator/src/test/java/com/aizuda/generator/TestCodeGenerator.java

@@ -5,11 +5,35 @@
  */
 package com.aizuda.generator;
 
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+
+import java.util.Scanner;
+
 public class TestCodeGenerator {
+    /**
+     * 读取控制台输入内容
+     */
+    private static final Scanner scanner = new Scanner(System.in);
 
     public static void main(String[] args) {
         // 代码生成
-        CodeGenerator.execute("jdbc:postgresql://127.0.0.1:5432/aizuda",
-                "postgres", "123456", "com.aizuda.generate");
+        CodeGenerator.execute("jdbc:postgresql://127.0.0.1:5432/aizuda-boot",
+                "postgres", "123456", "com.aizuda.boot.modules." + scannerNext("请输入模块名称"));
+    }
+
+    /**
+     * 控制台输入内容读取并打印提示信息
+     *
+     * @param message 提示信息
+     * @return
+     */
+    public static String scannerNext(String message) {
+        System.out.println(message);
+        String nextLine = scanner.nextLine();
+        if (StringUtils.isBlank(nextLine)) {
+            // 如果输入空行继续等待
+            return scanner.next();
+        }
+        return nextLine;
     }
 }