|
|
@@ -6,9 +6,11 @@ import com.goafanti.baiduAI.bo.SseMap;
|
|
|
import com.goafanti.baiduAI.bo.SseResult;
|
|
|
import com.goafanti.baiduAI.service.BaiduAiService;
|
|
|
import com.goafanti.common.bo.Result;
|
|
|
+import com.goafanti.common.bo.SseEmitterUTF8;
|
|
|
import com.goafanti.common.constant.ErrorConstants;
|
|
|
import com.goafanti.common.controller.BaseController;
|
|
|
import com.goafanti.common.controller.CertifyApiController;
|
|
|
+import com.goafanti.common.error.BusinessException;
|
|
|
import com.goafanti.common.model.AftUser;
|
|
|
import com.goafanti.common.utils.LoggerUtils;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
@@ -31,15 +33,17 @@ public class BaiduAiController {
|
|
|
private BaiduAiService baiduAiService;
|
|
|
|
|
|
@RequestMapping(value = "/send")
|
|
|
- public SseEmitter sendChat( InputSendChat in){
|
|
|
+ public SseEmitter sendChat(@RequestBody InputSendChat in){
|
|
|
if (in.getUserId()==null ){
|
|
|
-// in.setUserId(UUID.randomUUID().toString());
|
|
|
- in.setUserId("111");
|
|
|
+ in.setUserId(UUID.randomUUID().toString());
|
|
|
in.setStream(true);
|
|
|
}
|
|
|
- List<Messages> messages =new ArrayList<>();
|
|
|
- messages.add(new Messages("user","实用新型专利主要应用哪些领域?"));
|
|
|
- in.setMessages(messages);
|
|
|
+// List<Messages> messages =new ArrayList<>();
|
|
|
+// messages.add(new Messages("user","实用新型专利主要应用哪些领域?"));
|
|
|
+// in.setMessages(messages);
|
|
|
+ if (in.getMessages()==null||in.getMessages().isEmpty()){
|
|
|
+ throw new BusinessException("消息内容不能为空");
|
|
|
+ }
|
|
|
return baiduAiService.sendChat(in);
|
|
|
}
|
|
|
|
|
|
@@ -48,7 +52,7 @@ public class BaiduAiController {
|
|
|
@RequestMapping("/start")
|
|
|
public SseEmitter testSseEmitter(String clientId) {
|
|
|
// 默认30秒超时,设置为0L则永不超时
|
|
|
- SseEmitter sseEmitter = new SseEmitter(3600_000L);
|
|
|
+ SseEmitterUTF8 sseEmitter = new SseEmitterUTF8(3600_000L);
|
|
|
// if (clientId==null)clientId=UUID.randomUUID().toString();
|
|
|
SseMap.sseEmitterMap.put(clientId, new SseResult(clientId, System.currentTimeMillis(), sseEmitter));
|
|
|
return sseEmitter;
|