|
@@ -54,4 +54,43 @@ public class ListViewGenerator {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public static void GenListView1(GenCode model) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ Set<String> imports = new HashSet<>();
|
|
|
|
|
+
|
|
|
|
|
+ String templatePath = GetResource.class.getClassLoader().getResource("templates").getPath();
|
|
|
|
|
+ Properties pro = new Properties();
|
|
|
|
|
+ pro.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
|
|
|
|
|
+ pro.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, templatePath);
|
|
|
|
|
+ pro.setProperty("directive.foreach.counter.name", "velocityCount");
|
|
|
|
|
+ pro.setProperty("directive.foreach.counter.initial.value", "1");
|
|
|
|
|
+ Velocity.init(pro);
|
|
|
|
|
+ ToolManager manager = new ToolManager(true, true);
|
|
|
|
|
+ VelocityContext context = new VelocityContext(manager.createContext());
|
|
|
|
|
+ context.put("imports", imports);
|
|
|
|
|
+ context.put("model", model);
|
|
|
|
|
+ Template t = Velocity.getTemplate("ListTemplate1.vm");
|
|
|
|
|
+
|
|
|
|
|
+ String targetFile = model.getClassName() + "s.vue";
|
|
|
|
|
+ File file = new File(model.getViewPath(), targetFile);
|
|
|
|
|
+ if (!file.getParentFile().exists())
|
|
|
|
|
+ file.getParentFile().mkdirs();
|
|
|
|
|
+ if (!file.exists())
|
|
|
|
|
+ file.createNewFile();
|
|
|
|
|
+
|
|
|
|
|
+ FileOutputStream outStream = new FileOutputStream(file);
|
|
|
|
|
+ OutputStreamWriter writer = new OutputStreamWriter(outStream,
|
|
|
|
|
+ "UTF-8");
|
|
|
|
|
+ BufferedWriter sw = new BufferedWriter(writer);
|
|
|
|
|
+ t.merge(context, sw);
|
|
|
|
|
+ sw.flush();
|
|
|
|
|
+ sw.close();
|
|
|
|
|
+ outStream.close();
|
|
|
|
|
+ System.out.println("成功生成列表页:" + file.getAbsolutePath());
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|