import request from 'libs/request'
import { getToken } from 'libs/token'

export function addCompany (data) {
  return request.post('company/add', data)
}

export function getCompanyDetail (companyId) {
  return request.get('company/getCompanyDetail', {params: {companyId}})
}

export function getCompanyList (params) {
  const defaultParams = {
    pageNum: 1,
    pageSize: 10,
    key: params.searchKey || '',
    token: getToken()
  }
  return request.get('company/getCompanyList', {params: Object.assign(defaultParams, params)})
}

export function updateCompany (data) {
  return request.post('company/update', data)
}

export function fetchAllScene (data) {
  const defaultParams = {
    page_num: 1,
    page_size: 999,
    searchKey: '',
    token: getToken()
  }
  return request.post('company/getAllScene', Object.assign(defaultParams, data))
}

export function getIndustry (params) {
  const defaultParams = {
    pageNum: 1,
    pageSize: 10,
    keyword: params.searchKey || '',
    token: getToken()
  }
  return request.get('activity/trade/queryOrGetTradeList', {params: Object.assign(defaultParams, params)})
}

export function createIndustry (data) {
  return request.post('activity/trade/add', data)
}

export function updateIndustry (data) {
  return request.post('activity/trade/update', data)
}