From f76dc346e26e15c528c6465d2df19604981be592 Mon Sep 17 00:00:00 2001 From: chenzhihang <709011834@qq.com> Date: Fri, 20 Jun 2025 15:49:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BF=AE=E6=94=B9=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E7=89=88=E6=9C=AC=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataset/NewDatasetFromGitController.java | 7 ++- .../model/NewModelFromGitController.java | 6 +++ .../ruoyi/platform/service/ModelsService.java | 2 + .../platform/service/NewDatasetService.java | 2 + .../service/impl/ModelsServiceImpl.java | 17 +++++++ .../service/impl/NewDatasetServiceImpl.java | 15 ++++++ .../com/ruoyi/platform/utils/YamlUtils.java | 46 ------------------- 7 files changed, 48 insertions(+), 47 deletions(-) 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/controller/model/NewModelFromGitController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/NewModelFromGitController.java index 4bb8f03b..0d6dcbde 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/NewModelFromGitController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/NewModelFromGitController.java @@ -38,6 +38,12 @@ public class NewModelFromGitController extends BaseController { return AjaxResult.success(this.modelsService.newCreateVersion(modelsVo)); } + @PutMapping("/updateVersionDesc") + @ApiOperation("修改版本描述") + public AjaxResult updateVersionDesc(@RequestBody ModelsVo modelsVo) throws Exception { + return AjaxResult.success(this.modelsService.updateVersionDesc(modelsVo)); + } + @CrossOrigin(origins = "*", allowedHeaders = "*") @PostMapping("/upload") @ApiOperation(value = "上传模型", notes = "根据模型id上传模型文件,并将信息存入数据库。") 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 d8b47626..034f0b19 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 @@ -93,6 +93,8 @@ public interface ModelsService { String newCreateVersion(ModelsVo modelsVo) throws Exception; + String updateVersionDesc(ModelsVo modelsVo) throws Exception; + List> uploadModelLocal(MultipartFile[] files, String uuid) throws Exception; ResponseEntity downloadAllModelFilesNew(String name, String identifier, Integer id, String version, Boolean isPublic) throws IOException, Exception; 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/ModelsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java index 8f3181df..e937c377 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 @@ -868,6 +868,23 @@ public class ModelsServiceImpl implements ModelsService { return "新增模型版本成功"; } + @Override + public String updateVersionDesc(ModelsVo modelsVo) throws Exception { + LoginUser loginUser = SecurityUtils.getLoginUser(); + String ci4sUsername = Boolean.TRUE.equals(modelsVo.getIsPublic()) ? Constant.Item_Public : loginUser.getUsername(); + String gitLinkUsername = loginUser.getSysUser().getUserName(); + String gitLinkPassword = decrypt(loginUser.getSysUser().getOriginPassword()); + String repositoryName = modelsVo.getIdentifier(); + String branchName = modelsVo.getVersion(); + String relatePath = ci4sUsername + "/model/" + modelsVo.getId() + "/" + repositoryName + "/" + branchName; + String rootPath = localPath + relatePath; + String metaPath = rootPath + "/metadata"; + Map metaMap = JSON.parseObject(JSON.toJSONString(modelsVo), Map.class); + YamlUtils.generateYamlFile(metaMap, metaPath, "metadata"); + dvcUtils.pushNewBranchToRemote(rootPath, gitLinkUsername, gitLinkPassword, branchName); + return "更新模型版本成功"; + } + @Override public List> uploadModelLocal(MultipartFile[] files, String uuid) 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 d532c838..6eb89dcb 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 @@ -319,6 +319,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..0d88c412 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 @@ -46,58 +46,12 @@ public class YamlUtils { String fullPath = path + "/" + fileName + ".yaml"; try (FileWriter writer = new FileWriter(fullPath)) { - String dump = yaml.dump(data); - yaml.dump(data, writer); } catch (IOException e) { e.printStackTrace(); } } - -// 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 *