import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaintainInfoVO, MaintainInfoForm, MaintainInfoQuery, AllotTechnicalAdviserForm } from '@/api/customer/maintainInfo/types';

/**
 * 查询维保记录列表
 * @param query
 * @returns {*}
 */

export const listMaintainInfo = (query?: MaintainInfoQuery): AxiosPromise<MaintainInfoVO[]> => {
  return request({
    url: '/customer/maintainInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询维保记录详细
 * @param id
 */
export const getMaintainInfo = (id: string | number): AxiosPromise<MaintainInfoVO> => {
  return request({
    url: '/customer/maintainInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增维保记录
 * @param data
 */
export const addMaintainInfo = (data: MaintainInfoForm) => {
  return request({
    url: '/customer/maintainInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改维保记录
 * @param data
 */
export const updateMaintainInfo = (data: MaintainInfoForm) => {
  return request({
    url: '/customer/maintainInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除维保记录
 * @param id
 */
export const delMaintainInfo = (id: string | number | Array<string | number>) => {
  return request({
    url: '/customer/maintainInfo/' + id,
    method: 'delete'
  });
};

/**
 * 分配技术顾问
 * @param data
 */
export const allotTechnicalAdviser = (data: AllotTechnicalAdviserForm) => {
  return request({
    url: '/customer/maintainInfo/allotTechnicalAdviser',
    method: 'post',
    data: data
  });
};
