From 66d020892019ead137c71a9263c2b99ca0103a3c Mon Sep 17 00:00:00 2001 From: cherishsince Date: Thu, 18 Apr 2024 16:59:46 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=9A=84=E5=AF=B9=E8=AF=9D=202=E3=80=81?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96top100=E7=9A=84=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai/dataobject/AiChatConversationDO.java | 4 +- .../ai/mapper/AiChatConversationMapper.java | 37 +++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dataobject/AiChatConversationDO.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dataobject/AiChatConversationDO.java index 8f1956392..c48baa1c6 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dataobject/AiChatConversationDO.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dataobject/AiChatConversationDO.java @@ -30,10 +30,10 @@ public class AiChatConversationDO extends BaseDO { @Schema(description = "chat角色名称") private String chatRoleName; - @Schema(description = "对话标题(有程序自动生成)") + @Schema(description = "聊天标题(有程序自动生成)") private String chatTitle; - @Schema(description = "对话标题(有程序自动生成)") + @Schema(description = "聊天次数(有程序自动生成)") private Integer chatCount; @Schema(description = "对话类型(roleChat、userChat)") diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/mapper/AiChatConversationMapper.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/mapper/AiChatConversationMapper.java index 6e018a892..f6f58e7a0 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/mapper/AiChatConversationMapper.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/mapper/AiChatConversationMapper.java @@ -1,12 +1,19 @@ package cn.iocoder.yudao.module.ai.mapper; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.module.ai.dataobject.AiChatConversationDO; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Update; import org.springframework.stereotype.Repository; +import java.util.List; + /** * message mapper * @@ -21,4 +28,34 @@ public interface AiChatConversationMapper extends BaseMapperX pageResult = selectPage(new PageParam().setPageNo(1).setPageSize(1), + new LambdaQueryWrapper() + .eq(AiChatConversationDO::getUserId, loginUserId) + .orderByDesc(AiChatConversationDO::getId)); + if (CollUtil.isEmpty(pageResult.getList())) { + return null; + } + return pageResult.getList().get(0); + } + + /** + * 查询 - 前100 + * + * @param search + */ + default List selectTop100Conversation(Long loginUserId, String search) { + LambdaQueryWrapper queryWrapper + = new LambdaQueryWrapper().eq(AiChatConversationDO::getUserId, loginUserId); + if (!StrUtil.isBlank(search)) { + queryWrapper.like(AiChatConversationDO::getChatTitle, search); + } + queryWrapper.orderByDesc(AiChatConversationDO::getId); + return selectPage(new PageParam().setPageNo(1).setPageSize(100), queryWrapper).getList(); + } }