main
黄海 9 months ago
parent 67377ab692
commit c7d8afe644

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

Loading…
Cancel
Save