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

const apiPrefix = '/api/choice/reviews/';

export function getChartData(query: any) {
  return request({
    url: '/api/choice/reviews/stat_avg_score/',
    method: 'GET',
    params: query
  });
}

export function getTableData(query: any) {
  return request({
    url: apiPrefix,
    method: 'GET',
    params: query
  });
}

export function createComment(body: any) {
  return request({
    url: apiPrefix,
    method: 'POST',
    data: body
  });
}

export function exportData(query: any) {
  return request({
    url: apiPrefix + 'export_data/',
    method: 'GET',
    params: query,
    responseType: 'blob'
  });
}

//负面标签
export function getNegativeTags(query: any) {
  return request({
    url: '/api/choice/reviews_labels/',
    method: 'GET',
    params: query
  });
}

export function createNegativeTags(body: any) {
  return request({
    url: '/api/choice/reviews_labels/',
    method: 'POST',
    data: body
  });
}

export function updateNegativeTags(body: any){
  return request({
    url: '/api/choice/reviews_labels/' +`${body.id}/` ,
    method: 'PUT',
    data: body
  });
}

export function deleteNegativeTags(body: any) {
  return request({
    url: '/api/choice/reviews_labels/' + `${body.id}/` ,
    method: 'DELETE',
    data: body
  });
}

export function getWordCloudData(query: any) {
  return request({
    url: '/api/choice/reviews_labels/agg/',
    method: 'GET',
    params: query
  });
}

export function getBarChartData(query: any) {
  return request({
    url: '/api/choice/reviews_labels/agg/',
    method: 'GET',
    params: query
  });
}


export function getLineChartData(query: any) {
  return request({
    url: '/api/choice/reviews_labels/agg/',
    method: 'GET',
    params: query
  });
}
