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(); + } }