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


import cn.com.ty.lift.ud.searchHistory.mapper.entity.SearchHistoryEntity;
import cn.com.xwy.boot.web.dto.RestResponse;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 搜索历史表-Repository
 * 
 * @author tw
 * @date 2020-11-17
 */
public interface SearchHistoryMapper extends BaseMapper<SearchHistoryEntity> {

    /**
     * 获取热门搜索
     * @return
     */
    @Select(value = "select * from search_history order by search_times desc limit 0,10")
    List<SearchHistoryEntity> getHotSearch();

    @Select(value = "select * from search_history where key_word = #{request}")
    SearchHistoryEntity getByKeyWord(String request);

    @Update("update search_history set search_times = search_times + 1 where key_word = #{request}")
    void updateTimes(String request);
}
