Merge remote-tracking branch 'origin/main' into main
commit
431a474860
@ -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> {
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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>
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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…
Reference in New Issue