Просмотр исходного кода

Merge branch 'Develop' into 'Test'

Develop



See merge request !1230

menduo 5 лет назад
Родитель
Сommit
0929a9bfc3

+ 9 - 4
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/ctrl/CaseImportAndExportController.java

@@ -33,8 +33,8 @@ public class CaseImportAndExportController {
     @Autowired
     private MongoAPIService mongoAPIService;
 
-    //private String rootPath = "/var/www/download/";
-    private String rootPath = "H://";
+    private String rootPath = "/var/www/download";
+    //private String rootPath = "H://download/";
 
     private String rootZipFileName = "resource.zip";
 
@@ -71,7 +71,11 @@ public class CaseImportAndExportController {
     @RequestMapping(value = UrlConstants.API + "caseImport", method = RequestMethod.POST)
     public Map<String, Object> caseImport(MultipartHttpServletRequest request) {
         //TODO 解压压缩包到指定位置
-        String filePath = rootPath + "temp/";
+        String filePath = rootPath + System.currentTimeMillis()+ "_temp/";
+        File dir = new File(filePath);
+        if (!dir.exists()) {
+            dir.mkdirs();
+        }
         Map<String, Object> res = new HashMap<>();
         try {
             //获取上传的文件
@@ -89,6 +93,7 @@ public class CaseImportAndExportController {
                     return res;
                 }
                 FileUtils.unZipMultiFile(filePath + fileNames.get(0), rootPath);
+                FileUtils.unZipMultiFile(filePath + fileNames.get(0), filePath);
                 /*
                 if (!fileNames.get(0).equals(fileName)) {
                     //TODO 返回错误信息
@@ -106,7 +111,7 @@ public class CaseImportAndExportController {
             if (ownerId == null || ownerId.equals("")) {
                 ownerId = SecurityUtils.getSubject().getSession().getAttribute("userId").toString();
             }
-            Map<String, Object> tempMap = caseImportLogic.importCases(rootPath, ip, ownerId, fileName);
+            Map<String, Object> tempMap = caseImportLogic.importCases(filePath, ip, ownerId, fileName);
             if (!tempMap.get("code").equals(0)) {
                 res.put("code", 4);
                 res.put("message", tempMap.get("message"));

+ 2 - 2
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/logic/impl/CaseExportLogicImpl.java

@@ -22,7 +22,7 @@ public class CaseExportLogicImpl implements CaseExportLogic, Serializable {
 
     @Override
     public Map<String, Object> exportCases(List<Long> caseIds, String filePath,String workSpace, String zipFileName, String fileName) {
-        String ossFilePath = "download/";
+        String ossFilePath = "";
         Map<String, Object> fileMap = new HashMap<>();
         //String tempFilePath = workSpace + "temp/";
         String zipFilePath = filePath + zipFileName;
@@ -69,7 +69,7 @@ public class CaseExportLogicImpl implements CaseExportLogic, Serializable {
         }
         //打成压缩包
         FileToZip fileToZip = new FileToZip(zipFilePath);
-        fileToZip.compress(workSpace + ossFilePath, workSpace + fileName);
+        fileToZip.compress(workSpace + "app/",workSpace + "target/", workSpace + fileName);
         //FileDelete.delFile(tempFilePath);
         res.put("code", 0);
         res.put("message", "导出成功");