Commit 703129b9 authored by 赵啸非's avatar 赵啸非

修改部分生成代码逻辑

parent 6fac8380
......@@ -98,7 +98,7 @@
<el-col :span="12">
<el-form-item prop="isShowControl">
<span slot="label"
>是否request Mapping
>request Mapping方式
<el-tooltip
content="是否显示的生成Controller Mapping"
placement="top"
......@@ -108,9 +108,9 @@
</span>
<el-select v-model="info.isShowControl">
<el-option label="RequestBody" value="2" />
<el-option label="RequestForm" value="1" />
<el-option label="RequestFormTwo" value="0" />
<el-option label="RequestJsonBody" value="2" />
<el-option label="RequestPOSTMapping" value="1" />
<el-option label="RequestForm" value="0" />
</el-select>
</el-form-item>
......
......@@ -493,7 +493,7 @@ public class GentableEntity extends GentableEntityExt{
this.feignAppName = "";
this.genApi = null;
this.isGenExport = null;
this.isShowControl = null;
this.isShowControl = 2;
this.genPath = "/";
this.options = null;
this.remark = null;
......
......@@ -104,7 +104,7 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
GenUtils.initTable(table, operName);
table.setGenType(0);
table.setIsGenExport(0);
table.setIsShowControl(0);
table.setIsShowControl(2);
table.setGenPath("/");
table.setTplCategory("crud");
table.setAppId(appId);
......@@ -210,15 +210,6 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
List<GentableEntity> tableList = new ArrayList<>();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream);
// FreeMarkerUtils.menuSql = new StringBuilder();
// FreeMarkerUtils.paramsSql = new StringBuilder();
// FreeMarkerUtils.dbSql = new StringBuilder();
// FreeMarkerUtils.apimd = new StringBuilder();
// FreeMarkerUtils.apitwomd = new StringBuilder();
// FreeMarkerUtils.apidict = new StringBuilder();
// FreeMarkerUtils.apidict.append("## 字典附录\n");
// FreeMarkerUtils.apimd.append(headStr);
// FreeMarkerUtils.apitwomd.append(headStr);
GentableEntity gentableEntity = generatorCode(tableId, genTypes, zip);
tableList.add(gentableEntity);
......@@ -230,34 +221,6 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
FreeMarkerUtils.initFreeMarker(genFreePath("api.md.ftl"));
zipTemplate("api.md.ftl","doc/api.md",data,zip);
/*if (StringUtils.isNotEmpty(FreeMarkerUtils.menuSql)) {
zip.putNextEntry(new ZipEntry("db/menu.sql"));
IOUtils.write(FreeMarkerUtils.menuSql.toString(), zip, Constant.UTF8);
}
if (StringUtils.isNotEmpty(FreeMarkerUtils.dbSql)) {
zip.putNextEntry(new ZipEntry("db/db.sql"));
IOUtils.write(FreeMarkerUtils.dbSql.toString(), zip, Constant.UTF8);
}
if (StringUtils.isNotEmpty(FreeMarkerUtils.paramsSql)) {
zip.putNextEntry(new ZipEntry("db/params.sql"));
IOUtils.write(FreeMarkerUtils.paramsSql.toString(), zip, Constant.UTF8);
}
if (StringUtils.isNotEmpty(FreeMarkerUtils.apimd)) {
zip.putNextEntry(new ZipEntry("doc/api.md"));
IOUtils.write(FreeMarkerUtils.apimd.toString(), zip, Constant.UTF8);
}
if (StringUtils.isNotEmpty(FreeMarkerUtils.apitwomd)) {
// zip.putNextEntry(new ZipEntry("doc/api-two.md"));
zip.putNextEntry(new ZipEntry("doc/api.md"));
IOUtils.write(FreeMarkerUtils.apitwomd.toString(), zip, Constant.UTF8);
}
if (StringUtils.isNotEmpty(FreeMarkerUtils.apidict)) {
zip.putNextEntry(new ZipEntry("doc/dict.md"));
IOUtils.write(FreeMarkerUtils.apidict.toString(), zip, Constant.UTF8);
}*/
IOUtils.closeQuietly(zip);
return outputStream.toByteArray();
}
......@@ -266,16 +229,6 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
@Override
public byte[] downloadCode(Long[] tableIds, String genTypes) {
List<GentableEntity> tableList = new ArrayList<>();
// FreeMarkerUtils.menuSql = new StringBuilder();
// FreeMarkerUtils.dbSql = new StringBuilder();
// FreeMarkerUtils.paramsSql = new StringBuilder();
// FreeMarkerUtils.apimd = new StringBuilder();
// FreeMarkerUtils.apitwomd = new StringBuilder();
// FreeMarkerUtils.apidict = new StringBuilder();
// FreeMarkerUtils.apidict.append("## 字典附录\n");
// FreeMarkerUtils.apimd.append(headStr);
// FreeMarkerUtils.apitwomd.append(headStr);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream);
for (Long tableId : tableIds) {
......@@ -289,84 +242,6 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
zipTemplate("db.sql.ftl","db/db.sql",data,zip);
FreeMarkerUtils.initFreeMarker(genFreePath("api.md.ftl"));
zipTemplate("api.md.ftl","doc/api.md",data,zip);
/* try {
StringWriter sw = new StringWriter();
Template template = FreeMarkerUtils.getTemplate(temp);
template.process(data, sw);
zip.putNextEntry(new ZipEntry("db/menu.sql"));
IOUtils.write(sw.toString(), zip, Constant.UTF8);
if (template.getName().equals("menu.sql.ftl")) {
FreeMarkerUtils.menuSql.append(sw.toString());
} else if (template.getName().equals("db.sql.ftl")) {
FreeMarkerUtils.dbSql.append(sw.toString());
} else if (template.getName().equals("params.sql.ftl")) {
FreeMarkerUtils.paramsSql.append(sw.toString());
} else if (template.getName().equals("api.md.ftl")) {
FreeMarkerUtils.apimd.append(sw.toString());
} else if (template.getName().equals("api-two.md.ftl")) {
FreeMarkerUtils.apitwomd.append(sw.toString());
} else if (template.getName().equals("apidict.md.ftl")) {
FreeMarkerUtils.apidict.append(sw.toString() + "\n");
} else {
zip.putNextEntry(new ZipEntry(FreeMarkerUtils.getFileName(template.getName(), gentableEntity)));
IOUtils.write(sw.toString(), zip, Constant.UTF8);
}
IOUtils.closeQuietly(sw);
zip.flush();
zip.closeEntry();
} catch (Exception e) {
log.error("渲染模板失败,表名:" + gentableEntity.getTableName(), e);
}
zip.putNextEntry(new ZipEntry("db/menu.sql"));
StringWriter sw = new StringWriter();
Template template = FreeMarkerUtils.getTemplate(temp);
template.process(data, sw);
if (StringUtils.isNotEmpty(FreeMarkerUtils.menuSql)) {
zip.putNextEntry(new ZipEntry("db/menu.sql"));
StringWriter sw = new StringWriter();
Template template = FreeMarkerUtils.getTemplate(temp);
template.process(data, sw);
IOUtils.write(FreeMarkerUtils.menuSql.toString(), zip, Constant.UTF8);
}
if (StringUtils.isNotEmpty(FreeMarkerUtils.dbSql)) {
zip.putNextEntry(new ZipEntry("db/db.sql"));
IOUtils.write(FreeMarkerUtils.dbSql.toString(), zip, Constant.UTF8);
}
if (StringUtils.isNotEmpty(FreeMarkerUtils.paramsSql)) {
zip.putNextEntry(new ZipEntry("db/params.sql"));
IOUtils.write(FreeMarkerUtils.paramsSql.toString(), zip, Constant.UTF8);
}
if (StringUtils.isNotEmpty(FreeMarkerUtils.apimd)) {
FreeMarkerUtils.apimd.append(FreeMarkerUtils.apidict);
zip.putNextEntry(new ZipEntry("doc/api.md"));
IOUtils.write(FreeMarkerUtils.apimd.toString(), zip, Constant.UTF8);
}
if (StringUtils.isNotEmpty(FreeMarkerUtils.apitwomd)) {
FreeMarkerUtils.apitwomd.append(FreeMarkerUtils.apidict);
zip.putNextEntry(new ZipEntry("doc/api-two.md"));
IOUtils.write(FreeMarkerUtils.apitwomd.toString(), zip, Constant.UTF8);
}*/
// if (StringUtils.isNotEmpty(FreeMarkerUtils.apidict)) {
// zip.putNextEntry(new ZipEntry("doc/dict.md"));
// IOUtils.write(FreeMarkerUtils.apidict.toString(), zip, Constant.UTF8);
// }
//
IOUtils.closeQuietly(zip);
return outputStream.toByteArray();
}
......@@ -459,7 +334,7 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
table.setAppId(appId);
table.setGenType(0);
table.setIsGenExport(0);
table.setIsShowControl(0);
table.setIsShowControl(2);
table.setGenPath("/");
table.setTplCategory("crud");
table.setCacheServiceType(CacheServiceTypeEnum.NORMAL_SERVICE.getValue());
......@@ -468,16 +343,7 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
GentableEntity gentableEntity = this.selectOne(new GentableQuery().tableName(table.getTableName()).appId(appId));
if (!ObjectUtils.isEmpty(gentableEntity)) {
synchDb(gentableEntity.getId(), table.getColumns());
// //删除表
// this.remove(gentableEntity.getId(), context);
// //删除列
// List<GentableColumnEntity> gentableColumnEntities = gentableColumnService.find(new GentableColumnQuery().tableId(gentableEntity.getId()));
// if (ObjectUtils.isEmpty(gentableColumnEntities)) {
// gentableEntity.setColumns(gentableColumnEntities);
// gentableColumnService.remove(gentableEntity.getColumns().stream().map(item -> item.getId()).toArray(Long[]::new), context);
// }
} else {
//保存表
this.save(table);
//保存列
......@@ -599,7 +465,12 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
if (temp.contains("web.java.ftl") || temp.contains("webForm.java.ftl")) {
continue;
}
}else{
if (temp.contains("webBody.java.ftl")) {
continue;
}
}
if (temp.equals("menu.sql.ftl")) {
continue;
}
......@@ -614,22 +485,6 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
StringWriter sw = new StringWriter();
Template template = FreeMarkerUtils.getTemplate(temp);
template.process(data, sw);
// 添加到zip
/* if (template.getName().equals("menu.sql.ftl")) {
FreeMarkerUtils.menuSql.append(sw.toString());
} else if (template.getName().equals("db.sql.ftl")) {
FreeMarkerUtils.dbSql.append(sw.toString());
} else if (template.getName().equals("params.sql.ftl")) {
FreeMarkerUtils.paramsSql.append(sw.toString());
} else if (template.getName().equals("api.md.ftl")) {
FreeMarkerUtils.apimd.append(sw.toString());
} else if (template.getName().equals("api-two.md.ftl")) {
FreeMarkerUtils.apitwomd.append(sw.toString());
} else if (template.getName().equals("apidict.md.ftl")) {
FreeMarkerUtils.apidict.append(sw.toString() + "\n");
} else {
}*/
zip.putNextEntry(new ZipEntry(FreeMarkerUtils.getFileName(template.getName(), gentableEntity)));
IOUtils.write(sw.toString(), zip, Constant.UTF8);
......
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