mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-30 11:11:55 +08:00
增加message list 查询
This commit is contained in:
parent
64fdd045a5
commit
6b8174a5a6
@ -21,8 +21,10 @@ public interface ErrorCodeConstants {
|
||||
|
||||
|
||||
|
||||
ErrorCode AI_CHAT_CONTINUE_NOT_EXIST = new ErrorCode(1_022_000_020, "chat对话不存在!");;
|
||||
ErrorCode AI_CHAT_ROLE_NOT_EXIST = new ErrorCode(1_022_000_020, "chatRole不存在!");;
|
||||
ErrorCode AI_CHAT_CONTINUE_NOT_EXIST = new ErrorCode(1_022_000_020, "chat对话不存在!");
|
||||
ErrorCode AI_CHAT_CONVERSATION_NOT_YOURS = new ErrorCode(1_022_000_021, "这条chat对话不是你的!");
|
||||
|
||||
ErrorCode AI_CHAT_ROLE_NOT_EXIST = new ErrorCode(1_022_000_040, "chatRole不存在!");
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.ai.convert;
|
||||
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatMessageDO;
|
||||
import cn.iocoder.yudao.module.ai.vo.ChatMessageListRes;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 聊天 对话 convert
|
||||
*
|
||||
* @author fansili
|
||||
* @time 2024/4/18 16:39
|
||||
* @since 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface ChatMessageConvert {
|
||||
|
||||
ChatMessageConvert INSTANCE = Mappers.getMapper(ChatMessageConvert.class);
|
||||
|
||||
/**
|
||||
* 转换 ChatMessageListRes
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
List<ChatMessageListRes> convert(List<AiChatMessageDO> list);
|
||||
}
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.ai.mapper;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatMessageDO;
|
||||
import cn.iocoder.yudao.module.ai.vo.ChatMessageReq;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@ -28,4 +29,5 @@ public interface AiChatMessageMapper extends BaseMapperX<AiChatMessageDO> {
|
||||
.eq(AiChatMessageDO::getId, id)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,12 @@ package cn.iocoder.yudao.module.ai.service.impl;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.ai.ErrorCodeConstants;
|
||||
import cn.iocoder.yudao.module.ai.convert.ChatMessageConvert;
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatConversationDO;
|
||||
import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatMessageDO;
|
||||
import cn.iocoder.yudao.module.ai.mapper.AiChatConversationMapper;
|
||||
import cn.iocoder.yudao.module.ai.mapper.AiChatMessageMapper;
|
||||
import cn.iocoder.yudao.module.ai.service.ChatMessageService;
|
||||
@ -14,6 +17,8 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* chat message
|
||||
*
|
||||
@ -31,7 +36,15 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
||||
|
||||
@Override
|
||||
public PageResult<ChatMessageListRes> list(ChatMessageReq req) {
|
||||
return null;
|
||||
// 查询
|
||||
LambdaQueryWrapperX<AiChatMessageDO> queryWrapperX = new LambdaQueryWrapperX<>();
|
||||
queryWrapperX.eq(AiChatMessageDO::getChatConversationId, req.getChatConversationId());
|
||||
// 默认排序
|
||||
queryWrapperX.orderByDesc(AiChatMessageDO::getId);
|
||||
PageResult<AiChatMessageDO> pageResult = aiChatMessageMapper.selectPage(req, queryWrapperX);
|
||||
// 转换 res
|
||||
List<ChatMessageListRes> messageListResList = ChatMessageConvert.INSTANCE.convert(pageResult.getList());
|
||||
return new PageResult(messageListResList, pageResult.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.ai.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
@ -14,7 +15,7 @@ import lombok.experimental.Accessors;
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ChatMessageReq {
|
||||
public class ChatMessageReq extends PageParam {
|
||||
|
||||
@Schema(description = "聊天ID,关联到特定的会话或对话")
|
||||
@NotNull
|
||||
|
Loading…
Reference in New Issue
Block a user