import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CustomerDeptVO, CustomerDeptForm, CustomerDeptQuery } from '@/api/customer/customerFile/customerDept/types';

/**
 * 查询客户部门信息列表
 * @param query
 * @returns {*}
 */

export const listCustomerDept = (query?: CustomerDeptQuery): AxiosPromise<CustomerDeptVO[]> => {
  return request({
    url: '/customer/customerDept/tree',
    method: 'get',
    params: query
  });
};

/**
 * 查询客户部门信息详细
 * @param id
 */
export const getCustomerDept = (id: string | number): AxiosPromise<CustomerDeptVO> => {
  return request({
    url: '/customer/customerDept/' + id,
    method: 'get'
  });
};

/**
 * 新增客户部门信息
 * @param data
 */
export const addCustomerDept = (data: CustomerDeptForm) => {
  return request({
    url: '/customer/customerDept',
    method: 'post',
    data: data
  });
};

/**
 * 修改客户部门信息
 * @param data
 */
export const updateCustomerDept = (data: CustomerDeptForm) => {
  return request({
    url: '/customer/customerDept',
    method: 'put',
    data: data
  });
};

/**
 * 删除客户部门信息
 * @param id
 */
export const delCustomerDept = (id: string | number | Array<string | number>) => {
  return request({
    url: '/customer/customerDept/' + id,
    method: 'delete'
  });
};
