package org.jk.rag.mapper;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jk.common.mybatis.core.mapper.BaseMapperPlus;
import org.jk.rag.domain.ModelConfig;
import org.jk.rag.domain.vo.ModelConfigVo;
import org.jk.system.domain.SysConfig;
import org.w3c.dom.stylesheets.LinkStyle;

import java.util.List;

/**
 * 模型配置Mapper接口
 *
 * @author Lion Li
 * @date 2026-01-19
 */
public interface ModelConfigMapper extends BaseMapperPlus<ModelConfig, ModelConfigVo> {
    @InterceptorIgnore(dataPermission = "true", tenantLine = "true")
    @Select("<script>" +
        " select * from sys_config where config_type = 'N'  " +
        "</script>")
    List<SysConfig> queryConfigTypeN();

    @InterceptorIgnore(dataPermission = "true", tenantLine = "true")
    @Update("<script>" +
        " update  sys_config set config_value = #{configValue} where config_key = #{configKey}  " +
        "</script>")
    void editSysConfig(@Param("configValue")String configValue,@Param("configKey")String configKey);

    @InterceptorIgnore(dataPermission = "true", tenantLine = "true")
    @Select("<script>" +
        " select DISTINCT sc.config_value model " +
        " ,sc2.config_value bindingModel " +
        " ,sc3.config_value embeddingModel " +
        " ,mc.max_token maxToken " +
        "from sys_config sc " +
        "left join sys_config sc2 on sc2.config_key = 'rerank_model' " +
        "left join sys_config sc3 on sc3.config_key = 'embedding_model' " +
        "left join model_config mc on sc.config_value = mc.model " +
        "where sc.config_key = 'model'  " +
        "</script>")
    List<ModelConfigVo> queryConfig();

}
