代码下载改动
This commit is contained in:
parent
290036d38c
commit
e9e8ae6abe
|
|
@ -74,3 +74,10 @@ export function synchDb(tableName) {
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
//下载接口
|
||||||
|
export function downloadCode(tableNames){
|
||||||
|
return request({
|
||||||
|
url:'/tool/gen/batchGenCode?tables=' + tableNames,
|
||||||
|
method:'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen";
|
import { listTable, previewTable, delTable, genCode, synchDb, downloadCode } from "@/api/tool/gen";
|
||||||
import importTable from "./importTable";
|
import importTable from "./importTable";
|
||||||
import { downLoadZip } from "@/utils/zipdownload";
|
import { downLoadZip } from "@/utils/zipdownload";
|
||||||
import hljs from "highlight.js/lib/highlight";
|
import hljs from "highlight.js/lib/highlight";
|
||||||
|
|
@ -269,6 +269,10 @@ export default {
|
||||||
this.msgSuccess("成功生成到自定义路径:" + row.genPath);
|
this.msgSuccess("成功生成到自定义路径:" + row.genPath);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
// downloadCode(tableNames).then(res =>{
|
||||||
|
// this.download(res.msg);
|
||||||
|
// })
|
||||||
|
// // todo
|
||||||
downLoadZip("/tool/gen/batchGenCode?tables=" + tableNames, "hchyun");
|
downLoadZip("/tool/gen/batchGenCode?tables=" + tableNames, "hchyun");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
|
||||||
os.write(b, 0, length);
|
os.write(b, 0, length);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
System.out.println(e);
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
if (os != null) {
|
if (os != null) {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,13 @@ public class Config {
|
||||||
private static String profile;
|
private static String profile;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setProfile(String profile){
|
||||||
|
Config.profile = profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String getProfile() {
|
public static String getProfile() {
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import java.util.zip.ZipOutputStream;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.hchyun.generator.aop.Log;
|
import com.hchyun.generator.aop.Log;
|
||||||
|
import com.hchyun.generator.config.Config;
|
||||||
import com.hchyun.generator.enums.GenBusinessType;
|
import com.hchyun.generator.enums.GenBusinessType;
|
||||||
import com.hchyun.generator.utils.GenBaseController;
|
import com.hchyun.generator.utils.GenBaseController;
|
||||||
import com.hchyun.generator.utils.GenReturnConstants;
|
import com.hchyun.generator.utils.GenReturnConstants;
|
||||||
|
|
@ -207,22 +208,29 @@ public class GenController extends GenBaseController {
|
||||||
String[] tableNames = Convert.toStrArray(tables);
|
String[] tableNames = Convert.toStrArray(tables);
|
||||||
byte[] data = genTableService.downloadCode(tableNames);
|
byte[] data = genTableService.downloadCode(tableNames);
|
||||||
genCode(response, data);
|
genCode(response, data);
|
||||||
compress(data);
|
// if (compress(data)){
|
||||||
|
// return AjaxResult.success("hchyun.zip");
|
||||||
|
// }else {
|
||||||
|
// return AjaxResult.error();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将bytes流写入到本地
|
* 将bytes流写入到本地
|
||||||
* @param bytes
|
* @param bytes
|
||||||
*/
|
*/
|
||||||
public static void compress(byte[] bytes) {
|
public boolean compress(byte[] bytes) {
|
||||||
try {
|
try {
|
||||||
FileOutputStream fileOutputStream = new FileOutputStream("F:\\Work\\表白\\huhyun.zip");
|
String dir = Config.getProfile()+"/hchyun.zip";
|
||||||
|
FileOutputStream fileOutputStream = new FileOutputStream(dir);
|
||||||
fileOutputStream.write(bytes);
|
fileOutputStream.write(bytes);
|
||||||
fileOutputStream.flush();
|
fileOutputStream.flush();
|
||||||
fileOutputStream.close();
|
fileOutputStream.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue