feat(controller): 添加上传本地技能压缩包V2接口
- 在SkillGenController中新增uploadSkillV4方法,支持上传zip或rar格式技能包 - 新增CmsContent uploadSkillV4接口实现技能包解析和内容生成 - 集成SevenZipJBinding库支持rar格式解压 - 实现压缩包目录树结构解析功能 - 添加YAML内容生成和技能信息提取功能 - 完善异常处理和错误信息返回机制
This commit is contained in:
parent
b548bfbc14
commit
a5631caab3
|
|
@ -128,4 +128,24 @@ public class SkillGenController {
|
||||||
return CommonResult.success(cmsContent);
|
return CommonResult.success(cmsContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传本地技能压缩包V2
|
||||||
|
*
|
||||||
|
* @param file 技能压缩包文件
|
||||||
|
* @return 生成的技能内容
|
||||||
|
*/
|
||||||
|
@PostMapping("/uploadSkillV4")
|
||||||
|
@Operation(summary = "上传本地技能压缩包V2", description = "上传本地zip或rar文件并生成技能")
|
||||||
|
public CommonResult<CmsContent> uploadSkillV4(
|
||||||
|
@RequestParam("file") MultipartFile file) {
|
||||||
|
try {
|
||||||
|
byte[] fileBytes = file.getBytes();
|
||||||
|
String fileName = file.getOriginalFilename();
|
||||||
|
CmsContent cmsContent = skillGenService.uploadSkillV4(fileBytes, fileName);
|
||||||
|
return CommonResult.success(cmsContent);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return CommonResult.failed("上传失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.kexue.skills.entity.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 技能包信息DTO
|
||||||
|
*
|
||||||
|
* @author AI技能生成助手
|
||||||
|
* @since 2026-04-10
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SkillPackageInfoDto implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 技能名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 版本号
|
||||||
|
*/
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 技能描述
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作者
|
||||||
|
*/
|
||||||
|
private String author;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建日期
|
||||||
|
*/
|
||||||
|
private String created;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标签列表
|
||||||
|
*/
|
||||||
|
private List<String> tags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 目录结构
|
||||||
|
*/
|
||||||
|
private List<SkillStructureNodeDto> structure;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.kexue.skills.entity.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 技能包目录结构节点DTO
|
||||||
|
*
|
||||||
|
* @author AI技能生成助手
|
||||||
|
* @since 2026-04-10
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SkillStructureNodeDto implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点名称(文件或目录名)
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点类型:directory 或 file
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父级路径
|
||||||
|
*/
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式:dir、markdown、python
|
||||||
|
*/
|
||||||
|
private String format;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点描述
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子节点列表(目录类型使用)
|
||||||
|
*/
|
||||||
|
private List<SkillStructureNodeDto> children;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件内容(文件类型使用)
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
}
|
||||||
|
|
@ -69,5 +69,7 @@ public interface SkillGenService {
|
||||||
*/
|
*/
|
||||||
CmsContent uploadSkillV2(byte[] fileBytes, String fileName);
|
CmsContent uploadSkillV2(byte[] fileBytes, String fileName);
|
||||||
|
|
||||||
|
CmsContent uploadSkillV4(byte[] fileBytes, String fileName);
|
||||||
|
|
||||||
CmsContent uploadSkillV3(String yamlContent);
|
CmsContent uploadSkillV3(String yamlContent);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.kexue.skills.utils;
|
||||||
|
|
||||||
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
|
public class YamlUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对象转 YAML 字符串
|
||||||
|
*/
|
||||||
|
public static String toYaml(Object obj) {
|
||||||
|
DumperOptions options = new DumperOptions();
|
||||||
|
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||||
|
options.setPrettyFlow(true);
|
||||||
|
Yaml yaml = new Yaml(options);
|
||||||
|
return yaml.dump(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue