Commit bd8a139e by patrick

fix: send-stream api login error

parent e3730e94
......@@ -80,8 +80,10 @@ public class AiChatMessageController {
@PostMapping(value = "/send-stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
@PermitAll // 解决 SSE 最终响应的时候,会被 Access Denied 拦截的问题
public Flux<CommonResult<AiChatMessageSendRespVO>> sendChatMessageStream(@Valid @RequestBody AiChatMessageSendReqVO sendReqVO) throws MalformedURLException {
if (getLoginUserId() == null){
throw exception(USER_NOT_LOGIN);
Long userId = getLoginUserId();
if (userId == null) {
// 将错误包装在流中返回
return Flux.just(CommonResult.error(USER_NOT_LOGIN.getCode(), USER_NOT_LOGIN.getMsg()));
}
// 禁用ruoyi的上下文能力
sendReqVO.setUseContext(false);
......@@ -101,7 +103,7 @@ public class AiChatMessageController {
if (sendReqVO.getResponseChatItemId() == null) {
sendReqVO.setResponseChatItemId(generateBase62UniqueId(20));
}
return chatMessageService.sendChatMessageStream(sendReqVO, getLoginUserId(), originalUrls);
return chatMessageService.sendChatMessageStream(sendReqVO, userId, originalUrls);
}
@Operation(summary = "获得指定对话的消息列表")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment