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

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

/**
 * 知识库 Mapper
 *
 * @author 华大大模型
 */
@Mapper
public interface KnowledgeBaseMapper extends BaseMapperX<KnowledgeBaseDO> {

    default PageResult<KnowledgeBaseDO> selectPage(KnowledgeBasePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<KnowledgeBaseDO>()
                .likeIfPresent(KnowledgeBaseDO::getKnowledgeBaseName, reqVO.getKnowledgeBaseName())
                .eqIfPresent(KnowledgeBaseDO::getKnowledgeBaseIntro, reqVO.getKnowledgeBaseIntro())
                .eqIfPresent(KnowledgeBaseDO::getKnowledgeBaseLogo, reqVO.getKnowledgeBaseLogo())
                .betweenIfPresent(KnowledgeBaseDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(KnowledgeBaseDO::getTopK, reqVO.getTopK())
                .eqIfPresent(KnowledgeBaseDO::getScore, reqVO.getScore())
                .eqIfPresent(KnowledgeBaseDO::getKnowledgeLength, reqVO.getKnowledgeLength())
                .eqIfPresent(KnowledgeBaseDO::getKnowledgeFile, reqVO.getKnowledgeFile())
                .orderByDesc(KnowledgeBaseDO::getId));
    }

}
