Merge remote-tracking branch 'origin/main' into main

main
jiangxucong 3 months ago
commit 431a474860

@ -53,6 +53,7 @@ const Category = memo<{ data: DiscoverProviderItem[] }>(({ data }) => {
return ( return (
<CategoryMenu <CategoryMenu
style={{ width: 'red' }}
items={items.map((item: any) => ({ items={items.map((item: any) => ({
...item, ...item,
label: ( label: (

@ -43,12 +43,12 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@ -154,6 +154,16 @@
<artifactId>hanlp</artifactId> <artifactId>hanlp</artifactId>
<version>portable-1.8.6</version> <version>portable-1.8.6</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3</version> <!-- 请检查是否有更新的版本 -->
</dependency>
</dependencies> </dependencies>
<!-- 阿里云maven仓库 --> <!-- 阿里云maven仓库 -->
<repositories> <repositories>

@ -34,6 +34,7 @@ import java.text.SimpleDateFormat;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
/** /**
* MVC * MVC
* *
@ -89,4 +90,11 @@ public class WebMvcConfig implements WebMvcConfigurer {
converter.setObjectMapper(mapper); converter.setObjectMapper(mapper);
return converter; return converter;
} }
// @Bean
// public CommonsMultipartResolver multipartResolver() {
// org.springframework.web.multipart.commons.CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
// multipartResolver.setMaxUploadSize(100000); // 设置最大上传大小
// return multipartResolver;
// }
} }

@ -53,7 +53,7 @@ public class ChunksController {
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
public Result<ChunksDTO> get(@PathVariable("id") Long id){ public Result<ChunksDTO> get(@PathVariable("id") String id){
ChunksDTO data = chunksService.get(id); ChunksDTO data = chunksService.get(id);
return new Result<ChunksDTO>().ok(data); return new Result<ChunksDTO>().ok(data);
@ -69,7 +69,7 @@ public class ChunksController {
public Result save(@RequestBody ChunksDTO dto){ public Result save(@RequestBody ChunksDTO dto){
chunksService.save(dto); chunksService.save(dto);
return new Result(); return new Result().ok(dto);
} }
@PutMapping @PutMapping
@ -78,16 +78,16 @@ public class ChunksController {
chunksService.update(dto); chunksService.update(dto);
return new Result(); return new Result().ok(dto);
} }
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody String[] ids){
//效验数据 //效验数据
chunksService.delete(ids); chunksService.delete(ids);
return new Result(); return new Result().ok(ids);
} }
} }

@ -14,10 +14,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.nio.file.Files; import java.nio.file.Files;
@ -46,7 +48,7 @@ public class DigitalImgController {
@Autowired @Autowired
FileUtil fileUtil; FileUtil fileUtil;
@PostMapping("/uploadPicture") @PostMapping("/uploadPicture")
public Result<String> uploadPicture(@RequestParam("file") MultipartFile file) { public Result<String> uploadPicture(@RequestParam(value="file") MultipartFile file) {
if (file.isEmpty()) { if (file.isEmpty()) {
return new Result<String>().error("文件为空"); return new Result<String>().error("文件为空");
} }
@ -57,7 +59,7 @@ public class DigitalImgController {
return new Result<String>().error("上传失败: " + e.getMessage()); return new Result<String>().error("上传失败: " + e.getMessage());
} }
} }
@PostMapping("/getPicture") @GetMapping("/getPicture")
public void getPicture(HttpServletResponse response,@RequestParam(name = "id", required = true) String id) { public void getPicture(HttpServletResponse response,@RequestParam(name = "id", required = true) String id) {
try { try {
DigitalImgDTO data = digitalImgService.get(id); DigitalImgDTO data = digitalImgService.get(id);
@ -104,6 +106,8 @@ public class DigitalImgController {
digitalImgService.save(dto); digitalImgService.save(dto);
return new Result(); return new Result();
//param ={"imgPath":"uploads/202503/5c799cffa5864619b817063f77fe734d..png","name":"开源项目","imgType":"1"}
//{"code":0,"msg":"success","data":null}
} }
@PutMapping @PutMapping

@ -52,7 +52,7 @@ public class FileChunksController {
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
public Result<FileChunksDTO> get(@PathVariable("id") Long id){ public Result<FileChunksDTO> get(@PathVariable("id") String id){
FileChunksDTO data = fileChunksService.get(id); FileChunksDTO data = fileChunksService.get(id);
return new Result<FileChunksDTO>().ok(data); return new Result<FileChunksDTO>().ok(data);
@ -78,7 +78,7 @@ public class FileChunksController {
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody String[] ids){
fileChunksService.delete(ids); fileChunksService.delete(ids);

@ -99,7 +99,7 @@ public class FilesController {
public Result delete(@RequestBody String[] ids){ public Result delete(@RequestBody String[] ids){
filesService.delete(ids); filesService.delete(ids);
return new Result(); return new Result().ok(ids);
} }
} }

@ -52,7 +52,7 @@ public class GlobalFilesController {
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
public Result<GlobalFilesDTO> get(@PathVariable("id") Long id){ public Result<GlobalFilesDTO> get(@PathVariable("id") String id){
GlobalFilesDTO data = globalFilesService.get(id); GlobalFilesDTO data = globalFilesService.get(id);
return new Result<GlobalFilesDTO>().ok(data); return new Result<GlobalFilesDTO>().ok(data);
@ -64,7 +64,7 @@ public class GlobalFilesController {
globalFilesService.save(dto); globalFilesService.save(dto);
return new Result(); return new Result().ok(dto);
} }
@PutMapping @PutMapping
@ -73,16 +73,16 @@ public class GlobalFilesController {
globalFilesService.update(dto); globalFilesService.update(dto);
return new Result(); return new Result().ok(dto);
} }
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody String[] ids){
globalFilesService.delete(ids); globalFilesService.delete(ids);
return new Result(); return new Result().ok(ids);
} }
} }

@ -86,7 +86,7 @@ public class KnowledgeBasesController {
public Result delete(@RequestBody String[] ids){ public Result delete(@RequestBody String[] ids){
knowledgeBasesService.delete(ids); knowledgeBasesService.delete(ids);
return new Result(); return new Result().ok(ids);
} }
} }

@ -52,7 +52,7 @@ public class MyDigitalHumanController {
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
public Result<MyDigitalHumanDTO> get(@PathVariable("id") Long id){ public Result<MyDigitalHumanDTO> get(@PathVariable("id") String id){
MyDigitalHumanDTO data = myDigitalHumanService.get(id); MyDigitalHumanDTO data = myDigitalHumanService.get(id);
return new Result<MyDigitalHumanDTO>().ok(data); return new Result<MyDigitalHumanDTO>().ok(data);
@ -62,23 +62,26 @@ public class MyDigitalHumanController {
@ApiOperation("保存") @ApiOperation("保存")
public Result save(@RequestBody MyDigitalHumanDTO dto){ public Result save(@RequestBody MyDigitalHumanDTO dto){
myDigitalHumanService.save(dto); //
MyDigitalHumanDTO ret = myDigitalHumanService.genVideo(dto);
//myDigitalHumanService.save(dto);
return new Result(); return new Result<MyDigitalHumanDTO>().ok(ret);
} }
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
public Result update(@RequestBody MyDigitalHumanDTO dto){ public Result update(@RequestBody MyDigitalHumanDTO dto){
myDigitalHumanService.update(dto); MyDigitalHumanDTO ret = myDigitalHumanService.genVideo(dto);
//myDigitalHumanService.update(dto);
return new Result(); return new Result<MyDigitalHumanDTO>().ok(ret);
} }
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody String[] ids){
myDigitalHumanService.delete(ids); myDigitalHumanService.delete(ids);

@ -0,0 +1,95 @@
package com.pjilisense.flxai.controller;
import com.pjilisense.flxai.base.constant.Constant;
import com.pjilisense.flxai.dto.DigitalImgDTO;
import com.pjilisense.flxai.page.PageData;
import com.pjilisense.flxai.utils.Result;
import com.pjilisense.flxai.dto.VoiceRefFilesDTO;
import com.pjilisense.flxai.service.VoiceRefFilesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
*
*
* @author liushujing liushujing@philisense.com
* @since 1.0.0 2025-02-28
*/
@RestController
@RequestMapping(Constant.BASE_PATH+"voicereffiles")
@Api(tags="音频参考文件")
public class VoiceRefFilesController {
private static Logger logger = LoggerFactory.getLogger(VoiceRefFilesController.class);
@Autowired
private VoiceRefFilesService voiceRefFilesService;
@GetMapping("page")
@ApiOperation("分页")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType="Integer", dataTypeClass =Integer.class) ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="Integer", dataTypeClass =Integer.class) ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String", dataTypeClass =String.class) ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String", dataTypeClass =String.class)
})
public Result<PageData<VoiceRefFilesDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<VoiceRefFilesDTO> page = voiceRefFilesService.page(params);
return new Result<PageData<VoiceRefFilesDTO>>().ok(page);
}
@PostMapping("queryAll")
@ApiOperation("根据类型获取全部数据")
public Result<List<VoiceRefFilesDTO>> queryAll(@RequestBody VoiceRefFilesDTO dto) {
List<VoiceRefFilesDTO> page = voiceRefFilesService.getAll(dto);
return new Result<List<VoiceRefFilesDTO>>().ok(page);
}
@GetMapping("{id}")
@ApiOperation("信息")
public Result<VoiceRefFilesDTO> get(@PathVariable("id") String id){
VoiceRefFilesDTO data = voiceRefFilesService.get(id);
return new Result<VoiceRefFilesDTO>().ok(data);
}
@PostMapping
@ApiOperation("保存")
public Result save(@RequestBody VoiceRefFilesDTO dto){
voiceRefFilesService.save(dto);
return new Result();
}
@PutMapping
@ApiOperation("修改")
public Result update(@RequestBody VoiceRefFilesDTO dto){
voiceRefFilesService.update(dto);
return new Result();
}
@DeleteMapping
@ApiOperation("删除")
public Result delete(@RequestBody String[] ids){
voiceRefFilesService.delete(ids);
return new Result();
}
}

@ -0,0 +1,16 @@
package com.pjilisense.flxai.dao;
import com.pjilisense.flxai.base.dao.BaseDao;
import com.pjilisense.flxai.entity.VoiceRefFilesEntity;
import org.apache.ibatis.annotations.Mapper;
/**
*
*
* @author liushujing liushujing@philisense.com
* @since 1.0.0 2025-02-28
*/
@Mapper
public interface VoiceRefFilesDao extends BaseDao<VoiceRefFilesEntity> {
}

@ -28,8 +28,9 @@ public class DigitalImgDTO implements Serializable {
@ApiModelProperty(value = "图片存放的相对路径") @ApiModelProperty(value = "图片存放的相对路径")
private String imgPath; private String imgPath;
@ApiModelProperty(value = "图片类型1数字人形象2数字人场景3数字人背景") @ApiModelProperty(value = "图片类型1数字人形象2数字人场景3数字人背景4音色形象")
private String imgType; private String imgType;
@ApiModelProperty(value = "音频在服务器的目录")
private String voiceServerDir;
} }

@ -0,0 +1,38 @@
package com.pjilisense.flxai.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
*
*
* @author liushujing liushujing@philisense.com
* @since 1.0.0 2025-02-28
*/
@Data
@ApiModel(value = "音频参考文件")
public class VoiceRefFilesDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "音频存路径")
private String voicePath;
@ApiModelProperty(value = "显示图片路径")
private String imgPath;
@ApiModelProperty(value = "语言")
private String language;
}

@ -1,6 +1,7 @@
package com.pjilisense.flxai.entity; package com.pjilisense.flxai.entity;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
@ -28,7 +29,13 @@ public class DigitalImgEntity {
*/ */
private String imgPath; private String imgPath;
/** /**
* 123 * 1234
*/ */
private String imgType; private String imgType;
/**
*
*/
private String voiceServerDir;
} }

@ -0,0 +1,38 @@
package com.pjilisense.flxai.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
/**
*
*
* @author liushujing liushujing@philisense.com
* @since 1.0.0 2025-02-28
*/
@Data
@TableName("voice_ref_files")
public class VoiceRefFilesEntity {
/**
*
*/
private String id;
/**
*
*/
private String name;
/**
*
*/
private String voicePath;
/**
*
*/
private String imgPath;
/**
*
*/
private String language;
}

@ -12,4 +12,5 @@ import com.pjilisense.flxai.entity.MyDigitalHumanEntity;
*/ */
public interface MyDigitalHumanService extends CrudService<MyDigitalHumanEntity, MyDigitalHumanDTO> { public interface MyDigitalHumanService extends CrudService<MyDigitalHumanEntity, MyDigitalHumanDTO> {
MyDigitalHumanDTO genVideo(MyDigitalHumanDTO dto);
} }

@ -0,0 +1,18 @@
package com.pjilisense.flxai.service;
import com.pjilisense.flxai.base.service.CrudService;
import com.pjilisense.flxai.dto.VoiceRefFilesDTO;
import com.pjilisense.flxai.entity.VoiceRefFilesEntity;
import java.util.List;
/**
*
*
* @author liushujing liushujing@philisense.com
* @since 1.0.0 2025-02-28
*/
public interface VoiceRefFilesService extends CrudService<VoiceRefFilesEntity, VoiceRefFilesDTO> {
List<VoiceRefFilesDTO> getAll(VoiceRefFilesDTO dto);
}

@ -37,7 +37,7 @@ public class ChunksServiceImpl extends CrudServiceImpl<ChunksDao, ChunksEntity,
@Override @Override
public List<Map<String, Object>> search(String userid,String keyText) { public List<Map<String, Object>> search(String userid,String keyText) {
return search1( userid, keyText); return search2( userid, keyText);
} }
private List<Map<String, Object>> search1(String userid,String keyText) { private List<Map<String, Object>> search1(String userid,String keyText) {

@ -31,4 +31,15 @@ public class MyDigitalHumanServiceImpl extends CrudServiceImpl<MyDigitalHumanDao
} }
@Override
public MyDigitalHumanDTO genVideo(MyDigitalHumanDTO dto) {
//TODO:gen video code here
if(dto.getId()!=null&&dto.getId().length()>0){
update(dto);
} else {
save(dto);
}
return dto;
}
} }

@ -0,0 +1,48 @@
package com.pjilisense.flxai.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pjilisense.flxai.base.service.impl.CrudServiceImpl;
import com.pjilisense.flxai.dao.VoiceRefFilesDao;
import com.pjilisense.flxai.dto.DigitalImgDTO;
import com.pjilisense.flxai.dto.VoiceRefFilesDTO;
import com.pjilisense.flxai.entity.DigitalImgEntity;
import com.pjilisense.flxai.entity.VoiceRefFilesEntity;
import com.pjilisense.flxai.service.VoiceRefFilesService;
import cn.hutool.core.util.StrUtil;
import com.pjilisense.flxai.utils.ConvertUtils;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
*
*
* @author liushujing liushujing@philisense.com
* @since 1.0.0 2025-02-28
*/
@Service
public class VoiceRefFilesServiceImpl extends CrudServiceImpl<VoiceRefFilesDao, VoiceRefFilesEntity, VoiceRefFilesDTO> implements VoiceRefFilesService {
@Override
public QueryWrapper<VoiceRefFilesEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get("id");
QueryWrapper<VoiceRefFilesEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StrUtil.isNotBlank(id), "id", id);
return wrapper;
}
@Override
public List<VoiceRefFilesDTO> getAll(VoiceRefFilesDTO dto) {
QueryWrapper<VoiceRefFilesEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StrUtil.isNotBlank(dto.getLanguage()), "language", dto.getLanguage());
wrapper.eq(StrUtil.isNotBlank(dto.getId()), "id", dto.getId());
wrapper.like(StrUtil.isNotBlank(dto.getName()), "name", dto.getName());
wrapper.orderByAsc("id");
List<VoiceRefFilesEntity> entityList =baseDao.selectList(wrapper);
return ConvertUtils.sourceToTarget(entityList, VoiceRefFilesDTO.class);
}
}

