import axios from '@/common/services/axios-instance'

class FullsearchService {
  // 搜索结果
  getSearchList(params) {
    return axios({
      url: 'api/xcoa-mobile/v1/ftsearch/search-list',
      method: 'post',
      data: params,
    })
  }

  // 业务类型分类树
  getCategoryList(params) {
    return axios({
      url: 'api/xcoa-mobile/v1/ftsearch/visiblesource',
      method: 'get',
      params,
    })
  }

  // 获取搜索分类
  getSearchCategory() {
    return axios({
      url: 'api/xcoa-mobile/v1/ftsearch/ssearch-condition',
      method: 'get',
    })
  }

  // 获取个人常用搜索数据
  getPersonalSearch() {
    return axios({
      url: 'api/xcoa-mobile/v1/ftsearch/record/search-record',
      method: 'get',
    })
  }

  // 获取热门搜索数据
  getHotSearch() {
    return axios({
      url: 'api/xcoa-mobile/v1/ftsearch/record/hotwords',
      method: 'get',
    })
  }

  // 搜索结果详情/导出url
  toSearchresultDetails() {
    return axios({
      url: 'api/xcoa-mobile/v1/ftsearch/open-document',
      method: 'get',
    })
  }

  // 导出文档
  searchExport(params) {
    return axios({
      url: `api/xcoa-mobile/v1/ftsearch/export`,
      method: 'post',
      data: params,
    }).then((res) => {
      return res.data
    })
  }

  // 导出下载
  exportDownload(params) {
    return axios({
      url: 'api/xcoa-mobile/v1/file-download/download/',
      method: 'get',
      responseType: 'blob',
      params,
    }).then((res) => {
      return res.data
    })
  }

  // 输入框提示
  seachInputTip(text) {
    return axios({
      url: `api/xcoa-mobile/v1/ftsearch/record/suggester?text=${text}`,
      method: 'get',
    })
  }

  // 应用
  applySearch(text) {
    return axios({
      url: `api/xcoa-mobile/v1/ftsearch/app-search?text=${text}`,
      method: 'get',
    })
  }

  // 获取历史搜索数据
  getHistoryData() {
    return axios({
      url: `api/xcoa-mobile/v1/ftsearch/record/recent-search`,
      method: 'get',
    })
  }

  // 删除选中的历史搜索数据
  deleteSearchItem(text) {
    return axios({
      url: `api/xcoa-mobile/v1/ftsearch/record/delete-record?recordWord=${text}`,
      method: 'get',
    })
  }
}

export default new FullsearchService()
