Browse Source

增加修改资源版本功能

dev-opt-homepage
chenzhihang 1 year ago
parent
commit
9edac46179
4 changed files with 23 additions and 46 deletions
  1. +6
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/NewDatasetFromGitController.java
  2. +2
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/NewDatasetService.java
  3. +15
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java
  4. +0
    -44
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/YamlUtils.java

+ 6
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/NewDatasetFromGitController.java View File

@@ -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添加版本") @ApiOperation("从labelsudio添加版本")
public AjaxResult addVersionFromLabelStudio(@RequestBody LabelDatasetVersionVo datasetVo) throws Exception { public AjaxResult addVersionFromLabelStudio(@RequestBody LabelDatasetVersionVo datasetVo) throws Exception {
return AjaxResult.success(this.newDatasetService.newCreateVersionFromLabelStudio(datasetVo)); return AjaxResult.success(this.newDatasetService.newCreateVersionFromLabelStudio(datasetVo));

} }


@GetMapping("/queryDatasets") @GetMapping("/queryDatasets")


+ 2
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/NewDatasetService.java View File

@@ -21,6 +21,8 @@ public interface NewDatasetService {


String newCreateVersion(NewDatasetVo datasetVo) throws Exception; String newCreateVersion(NewDatasetVo datasetVo) throws Exception;


String updateVersionDesc(NewDatasetVo datasetVo) throws Exception;

List<Map<String, String>> uploadDatasetlocal(MultipartFile[] files, String uuid) throws Exception; List<Map<String, String>> uploadDatasetlocal(MultipartFile[] files, String uuid) throws Exception;


ResponseEntity<InputStreamResource> downloadDatasetlocal(String filePath) throws Exception; ResponseEntity<InputStreamResource> downloadDatasetlocal(String filePath) throws Exception;


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

@@ -268,7 +268,6 @@ public class NewDatasetServiceImpl implements NewDatasetService {
datasetVo.setRelativePaths(relatePath + "/dataset"); datasetVo.setRelativePaths(relatePath + "/dataset");


datasetVo = addDatasetSourceToDataVo(datasetVo); datasetVo = addDatasetSourceToDataVo(datasetVo);
System.out.println(datasetVo);


YamlUtils.generateYamlFile(JsonUtils.objectToMap(datasetVo), localPath, "dataset"); YamlUtils.generateYamlFile(JsonUtils.objectToMap(datasetVo), localPath, "dataset");
//dvc数据跟踪 //dvc数据跟踪
@@ -294,6 +293,21 @@ public class NewDatasetServiceImpl implements NewDatasetService {
return "新增数据集成功"; 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 @Override
public Page<NewDatasetVo> newPersonalQueryByPage(Dataset dataset, PageRequest pageRequest) throws Exception { public Page<NewDatasetVo> newPersonalQueryByPage(Dataset dataset, PageRequest pageRequest) throws Exception {


+ 0
- 44
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/YamlUtils.java View File

@@ -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<String, Object> * 读取YAML文件并将其内容转换为Map<String, Object>
* *


Loading…
Cancel
Save