package org.jk.rag.mapper;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jk.rag.domain.entity.JkKnowledge;
import org.jk.rag.domain.entity.VipKnowledge;
import org.jk.rag.domain.vo.KnowledgeSliceVo;

import java.util.List;

/**
 * 高井 知识库列表
 *
 * @author takai
 */
public interface JkKnowledgeMapper
{
    /**
     * 根据条件分页查询知识库信息
     *
     * @param mData 知识库信息
     * @return 知识库信息
     */
    public List<JkKnowledge> selectKnowledgeList(JkKnowledge mData);


    @InterceptorIgnore(tenantLine = "true", dataPermission = "false")
    public List<JkKnowledge> selectAllKnowledgeList(JkKnowledge mData);
    /**
     * 查询唯一知识库信息
     * @param mData
     * @return
     */
    public JkKnowledge selectTargetKnowledge(JkKnowledge mData);


    /**
     * 新增知识库信息
     *
     * @param mData 知识库信息
     * @return 结果
     */
    public int insertKnowledge(JkKnowledge mData);

    /**
     * 更新知识库信息
     *
     * @param mData 知识库信息
     * @return 结果
     */
    public int updateKnowledge(JkKnowledge mData);

    int delKnowledge(String knowledgeId);

    public int insertVipKnowledge(VipKnowledge mData);

    public int deleteVipByknowledgeId(String appId);

    public Page<JkKnowledge> selectKnowledgePageList( @Param("ew")JkKnowledge mData, @Param("page") Page page);

    @Select("<script>" +
        "select slice.document_id documentId" +
        ",slice.knowledge_id knowledgeId " +
        ",knowledge.name knowledgeName " +
        ",document.name documentName " +
        ",slice.slice_text sliceText " +
        " from bm_document document " +
        " left join bm_knowledge knowledge on document.knowledge_id = knowledge.knowledge_id" +
        " left join slice_info slice on document.document_id = slice.document_id " +
        " where slice.knowledge_id = #{knowledgeId} " +
        " order by slice.document_id,slice.slice_index " +
        "</script>")
    List<KnowledgeSliceVo> selectExportKnowledgeSlice(@Param("knowledgeId") String knowledgeId);

    @InterceptorIgnore(tenantLine = "true", dataPermission = "false")
    @Select("<script>" +
        "select knowledge_id " +
        " from bm_knowledge  " +
        "</script>")
    List<String> getKnowledgeIds();
}
