import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AreaVO, AreaForm, AreaQuery } from '@/api/supplier/area/types';

/**
 * 查询供应区域列表
 * @param query
 * @returns {*}
 */

export const listArea = (query?: AreaQuery): AxiosPromise<AreaVO[]> => {
  return request({
    url: '/customer/area/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询供应区域详细
 * @param id
 */
export const getArea = (id: string | number): AxiosPromise<AreaVO> => {
  return request({
    url: '/customer/area/' + id,
    method: 'get'
  });
};

/**
 * 新增供应区域
 * @param data
 */
export const addArea = (data: AreaForm) => {
  return request({
    url: '/customer/area',
    method: 'post',
    data: data
  });
};

/**
 * 修改供应区域
 * @param data
 */
export const updateArea = (data: AreaForm) => {
  return request({
    url: '/customer/area',
    method: 'put',
    data: data
  });
};

/**
 * 删除供应区域
 * @param id
 */
export const delArea = (id: string | number | Array<string | number>) => {
  return request({
    url: '/customer/area/' + id,
    method: 'delete'
  });
};


