|
|
|
@ -250,7 +250,7 @@ public class GenerateCode {
|
|
|
|
|
paraList.add(record);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(parasWithoutPrimaryKey.endsWith(" ")){
|
|
|
|
|
if (parasWithoutPrimaryKey.endsWith(" ")) {
|
|
|
|
|
parasWithoutPrimaryKey = parasWithoutPrimaryKey.substring(0, parasWithoutPrimaryKey.length() - 1);
|
|
|
|
|
}
|
|
|
|
|
dataModel.put("paraList", paraList);//用于注释,显示@para 参数名 参数含义
|
|
|
|
@ -262,10 +262,11 @@ public class GenerateCode {
|
|
|
|
|
dataModel.put("primary_key_type", primary_key_type);//主键类型
|
|
|
|
|
dataModel.put("tableName", tableName);//表名
|
|
|
|
|
|
|
|
|
|
//更新时的填充参数
|
|
|
|
|
String updateParas = "";
|
|
|
|
|
for (String s : parasWithoutPrimaryKeyAndDataType.split(",")) {
|
|
|
|
|
if (s.equals("create_time")) {
|
|
|
|
|
updateParas += s+"=now(),";
|
|
|
|
|
updateParas += s + "=now(),";
|
|
|
|
|
} else {
|
|
|
|
|
updateParas += s + "=?,";
|
|
|
|
|
}
|
|
|
|
@ -275,7 +276,8 @@ public class GenerateCode {
|
|
|
|
|
}
|
|
|
|
|
dataModel.put("updateParas", updateParas);
|
|
|
|
|
|
|
|
|
|
System.out.println(dataModel);
|
|
|
|
|
//打印调试信息
|
|
|
|
|
//System.out.println(dataModel);
|
|
|
|
|
|
|
|
|
|
//调用FreeMarker模板引擎
|
|
|
|
|
Configuration cfg = new Configuration(new Version(2, 3, 33));// 创建一个 Configuration 实例
|
|
|
|
@ -293,7 +295,7 @@ public class GenerateCode {
|
|
|
|
|
Writer out = new FileWriter(codePath + "/" + tableName + "_Controller.txt", StandardCharsets.UTF_8);
|
|
|
|
|
template.process(dataModel, out);
|
|
|
|
|
out.close();
|
|
|
|
|
System.out.println("生成Controller层代码完成。");
|
|
|
|
|
System.out.println("Controller层代码生成完毕。");
|
|
|
|
|
|
|
|
|
|
//2、生成Model层代码
|
|
|
|
|
// 加载模板
|
|
|
|
@ -302,6 +304,6 @@ public class GenerateCode {
|
|
|
|
|
out = new FileWriter(codePath + "/" + tableName + "_Model.txt", StandardCharsets.UTF_8);
|
|
|
|
|
template.process(dataModel, out);
|
|
|
|
|
out.close();
|
|
|
|
|
System.out.println("生成Model层代码完成。");
|
|
|
|
|
System.out.println("Model层代码生成完毕。");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|