Commit ad1b4dbd by Mark

修复生成代码报异常

parent 73f2c5fc
...@@ -46,23 +46,19 @@ public class SysGeneratorController { ...@@ -46,23 +46,19 @@ public class SysGeneratorController {
return R.ok().put("page", pageUtil); return R.ok().put("page", pageUtil);
} }
/** /**
* 生成代码 * 生成代码
*/ */
@RequestMapping("/code") @RequestMapping("/code")
public void code(HttpServletRequest request, HttpServletResponse response) throws IOException{ public void code(String tables, HttpServletResponse response) throws IOException{
String[] tableNames = new String[]{}; byte[] data = sysGeneratorService.generatorCode(tables.split(","));
String tables = request.getParameter("tables");
tableNames = JSON.parseArray(tables).toArray(tableNames); response.reset();
response.setHeader("Content-Disposition", "attachment; filename=\"renren.zip\"");
byte[] data = sysGeneratorService.generatorCode(tableNames); response.addHeader("Content-Length", "" + data.length);
response.setContentType("application/octet-stream; charset=UTF-8");
response.reset();
response.setHeader("Content-Disposition", "attachment; filename=\"renren.zip\""); IOUtils.write(data, response.getOutputStream());
response.addHeader("Content-Length", "" + data.length);
response.setContentType("application/octet-stream; charset=UTF-8");
IOUtils.write(data, response.getOutputStream());
} }
} }
...@@ -50,11 +50,11 @@ var vm = new Vue({ ...@@ -50,11 +50,11 @@ var vm = new Vue({
}).trigger("reloadGrid"); }).trigger("reloadGrid");
}, },
generator: function() { generator: function() {
var tableNames = getSelectedRows(); var tableNames = getSelectedRows();
if(tableNames == null){ if(tableNames == null){
return ; return ;
} }
location.href = "sys/generator/code?tables=" + JSON.stringify(tableNames); location.href = "sys/generator/code?tables=" + tableNames.join();
} }
} }
}); });
......
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