package com.cy.guoyan.admin.module.ai.dal.mysql.chatmessage;

import com.cy.guoyan.admin.framework.common.pojo.PageResult;
import com.cy.guoyan.admin.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cy.guoyan.admin.framework.mybatis.core.mapper.BaseMapperX;
import com.cy.guoyan.admin.module.ai.controller.admin.chatmessage.vo.ChatMessagePageReqVO;
import com.cy.guoyan.admin.module.ai.dal.dataobject.chatmessage.ChatMessageDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * AI聊天消息 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface ChatMessageMapper extends BaseMapperX<ChatMessageDO> {

    default PageResult<ChatMessageDO> selectPage(ChatMessagePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ChatMessageDO>()
                .eqIfPresent(ChatMessageDO::getSessionId, reqVO.getSessionId())
                .eqIfPresent(ChatMessageDO::getUserId, reqVO.getUserId())
                .eqIfPresent(ChatMessageDO::getRole, reqVO.getRole())
                .eqIfPresent(ChatMessageDO::getContent, reqVO.getContent())
                .betweenIfPresent(ChatMessageDO::getMessageTime, reqVO.getMessageTime())
                .eqIfPresent(ChatMessageDO::getDifyMessageId, reqVO.getDifyMessageId())
                .eqIfPresent(ChatMessageDO::getDifyTaskId, reqVO.getDifyTaskId())
                .eqIfPresent(ChatMessageDO::getDifyEvent, reqVO.getDifyEvent())
                .eqIfPresent(ChatMessageDO::getDifyConversationId, reqVO.getDifyConversationId())
                .eqIfPresent(ChatMessageDO::getCreatedTimestamp, reqVO.getCreatedTimestamp())
                .eqIfPresent(ChatMessageDO::getAgentThought, reqVO.getAgentThought())
                .eqIfPresent(ChatMessageDO::getAgentObservation, reqVO.getAgentObservation())
                .eqIfPresent(ChatMessageDO::getAgentTool, reqVO.getAgentTool())
                .eqIfPresent(ChatMessageDO::getAgentToolInput, reqVO.getAgentToolInput())
                .eqIfPresent(ChatMessageDO::getFileIds, reqVO.getFileIds())
                .eqIfPresent(ChatMessageDO::getFileUrls, reqVO.getFileUrls())
                .eqIfPresent(ChatMessageDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ChatMessageDO::getIsVisible, reqVO.getIsVisible())
                .eqIfPresent(ChatMessageDO::getMetadataJson, reqVO.getMetadataJson())
                .eqIfPresent(ChatMessageDO::getUsageJson, reqVO.getUsageJson())
                .eqIfPresent(ChatMessageDO::getResponseJson, reqVO.getResponseJson())
                .betweenIfPresent(ChatMessageDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(ChatMessageDO::getId));
    }

}