Browse Source

修改模型不准返回状态码

pull/7/head
fanshuai 2 years ago
parent
commit
838215dce2
2 changed files with 5 additions and 5 deletions
  1. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelsService.java
  2. +4
    -4
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java

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

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


String removeById(Integer id); String removeById(Integer id);


ResponseEntity<InputStreamResource> downloadModels(Integer id);
ResponseEntity<InputStreamResource> downloadModels(Integer id) throws Exception;








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

@@ -176,15 +176,15 @@ public class ModelsServiceImpl implements ModelsService {
*/ */


@Override @Override
public ResponseEntity<InputStreamResource> downloadModels(Integer id) {
public ResponseEntity<InputStreamResource> downloadModels(Integer id) throws Exception {
ModelsVersion modelsVersion = this.modelsVersionDao.queryById(id); ModelsVersion modelsVersion = this.modelsVersionDao.queryById(id);
if (modelsVersion == null) { if (modelsVersion == null) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
throw new Exception("未找到该版本模型");
} }
// 从数据库中获取存储路径(即MinIO中的对象名称) // 从数据库中获取存储路径(即MinIO中的对象名称)
String objectName = modelsVersion.getUrl(); String objectName = modelsVersion.getUrl();
if(objectName == null || objectName.isEmpty() ){ if(objectName == null || objectName.isEmpty() ){
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
throw new Exception("未找到该版本模型文件");
} }


try { try {
@@ -200,7 +200,7 @@ public class ModelsServiceImpl implements ModelsService {
.body(resource); .body(resource);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
throw new Exception("下载模型文件错误");
} }
} }




Loading…
Cancel
Save