diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelsService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelsService.java index e720f45c..7d79ea71 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelsService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelsService.java @@ -66,7 +66,7 @@ public interface ModelsService { String removeById(Integer id); - ResponseEntity downloadModels(Integer id); + ResponseEntity downloadModels(Integer id) throws Exception; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java index c56252cf..bb8a7126 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java @@ -176,15 +176,15 @@ public class ModelsServiceImpl implements ModelsService { */ @Override - public ResponseEntity downloadModels(Integer id) { + public ResponseEntity downloadModels(Integer id) throws Exception { ModelsVersion modelsVersion = this.modelsVersionDao.queryById(id); if (modelsVersion == null) { - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); + throw new Exception("未找到该版本模型"); } // 从数据库中获取存储路径(即MinIO中的对象名称) String objectName = modelsVersion.getUrl(); if(objectName == null || objectName.isEmpty() ){ - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); + throw new Exception("未找到该版本模型文件"); } try { @@ -200,7 +200,7 @@ public class ModelsServiceImpl implements ModelsService { .body(resource); } catch (Exception e) { e.printStackTrace(); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null); + throw new Exception("下载模型文件错误"); } }