| | |
| | | public String username; |
| | | public String password; |
| | | public String table; |
| | | public String tableName; |
| | | public String packagePath; |
| | | public boolean controller = true; |
| | | public boolean service = true; |
| | |
| | | private String systemPackage; |
| | | private String itemName; |
| | | private String tableColumns; |
| | | private String formEditColumns; |
| | | |
| | | public void build() throws Exception { |
| | | init(); |
| | |
| | | } |
| | | itemName = packagePathSplit[packagePathSplit.length - 1]; |
| | | tableColumns = createTableColumns(); |
| | | formEditColumns = createFormEditColumns(); |
| | | } |
| | | |
| | | private String readFile(String template){ |
| | |
| | | if(!writerFile.exists()){ |
| | | content=content. |
| | | replaceAll("@\\{TABLENAME}", table) |
| | | .replaceAll("@\\{TABLEDESC}", tableName) |
| | | .replaceAll("@\\{ENTITYIMPORT}", entityImport) |
| | | .replaceAll("@\\{ENTITYCONTENT}", entityContent) |
| | | .replaceAll("@\\{ENTITYNAME}", fullEntityName) |
| | |
| | | .replaceAll("@\\{UPCASEMARJORCOLUMN}", GeneratorUtils.firstCharConvert(primaryKeyColumn, false)) |
| | | .replaceAll("@\\{SYSTEMPACKAGE}",systemPackage) |
| | | .replaceAll("@\\{TABLECOLUMNS}", tableColumns) |
| | | .replaceAll("@\\{FORMEDITCOLUMNS}", formEditColumns) |
| | | ; |
| | | writerFile.createNewFile(); |
| | | BufferedWriter writer=new BufferedWriter(new FileWriter(writerFile)); |
| | |
| | | private void gainDbInfo() throws Exception { |
| | | Connection conn; |
| | | if (null == this.sqlOsType) { |
| | | throw new RuntimeException("请指定数据库类型!"); |
| | | throw new RuntimeException("请选择sqlOsType!"); |
| | | } |
| | | if (null == this.table) { |
| | | throw new RuntimeException("请输入table!"); |
| | | } |
| | | if (null == this.tableName) { |
| | | throw new RuntimeException("请输入tableName!"); |
| | | } |
| | | switch (this.sqlOsType) { |
| | | case MYSQL: |
| | |
| | | /************************************** Edit动态字段 ********************************************/ |
| | | /**********************************************************************************************/ |
| | | |
| | | private String createFormEditColumns() { |
| | | StringBuilder sb = new StringBuilder(); |
| | | int times = 0; |
| | | for (Column column : columns) { |
| | | if (column.isPrimaryKey() |
| | | || column.getHumpName().equals("deleted") |
| | | || column.getHumpName().equals("hostId") |
| | | ) { |
| | | continue; |
| | | } |
| | | |
| | | if (times%2 == 0) { |
| | | |
| | | } |
| | | |
| | | times++; |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |
| | | |
| | | |