!90 抽取重复代码到一个方法

Merge pull request !90 from lywjlong/master
pull/90/MERGE
若依 6 years ago committed by Gitee
commit 661db11765

@ -60,12 +60,7 @@ public class GenController extends BaseController
public void genCode(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException public void genCode(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException
{ {
byte[] data = genService.generatorCode(tableName); byte[] data = genService.generatorCode(tableName);
response.reset(); genCode(response, data);
response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\"");
response.addHeader("Content-Length", "" + data.length);
response.setContentType("application/octet-stream; charset=UTF-8");
IOUtils.write(data, response.getOutputStream());
} }
/** /**
@ -79,6 +74,16 @@ public class GenController extends BaseController
{ {
String[] tableNames = Convert.toStrArray(tables); String[] tableNames = Convert.toStrArray(tables);
byte[] data = genService.generatorCode(tableNames); byte[] data = genService.generatorCode(tableNames);
genCode(response, data);
}
/**
* zip
* @param response
* @param data
* @throws IOException
*/
private void genCode(HttpServletResponse response, byte[] data) throws IOException {
response.reset(); response.reset();
response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\""); response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\"");
response.addHeader("Content-Length", "" + data.length); response.addHeader("Content-Length", "" + data.length);

Loading…
Cancel
Save