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

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

/**
 * AI 知识库 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface ChatKnowledgeDatasetMapper extends BaseMapperX<ChatKnowledgeDatasetDO> {

    default PageResult<ChatKnowledgeDatasetDO> selectPage(ChatKnowledgeDatasetPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ChatKnowledgeDatasetDO>()
                .betweenIfPresent(ChatKnowledgeDatasetDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ChatKnowledgeDatasetDO::getDifyDatasetId, reqVO.getDifyDatasetId())
                .likeIfPresent(ChatKnowledgeDatasetDO::getName, reqVO.getName())
                .eqIfPresent(ChatKnowledgeDatasetDO::getDescription, reqVO.getDescription())
                .eqIfPresent(ChatKnowledgeDatasetDO::getIndexingTechnique, reqVO.getIndexingTechnique())
                .eqIfPresent(ChatKnowledgeDatasetDO::getEmbeddingModel, reqVO.getEmbeddingModel())
                .betweenIfPresent(ChatKnowledgeDatasetDO::getAutoUpdate, reqVO.getAutoUpdate())
                .eqIfPresent(ChatKnowledgeDatasetDO::getEnabled, reqVO.getEnabled())
                .eqIfPresent(ChatKnowledgeDatasetDO::getDefaultPermission, reqVO.getDefaultPermission())
                .eqIfPresent(ChatKnowledgeDatasetDO::getAppCount, reqVO.getAppCount())
                .eqIfPresent(ChatKnowledgeDatasetDO::getDifyCreatedAt, reqVO.getDifyCreatedAt())
                .eqIfPresent(ChatKnowledgeDatasetDO::getDifyUpdatedAt, reqVO.getDifyUpdatedAt())
                .eqIfPresent(ChatKnowledgeDatasetDO::getMetadataJson, reqVO.getMetadataJson())
                .orderByDesc(ChatKnowledgeDatasetDO::getId));
    }

}