添加paddle 工具
parent
5201605876
commit
59772a9b9a
@ -0,0 +1,132 @@
|
||||
package com.supervision.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 响应信息主体
|
||||
*
|
||||
* @author qimaoyu
|
||||
*/
|
||||
@Data
|
||||
public class R<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String TOTAL_COUNT = "total";
|
||||
public static final String RESULT_LIST = "result";
|
||||
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
public static final int SUCCESS = 200;
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
public static final int FAIL = 500;
|
||||
|
||||
private int code;
|
||||
|
||||
private String msg;
|
||||
|
||||
private T data;
|
||||
|
||||
public static <T> R<T> ok() {
|
||||
return restResult(null, SUCCESS, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> judgeResult(Boolean bo, String successMessage, String failMessage) {
|
||||
if (bo) {
|
||||
return restResult(null, SUCCESS, successMessage);
|
||||
} else {
|
||||
return restResult(null, FAIL, failMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> R<T> okMsg(String msg) {
|
||||
return restResult(null, SUCCESS, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data) {
|
||||
return restResult(data, SUCCESS, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data, String msg) {
|
||||
return restResult(data, SUCCESS, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail() {
|
||||
return restResult(null, FAIL, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(String msg) {
|
||||
return restResult(null, FAIL, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(T data) {
|
||||
return restResult(data, FAIL, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(int code, String msg) {
|
||||
return restResult(null, code, msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static <T> R<T> restResult(T data, int code, String msg) {
|
||||
R<T> apiResult = new R<>();
|
||||
apiResult.setCode(code);
|
||||
apiResult.setData(data);
|
||||
apiResult.setMsg(msg);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
|
||||
public static Map<String, Object> buildDataMap(List list) {
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
if (list == null) {
|
||||
dataMap.put(TOTAL_COUNT, 0);
|
||||
dataMap.put(RESULT_LIST, new ArrayList<>());
|
||||
} else {
|
||||
dataMap.put(TOTAL_COUNT, list.size());
|
||||
dataMap.put(RESULT_LIST, list);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
public static Map<String, Object> buildDataMap(List list, Long total) {
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put(TOTAL_COUNT, total);
|
||||
dataMap.put(RESULT_LIST, list);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
public static Map<String, Object> buildDataMap(Set list) {
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
if (list == null) {
|
||||
dataMap.put(TOTAL_COUNT, 0);
|
||||
dataMap.put(RESULT_LIST, new ArrayList<>());
|
||||
} else {
|
||||
dataMap.put(TOTAL_COUNT, list.size());
|
||||
dataMap.put(RESULT_LIST, list);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
public static Map<String, Object> buildDataMap(Object object) {
|
||||
if (object == null) {
|
||||
return null;
|
||||
}
|
||||
List<Object> resultList = new ArrayList<>();
|
||||
resultList.add(object);
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put(TOTAL_COUNT, resultList.size());
|
||||
dataMap.put(RESULT_LIST, resultList);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +1,14 @@
|
||||
package com.supervision.service;
|
||||
|
||||
import com.supervision.dto.robot.RobotTalkDTO;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface IChatService {
|
||||
String talk(MultipartFile file);
|
||||
RobotTalkDTO talk(MultipartFile file);
|
||||
|
||||
void getAudio(HttpServletResponse response, String audioId) throws IOException;
|
||||
}
|
||||
|
Loading…
Reference in New Issue