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

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.chatdocument.vo.ChatDocumentPageReqVO;
import com.cy.guoyan.admin.module.ai.dal.dataobject.chatdocument.ChatDocumentDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 知识库文档 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface ChatDocumentMapper extends BaseMapperX<ChatDocumentDO> {

    default PageResult<ChatDocumentDO> selectPage(ChatDocumentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ChatDocumentDO>()
                .betweenIfPresent(ChatDocumentDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ChatDocumentDO::getDifyDocumentId, reqVO.getDifyDocumentId())
                .eqIfPresent(ChatDocumentDO::getRagflowDocumentId, reqVO.getRagflowDocumentId())
                .eqIfPresent(ChatDocumentDO::getDatasetId, reqVO.getDatasetId())
                .eqIfPresent(ChatDocumentDO::getDataSourceType, reqVO.getDataSourceType())
                .eqIfPresent(ChatDocumentDO::getDataSourceInfo, reqVO.getDataSourceInfo())
                .eqIfPresent(ChatDocumentDO::getProcessRuleMode, reqVO.getProcessRuleMode())
                .likeIfPresent(ChatDocumentDO::getName, reqVO.getName())
                .eqIfPresent(ChatDocumentDO::getCreatedFrom, reqVO.getCreatedFrom())
                .eqIfPresent(ChatDocumentDO::getCreatedBy, reqVO.getCreatedBy())
                .eqIfPresent(ChatDocumentDO::getCreatedAt, reqVO.getCreatedAt())
                .eqIfPresent(ChatDocumentDO::getTokens, reqVO.getTokens())
                .eqIfPresent(ChatDocumentDO::getWordCount, reqVO.getWordCount())
                .eqIfPresent(ChatDocumentDO::getHitCount, reqVO.getHitCount())
                .eqIfPresent(ChatDocumentDO::getIndexingStatus, reqVO.getIndexingStatus())
                .eqIfPresent(ChatDocumentDO::getRagflowStatus, reqVO.getRagflowStatus())
                .eqIfPresent(ChatDocumentDO::getDisplayStatus, reqVO.getDisplayStatus())
                .eqIfPresent(ChatDocumentDO::getError, reqVO.getError())
                .eqIfPresent(ChatDocumentDO::getEnabled, reqVO.getEnabled())
                .eqIfPresent(ChatDocumentDO::getDisabledAt, reqVO.getDisabledAt())
                .eqIfPresent(ChatDocumentDO::getDisabledBy, reqVO.getDisabledBy())
                .eqIfPresent(ChatDocumentDO::getArchived, reqVO.getArchived())
                .eqIfPresent(ChatDocumentDO::getIndexingTechnique, reqVO.getIndexingTechnique())
                .eqIfPresent(ChatDocumentDO::getDocForm, reqVO.getDocForm())
                .eqIfPresent(ChatDocumentDO::getDocLanguage, reqVO.getDocLanguage())
                .eqIfPresent(ChatDocumentDO::getProcessRule, reqVO.getProcessRule())
                .eqIfPresent(ChatDocumentDO::getRetrievalModel, reqVO.getRetrievalModel())
                .eqIfPresent(ChatDocumentDO::getEmbeddingModel, reqVO.getEmbeddingModel())
                .eqIfPresent(ChatDocumentDO::getEmbeddingModelProvider, reqVO.getEmbeddingModelProvider())
                .orderByDesc(ChatDocumentDO::getId));
    }

}