Commit 6bc1f8d0f949cd3f09d7b4d39f55633eb85f02f7
1 parent
37952c6a
【修复】AI:临时解决 send-stream 被权限拦截 Access Denied 问题
Showing
1 changed file
with
2 additions
and
0 deletions
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/AiChatMessageController.java
| @@ -7,6 +7,7 @@ import io.swagger.v3.oas.annotations.Operation; | @@ -7,6 +7,7 @@ import io.swagger.v3.oas.annotations.Operation; | ||
| 7 | import io.swagger.v3.oas.annotations.Parameter; | 7 | import io.swagger.v3.oas.annotations.Parameter; |
| 8 | import io.swagger.v3.oas.annotations.tags.Tag; | 8 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 9 | import jakarta.annotation.Resource; | 9 | import jakarta.annotation.Resource; |
| 10 | +import jakarta.annotation.security.PermitAll; | ||
| 10 | import lombok.extern.slf4j.Slf4j; | 11 | import lombok.extern.slf4j.Slf4j; |
| 11 | import org.springframework.http.MediaType; | 12 | import org.springframework.http.MediaType; |
| 12 | import org.springframework.validation.annotation.Validated; | 13 | import org.springframework.validation.annotation.Validated; |
| @@ -37,6 +38,7 @@ public class AiChatMessageController { | @@ -37,6 +38,7 @@ public class AiChatMessageController { | ||
| 37 | // TODO @fan:要不要使用 Flux 来返回;可以使用 Flux<AiChatMessageRespVO> | 38 | // TODO @fan:要不要使用 Flux 来返回;可以使用 Flux<AiChatMessageRespVO> |
| 38 | @Operation(summary = "发送消息(流式)", description = "流式返回,响应较快") | 39 | @Operation(summary = "发送消息(流式)", description = "流式返回,响应较快") |
| 39 | @PostMapping(value = "/send-stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE) | 40 | @PostMapping(value = "/send-stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE) |
| 41 | + @PermitAll // 解决 SSE 最终响应的时候,会被 Access Denied 拦截的问题 | ||
| 40 | public Flux<AiChatMessageRespVO> sendMessageStream(@Validated @RequestBody AiChatMessageSendStreamReqVO sendReqVO) { | 42 | public Flux<AiChatMessageRespVO> sendMessageStream(@Validated @RequestBody AiChatMessageSendStreamReqVO sendReqVO) { |
| 41 | return chatService.chatStream(sendReqVO); | 43 | return chatService.chatStream(sendReqVO); |
| 42 | } | 44 | } |