mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 02:08:43 +08:00 
			
		
		
		
	1、增加获取最新的对话
2、增加获取top100的对话
This commit is contained in:
		| @@ -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)") | ||||
|   | ||||
| @@ -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<AiChatConversation | ||||
|     @Update("update ai_chat_conversation set chat_count = chat_count + 1 where id = #{id}") | ||||
|     void updateIncrChatCount(@Param("id") Long id); | ||||
|  | ||||
|     /** | ||||
|      * 查询 - 最新的对话 | ||||
|      * | ||||
|      * @param loginUserId | ||||
|      */ | ||||
|     default AiChatConversationDO selectLatestConversation(Long loginUserId) { | ||||
|         PageResult<AiChatConversationDO> pageResult = selectPage(new PageParam().setPageNo(1).setPageSize(1), | ||||
|                 new LambdaQueryWrapper<AiChatConversationDO>() | ||||
|                         .eq(AiChatConversationDO::getUserId, loginUserId) | ||||
|                         .orderByDesc(AiChatConversationDO::getId)); | ||||
|         if (CollUtil.isEmpty(pageResult.getList())) { | ||||
|             return null; | ||||
|         } | ||||
|         return pageResult.getList().get(0); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 查询 - 前100 | ||||
|      * | ||||
|      * @param search | ||||
|      */ | ||||
|     default List<AiChatConversationDO> selectTop100Conversation(Long loginUserId, String search) { | ||||
|         LambdaQueryWrapper<AiChatConversationDO> queryWrapper | ||||
|                 = new LambdaQueryWrapper<AiChatConversationDO>().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(); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 cherishsince
					cherishsince