59 lines
1.7 KiB
Java
59 lines
1.7 KiB
Java
package com.supervision.controller;
|
|
|
|
import com.supervision.pojo.vo.ReplyVoiceResVO;
|
|
import com.supervision.service.AskService;
|
|
import com.supervision.websocket.cache.WebSocketUserCache;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.socket.TextMessage;
|
|
import org.springframework.web.socket.WebSocketSession;
|
|
|
|
import java.io.IOException;
|
|
import java.util.List;
|
|
|
|
@Api(tags = "问诊")
|
|
@RestController
|
|
@RequestMapping("/ask/")
|
|
public class AskController {
|
|
|
|
@Autowired
|
|
private AskService askService;
|
|
|
|
|
|
@ApiOperation("发送消息到页面")
|
|
@GetMapping("/sendMessage")
|
|
public void sendMessage(String message, String sessionId) throws IOException {
|
|
WebSocketSession session = WebSocketUserCache.getSession(sessionId);
|
|
session.sendMessage(new TextMessage(message));
|
|
}
|
|
|
|
@ApiOperation("接收页面的语音消息")
|
|
@PostMapping("/receiveVoiceFile")
|
|
public String receiveVoiceFile(@RequestParam("file") MultipartFile file) throws IOException {
|
|
return askService.receiveVoiceFile(file);
|
|
}
|
|
|
|
@ApiOperation("回复语音及文字消息")
|
|
@GetMapping("replyVoice")
|
|
public ReplyVoiceResVO replyVoice() {
|
|
return askService.replyVoice();
|
|
}
|
|
|
|
@ApiOperation("进行对话")
|
|
@GetMapping("conversation")
|
|
public List<String> conversation(String question) {
|
|
return askService.conversation(question);
|
|
}
|
|
|
|
@ApiOperation("查询对话历史")
|
|
public void queryAskHistory(String processId) {
|
|
|
|
}
|
|
|
|
|
|
}
|