main
黄海 9 months ago
parent 67377ab692
commit c7d8afe644

@ -171,11 +171,11 @@ public class GenerateCode {
//开始生成 //开始生成
List<String> tables = getTableNames(conn); List<String> tables = getTableNames(conn);
String tableNames = ""; StringBuilder tableNames = new StringBuilder();
//表描述 //表描述
for (String table : tables) { for (String table : tables) {
JSONObject jo = getStructure(conn, table); JSONObject jo = getStructure(conn, table);
tableNames += table + ","; tableNames.append(table).append(",");
if (StrKit.isBlank(jo.getStr("key"))) { if (StrKit.isBlank(jo.getStr("key"))) {
dsKit.print("表" + table + "没有主键,请检查!"); dsKit.print("表" + table + "没有主键,请检查!");
@ -183,12 +183,12 @@ public class GenerateCode {
//生成代码 //生成代码
autoCodeFreeMaker(jo); autoCodeFreeMaker(jo);
} }
if (StrKit.isBlank(tableNames)) { if (StrKit.isBlank(tableNames.toString())) {
dsKit.print("没有找到表,请检查!"); dsKit.print("没有找到表,请检查!");
return; return;
} }
//去掉最后的逗号 //去掉最后的逗号
tableNames = tableNames.substring(0, tableNames.length() - 1); tableNames = new StringBuilder(tableNames.substring(0, tableNames.length() - 1));
//关闭数据库 //关闭数据库
conn.close(); conn.close();
@ -261,18 +261,18 @@ public class GenerateCode {
dataModel.put("tableName", tableName);//表名 dataModel.put("tableName", tableName);//表名
//更新时的填充参数 //更新时的填充参数
String updateParas = ""; StringBuilder updateParas = new StringBuilder();
for (String s : parasWithoutPrimaryKeyAndDataType.split(",")) { for (String s : parasWithoutPrimaryKeyAndDataType.split(",")) {
if (s.equals("create_time")) { if (s.equals("create_time")) {
updateParas += s + "=now(),"; updateParas.append(s).append("=now(),");
} else { } else {
updateParas += s + "=?,"; updateParas.append(s).append("=?,");
} }
} }
if (updateParas.endsWith(",")) { if (updateParas.toString().endsWith(",")) {
updateParas = updateParas.substring(0, updateParas.length() - 1); updateParas = new StringBuilder(updateParas.substring(0, updateParas.length() - 1));
} }
dataModel.put("updateParas", updateParas); dataModel.put("updateParas", updateParas.toString());
//打印调试信息 //打印调试信息
//System.out.println(dataModel); //System.out.println(dataModel);

Loading…
Cancel
Save