| | |
| | | import java.util.LinkedHashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.function.Function;
|
| | | import java.util.stream.Collectors;
|
| | | import java.util.zip.ZipEntry;
|
| | | import java.util.zip.ZipOutputStream;
|
| | |
| | | {
|
| | | GenTable table = genTableMapper.selectGenTableByName(tableName);
|
| | | List<GenTableColumn> tableColumns = table.getColumns();
|
| | | List<String> tableColumnNames = tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
| | | Map<String, GenTableColumn> tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity()));
|
| | |
|
| | | List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
| | | if (StringUtils.isEmpty(dbTableColumns))
|
| | |
| | | List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
| | |
|
| | | dbTableColumns.forEach(column -> {
|
| | | if (!tableColumnNames.contains(column.getColumnName()))
|
| | | GenUtils.initColumnField(column, table);
|
| | | if (tableColumnMap.containsKey(column.getColumnName()))
|
| | | {
|
| | | GenUtils.initColumnField(column, table);
|
| | | GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName());
|
| | | column.setColumnId(prevColumn.getColumnId());
|
| | | if (column.isList())
|
| | | {
|
| | | // 如果是列表,继续保留字典类型
|
| | | column.setDictType(prevColumn.getDictType());
|
| | | }
|
| | | genTableColumnMapper.updateGenTableColumn(column);
|
| | | }
|
| | | else
|
| | | {
|
| | | genTableColumnMapper.insertGenTableColumn(column);
|
| | | }
|
| | | });
|
| | |
| | | zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table)));
|
| | | IOUtils.write(sw.toString(), zip, Constants.UTF8);
|
| | | IOUtils.closeQuietly(sw);
|
| | | zip.flush();
|
| | | zip.flush();
|
| | | zip.closeEntry();
|
| | | }
|
| | | catch (IOException e)
|
| | |
| | | String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
| | | String parentMenuId = paramsObj.getString(GenConstants.PARENT_MENU_ID);
|
| | | String parentMenuName = paramsObj.getString(GenConstants.PARENT_MENU_NAME);
|
| | | |
| | |
|
| | | genTable.setTreeCode(treeCode);
|
| | | genTable.setTreeParentCode(treeParentCode);
|
| | | genTable.setTreeName(treeName);
|