Browse Source

优化文件下载

dev-DXTZYK
chenzhihang 1 year ago
parent
commit
93d9ef8c93
6 changed files with 10 additions and 14 deletions
  1. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/NewDatasetFromGitController.java
  2. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/NewModelFromGitController.java
  3. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelsService.java
  4. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/NewDatasetService.java
  5. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java
  6. +2
    -6
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java

+ 2
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/NewDatasetFromGitController.java View File

@@ -132,8 +132,8 @@ public class NewDatasetFromGitController {
*/ */
@GetMapping("/downloadAllFiles") @GetMapping("/downloadAllFiles")
@ApiOperation(value = "下载同一版本下所有数据集,并打包") @ApiOperation(value = "下载同一版本下所有数据集,并打包")
public ResponseEntity<InputStreamResource> downloadAllDatasetFiles(@RequestParam("name") String name, @RequestParam("id") Integer id, @RequestParam("version") String version) throws Exception {
return newDatasetService.downloadAllDatasetFilesNew(name, id, version);
public ResponseEntity<InputStreamResource> downloadAllDatasetFiles(@RequestParam("name") String name, @RequestParam("identifier") String identifier, @RequestParam("id") Integer id, @RequestParam("version") String version) throws Exception {
return newDatasetService.downloadAllDatasetFilesNew(name, identifier, id, version);
} }


/** /**


+ 2
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/NewModelFromGitController.java View File

@@ -50,8 +50,8 @@ public class NewModelFromGitController {


@GetMapping("/downloadAllFiles") @GetMapping("/downloadAllFiles")
@ApiOperation(value = "下载同一版本下所有模型,并打包") @ApiOperation(value = "下载同一版本下所有模型,并打包")
public ResponseEntity<InputStreamResource> downloadAllDatasetFiles(@RequestParam("name") String name, @RequestParam("id") Integer id, @RequestParam("version") String version) throws Exception {
return modelsService.downloadAllModelFilesNew(name, id, version);
public ResponseEntity<InputStreamResource> downloadAllDatasetFiles(@RequestParam("name") String name, @RequestParam("identifier") String identifier, @RequestParam("id") Integer id, @RequestParam("version") String version) throws Exception {
return modelsService.downloadAllModelFilesNew(name, identifier, id, version);
} }


@GetMapping("/downloadSingleFile") @GetMapping("/downloadSingleFile")


+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelsService.java View File

@@ -93,7 +93,7 @@ public interface ModelsService {


List<Map<String, String>> uploadModelLocal(MultipartFile[] files, String uuid) throws Exception; List<Map<String, String>> uploadModelLocal(MultipartFile[] files, String uuid) throws Exception;


ResponseEntity<InputStreamResource> downloadAllModelFilesNew(String identifier, Integer id, String version) throws IOException, Exception;
ResponseEntity<InputStreamResource> downloadAllModelFilesNew(String name, String identifier, Integer id, String version) throws IOException, Exception;


Page<ModelsVo> newPubilcQueryByPage(ModelsVo modelsVo, PageRequest pageRequest) throws Exception; Page<ModelsVo> newPubilcQueryByPage(ModelsVo modelsVo, PageRequest pageRequest) throws Exception;




+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/NewDatasetService.java View File

@@ -19,7 +19,7 @@ public interface NewDatasetService {
String newCreateVersion(NewDatasetVo datasetVo) throws Exception; String newCreateVersion(NewDatasetVo datasetVo) throws Exception;
List<Map<String, String>> uploadDatasetlocal(MultipartFile[] files, String uuid) throws Exception; List<Map<String, String>> uploadDatasetlocal(MultipartFile[] files, String uuid) throws Exception;
ResponseEntity<InputStreamResource> downloadDatasetlocal(String filePath) throws Exception; ResponseEntity<InputStreamResource> downloadDatasetlocal(String filePath) throws Exception;
ResponseEntity<InputStreamResource> downloadAllDatasetFilesNew(String name,Integer id, String version) throws IOException, Exception;
ResponseEntity<InputStreamResource> downloadAllDatasetFilesNew(String name, String identifier, Integer id, String version) throws IOException, Exception;
Page<NewDatasetVo> newPersonalQueryByPage(Dataset dataset, PageRequest pageRequest) throws Exception; Page<NewDatasetVo> newPersonalQueryByPage(Dataset dataset, PageRequest pageRequest) throws Exception;
Page<NewDatasetVo> newPubilcQueryByPage(Dataset dataset, PageRequest pageRequest) throws Exception; Page<NewDatasetVo> newPubilcQueryByPage(Dataset dataset, PageRequest pageRequest) throws Exception;




+ 2
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java View File

@@ -789,7 +789,7 @@ public class ModelsServiceImpl implements ModelsService {
} }


@Override @Override
public ResponseEntity<InputStreamResource> downloadAllModelFilesNew(String identifier, Integer id, String version) throws Exception {
public ResponseEntity<InputStreamResource> downloadAllModelFilesNew(String name, String identifier, Integer id, String version) throws Exception {
// 命令行操作 git clone 项目地址 // 命令行操作 git clone 项目地址
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
String ci4sUsername = loginUser.getUsername(); String ci4sUsername = loginUser.getUsername();
@@ -820,7 +820,7 @@ public class ModelsServiceImpl implements ModelsService {
InputStreamResource resource = new InputStreamResource(new FileInputStream(zipFile)); InputStreamResource resource = new InputStreamResource(new FileInputStream(zipFile));


return ResponseEntity.ok() return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + identifier + "_" + version + "_model.zip")
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + name + "_" + version + "_model.zip")
.contentType(MediaType.APPLICATION_OCTET_STREAM) .contentType(MediaType.APPLICATION_OCTET_STREAM)
.contentLength(zipFile.length()) .contentLength(zipFile.length())
.body(resource); .body(resource);


+ 2
- 6
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java View File

@@ -394,14 +394,10 @@ public class NewDatasetServiceImpl implements NewDatasetService {
} }


@Override @Override
public ResponseEntity<InputStreamResource> downloadAllDatasetFilesNew(String name, Integer id, String version) throws Exception {
public ResponseEntity<InputStreamResource> downloadAllDatasetFilesNew(String name, String identifier, Integer id, String version) throws Exception {
// 命令行操作 git clone 项目地址 // 命令行操作 git clone 项目地址
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
String ci4sUsername = loginUser.getUsername();
Jedis jedis = new Jedis(redisHost, redisPort);
String userReq = jedis.get(ci4sUsername + "_gitUserInfo");
Map<String, Object> userInfo = JsonUtils.jsonToMap(userReq);
String localPath = localPathlocal + loginUser.getUsername() + "/datasets/" + id + "/" + name;
String localPath = localPathlocal + loginUser.getUsername() + "/datasets/" + id + "/" + identifier;


// 打包 data 文件夹 // 打包 data 文件夹
String dataFolderPath = localPath + "/data"; String dataFolderPath = localPath + "/data";


Loading…
Cancel
Save