package cn.iocoder.yudao.module.llm.dal.mysql.conversation;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.llm.dal.dataobject.conversation.ConversationDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.llm.controller.admin.conversation.vo.*;

/**
 * 大模型对话记录 Mapper
 *
 * @author 华大大模型
 */
@Mapper
public interface ConversationMapper extends BaseMapperX<ConversationDO> {

    default PageResult<ConversationDO> selectPage(ConversationPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ConversationDO>()
                .eqIfPresent(ConversationDO::getRole, reqVO.getRole())
                .eqIfPresent(ConversationDO::getContent, reqVO.getContent())
                .eqIfPresent(ConversationDO::getModelParams, reqVO.getModelParams())
                .eqIfPresent(ConversationDO::getPrompt, reqVO.getPrompt())
                .eqIfPresent(ConversationDO::getKnowledgeBaseId, reqVO.getKnowledgeBaseId())
                .eqIfPresent(ConversationDO::getApplicationId, reqVO.getApplicationId())
                .eqIfPresent(ConversationDO::getModelServiceId, reqVO.getModelServiceId())
                .betweenIfPresent(ConversationDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ConversationDO::getId));
    }

}