mirror of https://gitee.com/y_project/RuoYi.git
抽取重复代码到一个方法并修改方法为private级别
parent
ba55256630
commit
74834fd24e
|
@ -60,12 +60,7 @@ public class GenServiceImpl implements IGenService
|
||||||
{
|
{
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
||||||
// 查询表信息
|
generatorCode(tableName, zip);
|
||||||
TableInfo table = genMapper.selectTableByName(tableName);
|
|
||||||
// 查询列信息
|
|
||||||
List<ColumnInfo> columns = genMapper.selectTableColumnsByName(tableName);
|
|
||||||
// 生成代码
|
|
||||||
generatorCode(table, columns, zip);
|
|
||||||
IOUtils.closeQuietly(zip);
|
IOUtils.closeQuietly(zip);
|
||||||
return outputStream.toByteArray();
|
return outputStream.toByteArray();
|
||||||
}
|
}
|
||||||
|
@ -83,22 +78,22 @@ public class GenServiceImpl implements IGenService
|
||||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
||||||
for (String tableName : tableNames)
|
for (String tableName : tableNames)
|
||||||
{
|
{
|
||||||
// 查询表信息
|
generatorCode(tableName, zip);
|
||||||
TableInfo table = genMapper.selectTableByName(tableName);
|
|
||||||
// 查询列信息
|
|
||||||
List<ColumnInfo> columns = genMapper.selectTableColumnsByName(tableName);
|
|
||||||
// 生成代码
|
|
||||||
generatorCode(table, columns, zip);
|
|
||||||
}
|
}
|
||||||
IOUtils.closeQuietly(zip);
|
IOUtils.closeQuietly(zip);
|
||||||
return outputStream.toByteArray();
|
return outputStream.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成代码
|
* 查询表信息并生成代码
|
||||||
*/
|
*/
|
||||||
public void generatorCode(TableInfo table, List<ColumnInfo> columns, ZipOutputStream zip)
|
private void generatorCode(String tableName, ZipOutputStream zip)
|
||||||
{
|
{
|
||||||
|
// 查询表信息
|
||||||
|
TableInfo table = genMapper.selectTableByName(tableName);
|
||||||
|
// 查询列信息
|
||||||
|
List<ColumnInfo> columns = genMapper.selectTableColumnsByName(tableName);
|
||||||
|
|
||||||
// 表名转换成Java属性名
|
// 表名转换成Java属性名
|
||||||
String className = GenUtils.tableToJava(table.getTableName());
|
String className = GenUtils.tableToJava(table.getTableName());
|
||||||
table.setClassName(className);
|
table.setClassName(className);
|
||||||
|
|
Loading…
Reference in New Issue