package cn.com.ty.lift.ud.searchIndex.mapper;


import cn.com.ty.lift.ud.searchIndex.mapper.entity.SearchIndexEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 搜索索引表-Repository
 * 
 * @author Xson
 * @date 2020-05-09
 */
public interface SearchIndexMapper extends BaseMapper<SearchIndexEntity> {

    /**
     * 搜索索引
     * @param word
     * @return
     */
    @Select("select * from search_index where key_word like '%${word}%'")
    List<SearchIndexEntity> selectByKeyWord(@Param("word") String word);

    /**
     * 查询对应表的数据
     * @param tableName
     * @param tableId
     */
    @Select("select * from ${tableName} where id = #{tableId}")
    Map<String,Object> getInfo(@Param("tableName") String tableName, @Param("tableId") Long tableId);


    /**
     * 根据模块ID 和 数据主键ID 删除索引信息
     * @param moduleId  模块ID
     * @param id  数据主键ID
     */
    @Delete("delete from search_index where module_id = #{moduleId} and table_id = #{id}")
    void deleteByIdAndModuleId(@Param("moduleId") Integer moduleId, @Param("id") Long id);
}
