Browse Source

修改模型不准返回状态码

pull/7/head
fanshuai 1 year 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);

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
public ResponseEntity<InputStreamResource> downloadModels(Integer id) {
public ResponseEntity<InputStreamResource> 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("下载模型文件错误");
}
}



Loading…
Cancel
Save