Commit e3730e94 by patrick

fix: 修复登陆信息失效返回错误

parent 88efbb4f
...@@ -109,8 +109,12 @@ public class AiChatMessageController { ...@@ -109,8 +109,12 @@ public class AiChatMessageController {
@Parameter(name = "conversationId", required = true, description = "对话编号", example = "1024") @Parameter(name = "conversationId", required = true, description = "对话编号", example = "1024")
public CommonResult<List<AiChatMessageRespVO>> getChatMessageListByConversationId( public CommonResult<List<AiChatMessageRespVO>> getChatMessageListByConversationId(
@RequestParam("conversationId") Long conversationId) { @RequestParam("conversationId") Long conversationId) {
Long userId = getLoginUserId();
if (userId == null){
throw exception(USER_NOT_LOGIN);
}
AiChatConversationDO conversation = chatConversationService.getChatConversation(conversationId); AiChatConversationDO conversation = chatConversationService.getChatConversation(conversationId);
if (conversation == null || ObjUtil.notEqual(conversation.getUserId(), getLoginUserId())) { if (conversation == null || ObjUtil.notEqual(conversation.getUserId(), userId)) {
return success(Collections.emptyList()); return success(Collections.emptyList());
} }
List<AiChatMessageDO> messageList = chatMessageService.getChatMessageListByConversationId(conversationId); List<AiChatMessageDO> messageList = chatMessageService.getChatMessageListByConversationId(conversationId);
......
...@@ -156,7 +156,7 @@ public class AiChatMessageServiceImpl implements AiChatMessageService { ...@@ -156,7 +156,7 @@ public class AiChatMessageServiceImpl implements AiChatMessageService {
chatMessageMapper.insert(assistantMessage); chatMessageMapper.insert(assistantMessage);
}); });
}).doOnError(throwable -> { }).doOnError(throwable -> {
log.error("[sendChatMessageStream][userId({}) sendReqVO({}) 发生异常]", userId, sendReqVO, throwable); // log.error("[sendChatMessageStream][userId({}) sendReqVO({}) 发生异常]", userId, sendReqVO, throwable);
// 忽略租户,因为 Flux 异步无法透传租户 // 忽略租户,因为 Flux 异步无法透传租户
// TenantUtils.executeIgnore(() -> // TenantUtils.executeIgnore(() ->
// chatMessageMapper.updateById(new AiChatMessageDO().setId(assistantMessage.getId()).setContent(throwable.getMessage()))); // chatMessageMapper.updateById(new AiChatMessageDO().setId(assistantMessage.getId()).setContent(throwable.getMessage())));
...@@ -164,6 +164,7 @@ public class AiChatMessageServiceImpl implements AiChatMessageService { ...@@ -164,6 +164,7 @@ public class AiChatMessageServiceImpl implements AiChatMessageService {
assistantMessage.setContent(throwable.getMessage()); assistantMessage.setContent(throwable.getMessage());
chatMessageMapper.insert(assistantMessage); chatMessageMapper.insert(assistantMessage);
}); });
throw exception(ErrorCodeConstants.CHAT_STREAM_ERROR);
}).onErrorResume(error -> Flux.just(error(ErrorCodeConstants.CHAT_STREAM_ERROR))); }).onErrorResume(error -> Flux.just(error(ErrorCodeConstants.CHAT_STREAM_ERROR)));
} }
......
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