diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/NewDatasetFromGitController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/NewDatasetFromGitController.java index f572dd45..3a73d5c3 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/NewDatasetFromGitController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/NewDatasetFromGitController.java @@ -62,6 +62,12 @@ public class NewDatasetFromGitController { } + @PutMapping("/updateVersionDesc") + @ApiOperation("修改版本描述") + public AjaxResult updateVersionDesc(@RequestBody NewDatasetVo datasetVo) throws Exception { + return AjaxResult.success(this.newDatasetService.updateVersionDesc(datasetVo)); + } + /** * 新增数据集与版本新 * @@ -72,7 +78,6 @@ public class NewDatasetFromGitController { @ApiOperation("从labelsudio添加版本") public AjaxResult addVersionFromLabelStudio(@RequestBody LabelDatasetVersionVo datasetVo) throws Exception { return AjaxResult.success(this.newDatasetService.newCreateVersionFromLabelStudio(datasetVo)); - } @GetMapping("/queryDatasets") diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/NewDatasetService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/NewDatasetService.java index 5d280066..d4b86d6b 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/NewDatasetService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/NewDatasetService.java @@ -21,6 +21,8 @@ public interface NewDatasetService { String newCreateVersion(NewDatasetVo datasetVo) throws Exception; + String updateVersionDesc(NewDatasetVo datasetVo) throws Exception; + List> uploadDatasetlocal(MultipartFile[] files, String uuid) throws Exception; ResponseEntity downloadDatasetlocal(String filePath) throws Exception; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java index 6f3a509b..8d5a4244 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java @@ -268,7 +268,6 @@ public class NewDatasetServiceImpl implements NewDatasetService { datasetVo.setRelativePaths(relatePath + "/dataset"); datasetVo = addDatasetSourceToDataVo(datasetVo); - System.out.println(datasetVo); YamlUtils.generateYamlFile(JsonUtils.objectToMap(datasetVo), localPath, "dataset"); //dvc数据跟踪 @@ -294,6 +293,21 @@ public class NewDatasetServiceImpl implements NewDatasetService { return "新增数据集成功"; } + @Override + public String updateVersionDesc(NewDatasetVo datasetVo) throws Exception { + LoginUser loginUser = SecurityUtils.getLoginUser(); + String ci4sUsername = Boolean.TRUE.equals(datasetVo.getIsPublic()) ? Constant.Item_Public : loginUser.getUsername(); + String gitLinkUsername = loginUser.getSysUser().getUserName(); + String gitLinkPassword = decrypt(loginUser.getSysUser().getOriginPassword()); + String repositoryName = datasetVo.getIdentifier(); + String branchName = datasetVo.getVersion(); + String relatePath = ci4sUsername + "/datasets/" + datasetVo.getId() + "/" + repositoryName + "/" + branchName; + String localPath = localPathlocal + relatePath; + YamlUtils.generateYamlFile(JsonUtils.objectToMap(datasetVo), localPath, "dataset"); + dvcUtils.pushNewBranchToRemote(localPath, gitLinkUsername, gitLinkPassword, branchName); + return "更新数据集版本成功"; + } + @Override public Page newPersonalQueryByPage(Dataset dataset, PageRequest pageRequest) throws Exception { diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/YamlUtils.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/YamlUtils.java index 142406cf..0e003742 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/YamlUtils.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/YamlUtils.java @@ -54,50 +54,6 @@ public class YamlUtils { } } - -// public static void generateYamlFile1(Object data, String path, String fileName) { -// try { -// YAMLFactory yamlFactory = new YAMLFactory(); -// yamlFactory.enable(YAMLGenerator.Feature.MINIMIZE_QUOTES); -// yamlFactory.disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER); -//// -// ObjectMapper objectMapper = new ObjectMapper(yamlFactory); -//// ObjectMapper objectMapper = new ObjectMapper(); -// objectMapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); -// String s = objectMapper.writeValueAsString(data); -// -// File directory = new File(path); -// if (!directory.exists()) { -// boolean isCreated = directory.mkdirs(); -// if (!isCreated) { -// throw new RuntimeException("创建路径失败: " + path); -// } -// } -// -// try { -// DumperOptions options = new DumperOptions(); -// options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); -// // 创建Yaml实例 -// Yaml yaml = new Yaml(options); -// -// String fullPath = path + "/" + fileName + ".yaml"; -// FileWriter writer = new FileWriter(fullPath); -// -// yaml.dump(s, writer); -// } catch (FileNotFoundException e) { -// e.printStackTrace(); -// -// } catch (IOException e) { -// throw new RuntimeException(e); -// } -// -// -// } catch (JsonProcessingException e) { -// throw new RuntimeException(e); -// } -// } - - /** * 读取YAML文件并将其内容转换为Map *