@ -39,13 +39,14 @@ public class FileUtil {
//⽂件后缀,如.jpeg //⽂件后缀,如.jpeg
assert filename != null; assert filename != null;
String suffix = filename.substring(filename.lastIndexOf(".")); String suffix = filename.substring(filename.lastIndexOf("."));
relPath =relPath+"/"+UUID.randomUUID().toString().replace("-","")+"."+suffix; relPath =relPath+UUID.randomUUID().toString().replace("-","")+suffix;
//⽬标⽂件 //⽬标⽂件
File descFile = new File(getFilepath(relPath)); File descFile = new File(getFilepath(relPath));
//判断⽬标⽂件所在的⽬录是否存在 //判断⽬标⽂件所在的⽬录是否存在
if (!descFile.getParentFile().exists()) { if (!descFile.getParentFile().exists()) {
descFile.getParentFile().mkdirs(); descFile.getParentFile().mkdirs();
} }
//multipartFile.transferTo(descFile);
try (InputStream is = multipartFile.getInputStream(); try (InputStream is = multipartFile.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is); BufferedInputStream bis = new BufferedInputStream(is);
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(descFile))) { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(descFile))) {
@ -91,10 +92,14 @@ public class FileUtil {
try { try {
// 读到流中 // 读到流中
if(file.isDirectory()) { if(file.isDirectory()) {
inputStream = new FileInputStream(filepath +"/"+ filename);// 文件的存放路径 filename = rootPath +"/"+ filename;
filename = filename.replace("//","/");
inputStream = new FileInputStream(filename);// 文件的存放路径
} else { } else {
inputStream = new FileInputStream(filepath);//filepath可能包含文件名 filename=rootPath;
inputStream = new FileInputStream(filename);//filepath可能包含文件名
} }
filename =filename.substring(filename.lastIndexOf("/")+1);
response.reset(); response.reset();
response.setContentType("application/octet-stream"); response.setContentType("application/octet-stream");
response.addHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(filename, "UTF-8")); response.addHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(filename, "UTF-8"));
@ -106,6 +111,7 @@ public class FileUtil {
outputStream.write(b, 0, len); outputStream.write(b, 0, len);
} }
} catch (IOException e) { } catch (IOException e) {
System.out.println(e.getMessage());
//log.error(e.getMessage(), e); //log.error(e.getMessage(), e);
}finally { }finally {
try { try {
@ -116,6 +122,7 @@ public class FileUtil {
} }
} }
} }
//
} }
public String getFilepath (final String filepath) {//filepath可能包含文件名 public String getFilepath (final String filepath) {//filepath可能包含文件名

@ -8,6 +8,7 @@
<result property="name" column="name"/> <result property="name" column="name"/>
<result property="imgPath" column="img_path"/> <result property="imgPath" column="img_path"/>
<result property="imgType" column="img_type"/> <result property="imgType" column="img_type"/>
<result property="voiceServerDir" column="voice_server_dir"/>
</resultMap> </resultMap>

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pjilisense.flxai.dao.VoiceRefFilesDao">
<resultMap type="com.pjilisense.flxai.entity.VoiceRefFilesEntity" id="voiceRefFilesMap">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="voicePath" column="voice_path"/>
<result property="imgPath" column="img_path"/>
<result property="language" column="language"/>
</resultMap>
<resultMap type="java.util.Map" id="BaseResultMap">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="voicePath" column="voice_path"/>
<result property="imgPath" column="img_path"/>
<result property="language" column="language"/>
</resultMap>
</mapper>

@ -222,6 +222,40 @@ public class TestUtils {
return null; return null;
} }
public static void doGetFile(String connectURL, String destFile) {
byte[] bytes = null;
ByteArrayOutputStream byteArrayOut = null;
URL url = null;
HttpURLConnection httpGet = null;
InputStream in = null;
try {
url = new URL(connectURL);
httpGet = (HttpURLConnection) url.openConnection();
httpGet.setConnectTimeout(CONNECT_TIMEOUT);
httpGet.setReadTimeout(READ_TIMEOUT);
httpGet.setRequestProperty("token", TOKEN);
httpGet.connect();
in = httpGet.getInputStream();
byteArrayOut = new ByteArrayOutputStream();
byte[] buf = new byte[512];
int l = 0;
while ((l = in.read(buf)) != -1) {
byteArrayOut.write(buf, 0, l);
}
bytes = byteArrayOut.toByteArray();
File file=new File(destFile);
file.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(file);
fos.write(bytes);
fos.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
close(byteArrayOut);
close(in);
close(httpGet);
}
}
private static void close(Closeable stream) { private static void close(Closeable stream) {
if (stream != null) { if (stream != null) {
try { try {

@ -28,7 +28,7 @@ public class ChunksControllerTest {
} }
@Test @Test
public void testGetAllAiTools() { public void testsearch() {
String url = TestUtils.WebconnectURL+"/api/robot/chunks/search"; String url = TestUtils.WebconnectURL+"/api/robot/chunks/search";
String charset = TestUtils.UTF8; String charset = TestUtils.UTF8;
try { try {
@ -40,6 +40,12 @@ public class ChunksControllerTest {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
//param ={"text":"开源项目","userId":"2f3c5337-cf1a-40ce-bbe3-ec45455d82f1"}
//{"code":0,"msg":"success","data":[{"fid":"file_wb9Pk6GBUq0z","fname":"问答.txt","question":"开源项目","answer":"HanLP是由一系列NLP工具组成的开源项目其中包含了中文分词、词性标注、命名实体识别等功能。","similarity":"0.9999999999999997779553950749686919152736663818359375","id":"2bcbd9ae-053e-45e5-a3a9-5498915bd749","text":"开源项目,HanLP是由一系列NLP工具组成的开源项目其中包含了中文分词、词性标注、命名实体识别等功能。"},{"fid":"file_wb9Pk6GBUq0z","fname":"问答.txt","question":"开源项目HanLP","answer":"HanLP是由一系列NLP工具组成的开源项目其中包含了中文分词、词性标注、命名实体识别等功能。","similarity":"0.81649658092772592343777660062187351286411285400390625","id":"2bcbd9ae-053e-45e5-a3a9-5498915bd748","text":"开源项目HanLP,HanLP是由一系列NLP工具组成的开源项目其中包含了中文分词、词性标注、命名实体识别等功能。"}]}
//2
//param ={"text":"开源项目","userId":"2f3c5337-cf1a-40ce-bbe3-ec45455d82f1"}
//{"code":0,"msg":"success","data":[{"fid":"file_wb9Pk6GBUq0z","fname":"问答.txt","similarity":"0.452267016866645388262213600683026015758514404296875","id":"2bcbd9ae-053e-45e5-a3a9-5498915bd749","text":"开源项目,HanLP是由一系列NLP工具组成的开源项目其中包含了中文分词、词性标注、命名实体识别等功能。"},{"fid":"file_wb9Pk6GBUq0z","fname":"问答.txt","similarity":"0.424264068711928510335695818866952322423458099365234375","id":"2bcbd9ae-053e-45e5-a3a9-5498915bd748","text":"开源项目HanLP,HanLP是由一系列NLP工具组成的开源项目其中包含了中文分词、词性标注、命名实体识别等功能。"}]}
} }
} }

@ -0,0 +1,148 @@
package test.com.pjilisense.flxai.controller;
import cn.hutool.http.body.MultipartBody;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.ApiModelProperty;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import test.com.pjilisense.flxai.TestUtils;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
public class DigitalImgControllerTest {
@BeforeEach
public void setUpTestDataWithinTransaction() {
// set up test data within the transaction
}
@AfterEach
public void tearDownWithinTransaction() {
// execute "tear down" logic within the transaction
}
@Test
public void testuploadPicture() {
String urls = TestUtils.WebconnectURL+"/api/robot/digitalimg/uploadPicture";
String charset = TestUtils.UTF8;
try {
CloseableHttpClient client = HttpClients.createDefault();
File file = new File("C:\\Users\\john\\Desktop\\30_200_200.jpg");
try {
URL url = new URL(urls);
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
httpConn.setUseCaches(false);
httpConn.setDoOutput(true); // Indicates that data will be sent
httpConn.setDoInput(true); // Indicates that data will be received
httpConn.setRequestMethod("POST"); // HTTP Request Method
String boundary = Long.toHexString(System.currentTimeMillis()); // Just generate any random value here
httpConn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
OutputStream output = httpConn.getOutputStream();
PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, "UTF-8"), true);
// Send normal form data with name "file"
writer.append("--" + boundary).append("\r\n");
writer.append("Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getName() + "\"").append("\r\n");
writer.append("Content-Type: " + "application/octet-stream").append("\r\n");
writer.append("\r\n").flush();
writer.flush();
// files data
FileInputStream input = new FileInputStream(file);
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = input.read(buffer)) != -1) {
output.write(buffer, 0, bytesRead);
}
output.flush();
input.close();
// Send multipart form data terminator
writer.append("\r\n").flush();
writer.append("--" + boundary + "--\r\n").append("\r\n").flush();
// Gets the response status code
int status = httpConn.getResponseCode();
BufferedReader reader = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
writer.close();
output.close();
httpConn.disconnect();
} catch (Exception ex) {
ex.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
//{"code":0,"msg":"success","data":"uploads/202503/882d8b1d82de42308142f9a49b5716f8.jpg"}
}
@Test
public void testgetPicture() {
String url = TestUtils.WebconnectURL+"/api/robot/digitalimg/getPicture?id=1896743235380944897";
TestUtils.doGetFile(url, "D:\\ceshi\\sysfile\\download\202503\\1896743235380944897.png");
}
@Test
public void testGetAllAiTools() {
String url = TestUtils.WebconnectURL+"/api/robot/digitalimg/getAllByType?imgType=1";
String charset = TestUtils.UTF8;
try {
String body = TestUtils.doGet(url, charset);
System.out.println(body);
} catch (Exception e) {
e.printStackTrace();
}
//{"code":0,"msg":"success","data":[{"id":"1896741333490540546","name":"开源项目","imgPath":"uploads/202503/5c799cffa5864619b817063f77fe734d.png","imgType":"1"}]}
}
@Test
public void testSave() {
String url = TestUtils.WebconnectURL+"/api/robot/digitalimg";
String charset = TestUtils.UTF8;
try {
Map<String, Object> params = new HashMap<String, Object>();
// params.put("name","开源项目");
// params.put("imgPath","uploads/202503/5c799cffa5864619b817063f77fe734d.png");
// params.put("imgType","1");
// params.put("name","开源项目");
// params.put("imgPath","uploads/202503/d1f8398f9bb844079f774ef496347e12.png");
// params.put("imgType","1");
params.put("name","音色1");
params.put("imgPath","uploads/202503/4eaee34079d74517ad6b9ea1e90e8308.jpg");
params.put("imgType","4");
String body = TestUtils.doPost(url, JSON.toJSONString(params), charset);
System.out.println(body);
//param ={"imgPath":"uploads/202503/d1f8398f9bb844079f774ef496347e12.png","name":"开源项目","imgType":"1"}
//{"code":0,"msg":"success","data":null}
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testupdate() {
String url = TestUtils.WebconnectURL+"/api/robot/digitalimg";
String charset = TestUtils.UTF8;
try {
Map<String, Object> params = new HashMap<String, Object>();
params.put("id","1896741333490540546");
params.put("name","开源项目2");
params.put("imgPath","uploads/202503/5c799cffa5864619b817063f77fe734d.png");
params.put("imgType","2");
String body = TestUtils.doPut(url, JSON.toJSONString(params), charset);
System.out.println(body);
//param ={"imgPath":"uploads/202503/5c799cffa5864619b817063f77fe734d.png","name":"开源项目2","id":"1896741333490540546","imgType":"2"}
//{"code":0,"msg":"success","data":null}
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -28,7 +28,7 @@ public class FilesControllerTest {
} }
@Test @Test
public void testGetAllAiTools() { public void testGetFileList() {
String url = TestUtils.WebconnectURL+"/api/robot/files/file_2FbUmaefz5b4"; String url = TestUtils.WebconnectURL+"/api/robot/files/file_2FbUmaefz5b4";
String charset = TestUtils.UTF8; String charset = TestUtils.UTF8;
try { try {
@ -37,6 +37,8 @@ public class FilesControllerTest {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
//method =GET
//{"code":0,"msg":"success","data":{"id":"file_2FbUmaefz5b4","userId":"fd8ae359-64dc-4a57-ab41-5438e2fda975","fileType":"text/plain","name":"jykc2.sql","size":1864714,"url":"files/482454/d2b0edb3-15bf-4fe6-ba2e-97b5f1fe0288.sql","metadata":{"date":"482454","path":"files/482454/d2b0edb3-15bf-4fe6-ba2e-97b5f1fe0288.sql","filename":"d2b0edb3-15bf-4fe6-ba2e-97b5f1fe0288.sql","dirname":"files/482454"},"createdAt":"2025-01-14 14:29:02","updatedAt":"2025-01-14 14:29:23","fileHash":"1d66edbc0b5da3289ecea1ae00ac384b2378603193574c5f0bc9a9a988de2a16","chunkTaskId":"ab3f259e-775a-4c57-8338-b273684f70d1","embeddingTaskId":"12020d55-d453-46d7-a8c8-b0bba5f5c747","accessedAt":"2025-01-14 14:29:02","fileCategory":"1","fileStatus":"1"}}
} }
// @Test // @Test
// public void testsave() { // public void testsave() {
@ -81,6 +83,9 @@ public class FilesControllerTest {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
//method =POST
//param ={"name":"jykc2.sql","id":"file_2FbUmaefz5b4"}
//{"code":0,"msg":"success","data":true}
} }
@Test @Test
@ -96,6 +101,9 @@ public class FilesControllerTest {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
//method =POST
//param ={"fileStatus":"1","id":"file_2FbUmaefz5b4"}
//{"code":0,"msg":"success","data":true}
} }
@Test @Test
public void testmodifyFileCategory() { public void testmodifyFileCategory() {
@ -110,5 +118,8 @@ public class FilesControllerTest {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
//method =POST
//param ={"fileCategory":"1","id":"file_2FbUmaefz5b4"}
//{"code":0,"msg":"success","data":true}
} }
} }

@ -37,6 +37,7 @@ public class KnowledgeBasesControllerTest {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
//{"code":0,"msg":"success","data":{"id":"kb_E5EcemGyKnh9","name":"知识库1","description":"知识库测试2","avatar":null,"type":null,"userId":"fd8ae359-64dc-4a57-ab41-5438e2fda975","isPublic":false,"settings":null,"createdAt":"2025-01-14 14:27:55","updatedAt":"2025-01-16 16:01:51","accessedAt":"2025-01-14 14:27:55"}}
} }
// @Test // @Test
// public void testsave() { // public void testsave() {
@ -83,5 +84,7 @@ public class KnowledgeBasesControllerTest {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
//param ={"description":"知识库测试23","id":"kb_E5EcemGyKnh9"}
//{"code":0,"msg":"success","data":true}
} }
} }

@ -0,0 +1,86 @@
package test.com.pjilisense.flxai.controller;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.ApiModelProperty;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import test.com.pjilisense.flxai.TestUtils;
import java.util.HashMap;
import java.util.Map;
public class MyDigitalHumanControllerTest {
@BeforeEach
public void setUpTestDataWithinTransaction() {
// set up test data within the transaction
}
@AfterEach
public void tearDownWithinTransaction() {
// execute "tear down" logic within the transaction
}
@Test
public void testGetAllAiTools() {
String url = TestUtils.WebconnectURL+"/api/robot/mydigitalhuman/queryAll?language=ch";
String charset = TestUtils.UTF8;
try {
Map<String, Object> params = new HashMap<String, Object>();
params.put("language","zh");
String body = TestUtils.doPost(url, JSON.toJSONString(params), charset);
System.out.println(body);
} catch (Exception e) {
e.printStackTrace();
}
//param ={"language":"zh"}
//{"code":0,"msg":"success","data":[{"id":"1896763411581108225","name":"音色Modify","voicePath":"uploads/202503/5c799cffa5864619b817063f77fe734e.MP3","imgPath":"1896761492913520641","language":"zh"}]}
}
@Test
public void testSave() {
String url = TestUtils.WebconnectURL+"/api/robot/mydigitalhuman";
String charset = TestUtils.UTF8;
try {
Map<String, Object> params = new HashMap<String, Object>();
params.put("userid","fd8ae359-64dc-4a57-ab41-5438e2fda975");
params.put("imageid","1896761492913520641");
params.put("sceneimgid","1896761492913520641");
params.put("bkimgid","1896761492913520641");
params.put("voiceid","1896763411581108225");
params.put("videoimg","1896763411581108225");
params.put("videodir","genvideo/202503/5c799cffa5864619b817063f77fe734d.mp4");
params.put("voicedir","genvoice/202503/A1");
String body = TestUtils.doPost(url, JSON.toJSONString(params), charset);
System.out.println(body);
//param ={"voiceid":"1896763411581108225","videodir":"genvideo/202503/5c799cffa5864619b817063f77fe734d.mp4","imageid":"1896761492913520641","bkimgid":"1896761492913520641","voicedir":"genvoice/202503/A1","videoimg":"1896763411581108225","userid":"fd8ae359-64dc-4a57-ab41-5438e2fda975","sceneimgid":"1896761492913520641"}
//{"code":0,"msg":"success","data":null}
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testupdate() {
String url = TestUtils.WebconnectURL+"/api/robot/mydigitalhuman";
String charset = TestUtils.UTF8;
try {
Map<String, Object> params = new HashMap<String, Object>();
params.put("id","1896816581502042113");
params.put("userid","fd8ae359-64dc-4a57-ab41-5438e2fda975");
params.put("imageid","1896761492913520641");
params.put("sceneimgid","1896761492913520641");
params.put("bkimgid","1896761492913520641");
params.put("voiceid","1896763411581108225");
params.put("videoimg","1896763411581108225");
params.put("videodir","genvideo/202503/5c799cffa5864619b817063f77fe734d.mp4");
params.put("voicedir","genvoice/202503/A2");
String body = TestUtils.doPut(url, JSON.toJSONString(params), charset);
System.out.println(body);
//param ={"voiceid":"1896763411581108225","videodir":"genvideo/202503/5c799cffa5864619b817063f77fe734d.mp4","imageid":"1896761492913520641","bkimgid":"1896761492913520641","voicedir":"genvoice/202503/A2","videoimg":"1896763411581108225","id":"1896816581502042113","userid":"fd8ae359-64dc-4a57-ab41-5438e2fda975","sceneimgid":"1896761492913520641"}
//{"code":0,"msg":"success","data":null}
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,82 @@
package test.com.pjilisense.flxai.controller;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.ApiModelProperty;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import test.com.pjilisense.flxai.TestUtils;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
public class VoiceRefFilesControllerTest {
@BeforeEach
public void setUpTestDataWithinTransaction() {
// set up test data within the transaction
}
@AfterEach
public void tearDownWithinTransaction() {
// execute "tear down" logic within the transaction
}
@Test
public void testGetAllAiTools() {
String url = TestUtils.WebconnectURL+"/api/robot/voicereffiles/queryAll?language=ch";
String charset = TestUtils.UTF8;
try {
Map<String, Object> params = new HashMap<String, Object>();
params.put("language","zh");
String body = TestUtils.doPost(url, JSON.toJSONString(params), charset);
System.out.println(body);
} catch (Exception e) {
e.printStackTrace();
}
//param ={"language":"zh"}
//{"code":0,"msg":"success","data":[{"id":"1896763411581108225","name":"音色Modify","voicePath":"uploads/202503/5c799cffa5864619b817063f77fe734e.MP3","imgPath":"1896761492913520641","language":"zh"}]}
}
@Test
public void testSave() {
String url = TestUtils.WebconnectURL+"/api/robot/voicereffiles";
String charset = TestUtils.UTF8;
try {
Map<String, Object> params = new HashMap<String, Object>();
params.put("name","音色1");
params.put("voicePath","uploads/202503/5c799cffa5864619b817063f77fe734d.MP3");
params.put("imgPath","1896761492913520641");
params.put("language","zh");
params.put("voiceServerDir","A1");
String body = TestUtils.doPost(url, JSON.toJSONString(params), charset);
System.out.println(body);
//param ={"voicePath":"uploads/202503/5c799cffa5864619b817063f77fe734d.MP3","imgPath":"1896761492913520641","name":"音色1","language":"zh","voiceServerDir":"A1"}
//{"code":0,"msg":"success","data":null}
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testupdate() {
String url = TestUtils.WebconnectURL+"/api/robot/voicereffiles";
String charset = TestUtils.UTF8;
try {
Map<String, Object> params = new HashMap<String, Object>();
params.put("id","1896763411581108225");
params.put("name","音色Modify");
params.put("voicePath","uploads/202503/5c799cffa5864619b817063f77fe734e.MP3");
params.put("imgPath","1896761492913520641");
params.put("language","zh");
String body = TestUtils.doPut(url, JSON.toJSONString(params), charset);
System.out.println(body);
//param ={"voicePath":"uploads/202503/5c799cffa5864619b817063f77fe734e.MP3","imgPath":"1896761492913520641","name":"音色Modify","language":"zh","id":"1896763411581108225","voiceServerDir":"A1"}
//{"code":0,"msg":"success","data":null}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Loading…
Cancel
Save