import { request } from '/@/utils/service';

const apiPrefix = '/api/searchterm/';

export function getSearchTermList(query: any) {
  return request({
    url: apiPrefix + 'topsearchtermroot/',
    method: 'GET',
    params: query,
  });
}

export function postCreateSearchTerm(body: any) {
  return request({
    url: apiPrefix + 'topsearchtermroot/',
    method: 'POST',
    data: body,
  });
}

export function deleteSearchTerm(body: any) {
  return request({
    url: apiPrefix + `topsearchtermrootdelete/${body}/`,
    method: 'POST',
  });
}

export function postUpdateSearchTerm(body: any) {
  return request({
    url: apiPrefix + `topsearchtermrootupdate/${body.id}/`,
    method: 'POST',
    data: body.data,
  });
}

export function uploadFile(file: any) {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: apiPrefix + 'topsearchtermrootupload/',
    method: 'POST',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
}
