import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LiaisonVO, LiaisonForm, LiaisonQuery } from '@/api/customer/liaison/types';

/**
 * 查询联系人列表
 * @param query
 * @returns {*}
 */

export const listLiaison = (query?: LiaisonQuery & PageQuery): AxiosPromise => {
  return request({
    url: '/liaison/list',
    method: 'post',
    data: query
  });
};

/**
 * 查询联系人详细
 * @param id
 */
export const getLiaison = (id?: string | number, scopeMenuId?: string): AxiosPromise<LiaisonVO> => {
  return request({
    url: '/liaison/get-by-id',
    method: 'post',
    data: {
      id,
      scopeMenuId
    }
  });
};

/**
 * 新增联系人
 * @param data
 */
export const addLiaison = (data: LiaisonForm) => {
  return request({
    url: '/liaison/add',
    method: 'post',
    data: data
  });
};
/**
 * 新增联系人
 * @param data
 */
export const liaisonResourceAdd = (data: LiaisonForm) => {
  return request({
    url: '/liaison-resource/add',
    method: 'post',
    data: data
  });
};

/**
 * 删除联系人
 * @param id
 */
export const delLiaison = (id?: string | number | Array<string | number>) => {
  let data = typeof id == 'object' ? { ids: id } : { id }
  return request({
    url: '/liaison/delete',
    method: 'post',
    data
  });
};
