| @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import javax.annotation.Resource; | |||
| import java.util.Map; | |||
| /** | |||
| * (Dataset)表控制层 | |||
| @@ -123,7 +124,7 @@ public class DatasetController { | |||
| @ApiImplicitParam(name = "file", value = "要上传的数据集文件", required = true, dataType = "file", paramType = "form"), | |||
| @ApiImplicitParam(name = "dataset_version_id", value = "数据集版本表id", required = true, dataType = "integer", paramType = "path") | |||
| }) | |||
| public ResponseEntity<String> uploadDataset(@RequestParam("file") MultipartFile file, | |||
| public ResponseEntity<Map> uploadDataset(@RequestParam("file") MultipartFile file, | |||
| @PathVariable("dataset_version_id") Integer dataset_version_id) throws Exception { | |||
| return ResponseEntity.ok(this.datasetService.uploadDataset(file, dataset_version_id)); | |||
| } | |||
| @@ -134,7 +135,7 @@ public class DatasetController { | |||
| */ | |||
| @PostMapping("/upload_pipeline") | |||
| @ApiOperation(value = "从流水线上传数据集", notes = "并将信息存入数据库。") | |||
| public ResponseEntity<String> uploadDatasetPipeline(@RequestBody(required =false) DatasetVersion datasetVersion) throws Exception { | |||
| public ResponseEntity<Map> uploadDatasetPipeline(@RequestBody(required =false) DatasetVersion datasetVersion) throws Exception { | |||
| return ResponseEntity.ok(this.datasetService.uploadDatasetPipeline(datasetVersion)); | |||
| } | |||
| } | |||
| @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import javax.annotation.Resource; | |||
| import java.util.Map; | |||
| /** | |||
| * (Models)表控制层 | |||
| @@ -107,7 +108,7 @@ public class ModelsController { | |||
| @PostMapping("/upload/{models_version_id}") | |||
| @ApiOperation(value = "上传模型", notes = "根据模型版本表id上传模型文件,并将信息存入数据库。") | |||
| public ResponseEntity<String> uploadModels(@RequestParam("file") MultipartFile file, @PathVariable("models_version_id") Integer models_version_id) throws Exception { | |||
| public ResponseEntity<Map> uploadModels(@RequestParam("file") MultipartFile file, @PathVariable("models_version_id") Integer models_version_id) throws Exception { | |||
| return ResponseEntity.ok(this.modelsService.uploadModels(file,models_version_id)); | |||
| } | |||
| @@ -118,7 +119,7 @@ public class ModelsController { | |||
| */ | |||
| @PostMapping("/upload_pipeline") | |||
| @ApiOperation("从流水线上传模型,并将信息存入数据库") | |||
| public ResponseEntity<String> uploadModelsPipeline(@RequestBody(required =false) ModelsVersion modelsVersion) throws Exception { | |||
| public ResponseEntity<Map> uploadModelsPipeline(@RequestBody(required =false) ModelsVersion modelsVersion) throws Exception { | |||
| return ResponseEntity.ok(this.modelsService.uploadModelsPipeline(modelsVersion)); | |||
| } | |||
| @@ -8,6 +8,8 @@ import org.springframework.data.domain.PageRequest; | |||
| import org.springframework.http.ResponseEntity; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import java.util.Map; | |||
| /** | |||
| * (Dataset)表服务接口 | |||
| * | |||
| @@ -67,7 +69,7 @@ public interface DatasetService { | |||
| ResponseEntity<InputStreamResource> downloadDataset(Integer id); | |||
| String uploadDataset(MultipartFile file, Integer id) throws Exception; | |||
| Map uploadDataset(MultipartFile file, Integer id) throws Exception; | |||
| String uploadDatasetPipeline(DatasetVersion datasetVersion) throws Exception; | |||
| Map uploadDatasetPipeline(DatasetVersion datasetVersion) throws Exception; | |||
| } | |||
| @@ -10,6 +10,8 @@ import org.springframework.data.domain.PageRequest; | |||
| import org.springframework.http.ResponseEntity; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import java.util.Map; | |||
| /** | |||
| * (Models)表服务接口 | |||
| * | |||
| @@ -64,7 +66,7 @@ public interface ModelsService { | |||
| ResponseEntity<InputStreamResource> downloadModels(Integer id); | |||
| String uploadModels(MultipartFile file, Integer id) throws Exception; | |||
| Map uploadModels(MultipartFile file, Integer id) throws Exception; | |||
| String uploadModelsPipeline(ModelsVersion modelsVersion) throws Exception; | |||
| Map uploadModelsPipeline(ModelsVersion modelsVersion) throws Exception; | |||
| } | |||
| @@ -33,7 +33,9 @@ import java.io.ByteArrayOutputStream; | |||
| import java.io.InputStream; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| * (Dataset)表服务实现类 | |||
| @@ -215,7 +217,7 @@ public class DatasetServiceImpl implements DatasetService { | |||
| * @return 是否成功 | |||
| */ | |||
| @Override | |||
| public String uploadDataset(MultipartFile file, Integer id) throws Exception { | |||
| public Map uploadDataset(MultipartFile file, Integer id) throws Exception { | |||
| if (file.isEmpty()) { | |||
| throw new Exception("文件为空,无法上传"); | |||
| } | |||
| @@ -263,14 +265,16 @@ public class DatasetServiceImpl implements DatasetService { | |||
| datasetVersionToUse.setFileName(fileName); | |||
| datasetVersionToUse.setFileSize(String.valueOf(sizeInKB)); | |||
| datasetVersionDao.update(datasetVersionToUse); | |||
| return "数据集成功上传到: " + objectName; | |||
| } catch (Exception e) { | |||
| throw new Exception("上传到数据集失败: " + e.getMessage(), e); | |||
| } | |||
| Map<String, String> result = new HashMap<String, String>(); | |||
| result.put("url",objectName); | |||
| return result; | |||
| } | |||
| @Override | |||
| public String uploadDatasetPipeline(DatasetVersion datasetVersion) throws Exception { | |||
| public Map uploadDatasetPipeline(DatasetVersion datasetVersion) throws Exception { | |||
| String username = SecurityUtils.getLoginUser().getUsername(); | |||
| // 检查是否存在 | |||
| Dataset dataset = this.queryById(datasetVersion.getDatasetId()); | |||
| @@ -301,7 +305,9 @@ public class DatasetServiceImpl implements DatasetService { | |||
| version.setUrl(url); | |||
| datasetVersionService.update(version); | |||
| } | |||
| return "数据集成功上传到: " + url; | |||
| Map<String, String> result = new HashMap<String, String>(); | |||
| result.put("url",url); | |||
| return result; | |||
| } | |||
| @@ -33,6 +33,8 @@ import java.io.ByteArrayOutputStream; | |||
| import java.io.InputStream; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| /** | |||
| * (Models)表服务实现类 | |||
| @@ -206,7 +208,7 @@ public class ModelsServiceImpl implements ModelsService { | |||
| * @return 是否成功 | |||
| */ | |||
| @Override | |||
| public String uploadModels(MultipartFile file, Integer id) throws Exception { | |||
| public Map uploadModels(MultipartFile file, Integer id) throws Exception { | |||
| if (file.isEmpty()) { | |||
| throw new Exception("文件为空,无法上传"); | |||
| } | |||
| @@ -254,15 +256,17 @@ public class ModelsServiceImpl implements ModelsService { | |||
| modelsVersionToUse.setFileName(fileName); | |||
| modelsVersionToUse.setFileSize(String.valueOf(sizeInKB)); | |||
| modelsVersionDao.update(modelsVersionToUse); | |||
| return "模型成功上传到: " + objectName; | |||
| } catch (Exception e) { | |||
| throw new Exception("上传到模型失败: " + e.getMessage(), e); | |||
| } | |||
| Map<String, String> result = new HashMap<String, String>(); | |||
| result.put("url",objectName); | |||
| return result; | |||
| } | |||
| @Override | |||
| public String uploadModelsPipeline(ModelsVersion modelsVersion) throws Exception { | |||
| public Map uploadModelsPipeline(ModelsVersion modelsVersion) throws Exception { | |||
| String username = SecurityUtils.getLoginUser().getUsername(); | |||
| // 检查是否存在 | |||
| Models models = this.queryById(modelsVersion.getModelsId()); | |||
| @@ -293,7 +297,9 @@ public class ModelsServiceImpl implements ModelsService { | |||
| version.setUrl(url); | |||
| modelsVersionService.update(version); | |||
| } | |||
| return "模型成功上传到: " + url; | |||
| Map<String, String> result = new HashMap<String, String>(); | |||
| result.put("url",url); | |||
| return result; | |||
| } | |||
| private String extractFileName(String urlStr) { | |||