diff --git a/pom.xml b/pom.xml
index aec6e8e..ec6cd2d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,6 +59,11 @@
hutool-all
5.8.26
+
+ org.mortbay.jetty
+ servlet-api
+ 9.0.83
+
diff --git a/src/main/java/com/supervision/contoller/ChatController.java b/src/main/java/com/supervision/contoller/ChatController.java
index b0dce0d..e40c65a 100644
--- a/src/main/java/com/supervision/contoller/ChatController.java
+++ b/src/main/java/com/supervision/contoller/ChatController.java
@@ -1,11 +1,17 @@
package com.supervision.contoller;
+import com.supervision.dto.R;
+import com.supervision.dto.robot.RobotTalkDTO;
import com.supervision.service.IChatService;
+import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
@Slf4j
@RestController
@RequestMapping("/chat")
@@ -15,7 +21,19 @@ public class ChatController {
private final IChatService chatService;
@PostMapping("/talk")
- public String talk(@RequestParam("file") MultipartFile multipartFile) {
- return chatService.talk(multipartFile);
+ public R talk(@RequestParam("file") MultipartFile multipartFile) {
+ RobotTalkDTO talk = chatService.talk(multipartFile);
+ return R.ok(talk);
+ }
+
+ @GetMapping("/talkList")
+ public List talkList(String sessionId) {
+ return new ArrayList();
+ }
+
+ @GetMapping("/getAudio")
+ public void getAudio(HttpServletResponse response,
+ @RequestParam("audioId")String audioId) throws IOException {
+ chatService.getAudio(response,audioId);
}
}
diff --git a/src/main/java/com/supervision/dto/R.java b/src/main/java/com/supervision/dto/R.java
new file mode 100644
index 0000000..cfc1f9c
--- /dev/null
+++ b/src/main/java/com/supervision/dto/R.java
@@ -0,0 +1,132 @@
+package com.supervision.dto;
+
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * 响应信息主体
+ *
+ * @author qimaoyu
+ */
+@Data
+public class R 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 R ok() {
+ return restResult(null, SUCCESS, null);
+ }
+
+ public static R judgeResult(Boolean bo, String successMessage, String failMessage) {
+ if (bo) {
+ return restResult(null, SUCCESS, successMessage);
+ } else {
+ return restResult(null, FAIL, failMessage);
+ }
+ }
+
+ public static R okMsg(String msg) {
+ return restResult(null, SUCCESS, msg);
+ }
+
+ public static R ok(T data) {
+ return restResult(data, SUCCESS, null);
+ }
+
+ public static R ok(T data, String msg) {
+ return restResult(data, SUCCESS, msg);
+ }
+
+ public static R fail() {
+ return restResult(null, FAIL, null);
+ }
+
+ public static R fail(String msg) {
+ return restResult(null, FAIL, msg);
+ }
+
+ public static R fail(T data) {
+ return restResult(data, FAIL, null);
+ }
+
+ public static R fail(int code, String msg) {
+ return restResult(null, code, msg);
+ }
+
+
+
+ private static R restResult(T data, int code, String msg) {
+ R apiResult = new R<>();
+ apiResult.setCode(code);
+ apiResult.setData(data);
+ apiResult.setMsg(msg);
+ return apiResult;
+ }
+
+
+ public static Map buildDataMap(List list) {
+ Map 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 buildDataMap(List list, Long total) {
+ Map dataMap = new HashMap<>();
+ dataMap.put(TOTAL_COUNT, total);
+ dataMap.put(RESULT_LIST, list);
+ return dataMap;
+ }
+
+ public static Map buildDataMap(Set list) {
+ Map 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 buildDataMap(Object object) {
+ if (object == null) {
+ return null;
+ }
+ List