Commit bd8a139e by patrick

fix: send-stream api login error

parent e3730e94
...@@ -80,8 +80,10 @@ public class AiChatMessageController { ...@@ -80,8 +80,10 @@ public class AiChatMessageController {
@PostMapping(value = "/send-stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE) @PostMapping(value = "/send-stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
@PermitAll // 解决 SSE 最终响应的时候,会被 Access Denied 拦截的问题 @PermitAll // 解决 SSE 最终响应的时候,会被 Access Denied 拦截的问题
public Flux<CommonResult<AiChatMessageSendRespVO>> sendChatMessageStream(@Valid @RequestBody AiChatMessageSendReqVO sendReqVO) throws MalformedURLException { public Flux<CommonResult<AiChatMessageSendRespVO>> sendChatMessageStream(@Valid @RequestBody AiChatMessageSendReqVO sendReqVO) throws MalformedURLException {
if (getLoginUserId() == null){ Long userId = getLoginUserId();
throw exception(USER_NOT_LOGIN); if (userId == null) {
// 将错误包装在流中返回
return Flux.just(CommonResult.error(USER_NOT_LOGIN.getCode(), USER_NOT_LOGIN.getMsg()));
} }
// 禁用ruoyi的上下文能力 // 禁用ruoyi的上下文能力
sendReqVO.setUseContext(false); sendReqVO.setUseContext(false);
...@@ -101,7 +103,7 @@ public class AiChatMessageController { ...@@ -101,7 +103,7 @@ public class AiChatMessageController {
if (sendReqVO.getResponseChatItemId() == null) { if (sendReqVO.getResponseChatItemId() == null) {
sendReqVO.setResponseChatItemId(generateBase62UniqueId(20)); sendReqVO.setResponseChatItemId(generateBase62UniqueId(20));
} }
return chatMessageService.sendChatMessageStream(sendReqVO, getLoginUserId(), originalUrls); return chatMessageService.sendChatMessageStream(sendReqVO, userId, originalUrls);
} }
@Operation(summary = "获得指定对话的消息列表") @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