| | |
| | | /** |
| | | * 导出模型zip压缩包 |
| | | * |
| | | * @param modelId 模型id |
| | | * @param modelIds 模型id |
| | | * @param response 相应 |
| | | */ |
| | | @Override |
| | | public void exportZip(String modelId, HttpServletResponse response) { |
| | | public void exportZip(List<String> modelIds, HttpServletResponse response) { |
| | | ZipOutputStream zos = null; |
| | | try { |
| | | zos = ZipUtil.getZipOutputStream(response.getOutputStream(), StandardCharsets.UTF_8); |
| | | // 压缩包文件名 |
| | | String zipName = "模型不存在"; |
| | | // 查询模型基本信息 |
| | | for (String modelId : modelIds) { |
| | | Model model = repositoryService.getModel(modelId); |
| | | byte[] xmlBytes = repositoryService.getModelEditorSource(modelId); |
| | | if (ObjectUtil.isNotNull(model)) { |
| | |
| | | zos.write(xmlBytes); |
| | | } |
| | | } |
| | | } |
| | | response.setHeader("Content-Disposition", |
| | | "attachment; filename=" + URLEncoder.encode(zipName, StandardCharsets.UTF_8) + ".zip"); |
| | | // 刷出响应流 |