Commit 2fb94851 authored by Quxl's avatar Quxl

x

parent fbee8f62
...@@ -33,6 +33,7 @@ public class ReverseUtil { ...@@ -33,6 +33,7 @@ public class ReverseUtil {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append("package " + pkg_name + ";" + "\n\n"); sb.append("package " + pkg_name + ";" + "\n\n");
sb.append("import javax.persistence.Entity;" + "\n\n"); sb.append("import javax.persistence.Entity;" + "\n\n");
sb.append("import javax.persistence.Column;" + "\n\n");
if(paramyKeys.size() > 0) { if(paramyKeys.size() > 0) {
sb.append("import javax.persistence.Id;" + "\n\n"); sb.append("import javax.persistence.Id;" + "\n\n");
} }
...@@ -54,7 +55,7 @@ public class ReverseUtil { ...@@ -54,7 +55,7 @@ public class ReverseUtil {
sb.append("@Entity(name=\"" + name + "\")" + "\n"); sb.append("@Entity(name=\"" + name + "\")" + "\n");
sb.append("public class " + StringUtil.upperFirst(name) + " implements java.io.Serializable {" + "\n\n" + "\tprivate static final long serialVersionUID = 1L;" + "\n\n"); sb.append("public class " + StringUtil.upperFirst(name) + " implements java.io.Serializable {" + "\n\n" + "\tprivate static final long serialVersionUID = 1L;" + "\n\n");
processAllAttrs(paramyKeys, columnNames, colTypes, colComments, sb); processAllAttrs(paramyKeys, columnNames, colTypes, colComments, sb);
processAllConstructor(StringUtil.upperFirst(name), comment, columnNames, colTypes, colComments, sb); // processAllConstructor(StringUtil.upperFirst(name), comment, columnNames, colTypes, colComments, sb);
processAllMethod(columnNames, colTypes, colComments, sb); processAllMethod(columnNames, colTypes, colComments, sb);
sb.append("}" + "\n"); sb.append("}" + "\n");
String outputPath = root + File.separator + pkg_name.replace(".", File.separator) + File.separator + StringUtil.upperFirst(name) + ".java"; String outputPath = root + File.separator + pkg_name.replace(".", File.separator) + File.separator + StringUtil.upperFirst(name) + ".java";
...@@ -74,14 +75,10 @@ public class ReverseUtil { ...@@ -74,14 +75,10 @@ public class ReverseUtil {
public static void processAllAttrs(List<String> paramyKeys, List<String> columnNames, List<String> colTypes, List<String> columnComments, StringBuffer sbuffer) { public static void processAllAttrs(List<String> paramyKeys, List<String> columnNames, List<String> colTypes, List<String> columnComments, StringBuffer sbuffer) {
for (int i = 0; i < columnNames.size(); i++) { for (int i = 0; i < columnNames.size(); i++) {
String columnName = columnNames.get(i); String columnName = columnNames.get(i);
if(StringUtil.isNotBlank(columnComments.get(i))) {
sbuffer.append("\t/**" + "\n");
sbuffer.append("\t * " + columnComments.get(i) + "\n");
sbuffer.append("\t */" + "\n");
}
if(StringUtil.contains(paramyKeys.toArray(new String[paramyKeys.size()]), columnName)) { if(StringUtil.contains(paramyKeys.toArray(new String[paramyKeys.size()]), columnName)) {
sbuffer.append("\t@Id" + "\n"); sbuffer.append("\t@Id" + "\n");
} }
sbuffer.append("\t@Column(columnDefinition=\"" + colTypes.get(i) + (StringUtil.isNotBlank(columnComments.get(i)) ? " COMMENT '" + columnComments.get(i) : "") + "'\")" + "\n");
sbuffer.append("\tprivate " + sqlType2JavaType(colTypes.get(i)) + " " + columnName + ";" + "\n\n"); sbuffer.append("\tprivate " + sqlType2JavaType(colTypes.get(i)) + " " + columnName + ";" + "\n\n");
} }
sbuffer.append("\n"); sbuffer.append("\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment