package org.jk.rag.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jk.common.mybatis.core.mapper.BaseMapperPlus;
import org.jk.rag.domain.EvaluationTask;
import org.jk.rag.domain.vo.EvaluationTaskVo;

/**
 *  数据层
 *
 * @author jk
 */
public interface JkEvaluationTaskMapper extends BaseMapperPlus<EvaluationTask, EvaluationTaskVo> {

    @Select("<script>" +
        "select " +
        " et.task_id taskId," +
        " et.task_name taskName," +
        " et.task_description taskDescription," +
        " et.evaluation_type evaluationType," +
        " et.review_rag reviewRag," +
        " et.model," +
        " et.evaluation_data evaluationData," +
        " et.status," +
        " et.result_store resultStore," +
        " et.answer_loyalty answerLoyalty," +
        " et.correct_answer correctAnswer," +
        " et.answer_relevance answerRelevance," +
        " et.noise_sensitivity noiseSensitivity," +
        " et.context_recall contextRecall," +
        " et.context_relevance contextRelevance," +
        " et.del_flag delFlag," +
        " et.update_by updateBy," +
        " et.create_time createTime," +
        " et.update_time updateTime," +
        " et.start_time startTime," +
        " et.end_time endTime," +
        " et.create_by createBy," +
        " d.name datesetName," +
        " et.embedding_id embeddingId" +
        " from evaluation_task et " +
        " left join dataset d on et.evaluation_data = d.id " +
        "  where 1 = 1 " +
        " <if test='name != null and name != \"\"'> " +
        " AND task_name like concat('%',#{name},'%') " +
        " </if>" +
        " order by et.create_time desc " +
        "</script>")
    Page<EvaluationTaskVo> selectPageList(@Param("name") String name, @Param("page") Page page);

    @Select("<script>" +
        "select " +
        " count(*)" +
        " from evaluation_task " +
        "  where 1 = 1 " +
        " <if test='taskName != null and taskName != \"\"'> " +
        " AND task_name = #{taskName} " +
        " </if>" +
        "</script>")
    Integer checkName(@Param("taskName") String taskName);
}
