Browse Source

增加修改资源版本功能

dev-check
chenzhihang 10 months ago
parent
commit
f76dc346e2
7 changed files with 48 additions and 47 deletions
  1. +6
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/NewDatasetFromGitController.java
  2. +6
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/NewModelFromGitController.java
  3. +2
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelsService.java
  4. +2
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/NewDatasetService.java
  5. +17
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java
  6. +15
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java
  7. +0
    -46
      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添加版本")
public AjaxResult addVersionFromLabelStudio(@RequestBody LabelDatasetVersionVo datasetVo) throws Exception {
return AjaxResult.success(this.newDatasetService.newCreateVersionFromLabelStudio(datasetVo));

}

@GetMapping("/queryDatasets")


+ 6
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/NewModelFromGitController.java View File

@@ -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上传模型文件,并将信息存入数据库。")


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

@@ -93,6 +93,8 @@ public interface ModelsService {

String newCreateVersion(ModelsVo modelsVo) throws Exception;

String updateVersionDesc(ModelsVo modelsVo) throws Exception;

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

ResponseEntity<InputStreamResource> downloadAllModelFilesNew(String name, String identifier, Integer id, String version, Boolean isPublic) throws IOException, Exception;


+ 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 updateVersionDesc(NewDatasetVo datasetVo) throws Exception;

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

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


+ 17
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java View File

@@ -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<String, Object> metaMap = JSON.parseObject(JSON.toJSONString(modelsVo), Map.class);
YamlUtils.generateYamlFile(metaMap, metaPath, "metadata");
dvcUtils.pushNewBranchToRemote(rootPath, gitLinkUsername, gitLinkPassword, branchName);
return "更新模型版本成功";
}


@Override
public List<Map<String, String>> uploadModelLocal(MultipartFile[] files, String uuid) throws Exception {


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

@@ -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<NewDatasetVo> newPersonalQueryByPage(Dataset dataset, PageRequest pageRequest) throws Exception {


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

@@ -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<String, Object>
*


Loading…
Cancel
Save