import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SysServiceVO, SysServiceForm, SysServiceQuery } from '@/api/store/sysService/types';

/**
 * 查询客服信息列表
 * @param query
 * @returns {*}
 */

export const listSysService = (query?: SysServiceQuery): AxiosPromise<SysServiceVO[]> => {
  return request({
    url: '/system/sysService/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询客服信息详细
 * @param id
 */
export const getSysService = (id: string | number): AxiosPromise<SysServiceVO> => {
  return request({
    url: '/system/sysService/' + id,
    method: 'get'
  });
};

/**
 * 设为默认客服
 * @param id
 */
export const setDefault = (id: string | number): AxiosPromise<SysServiceVO> => {
  return request({
    url: '/system/sysService/setDefault/' + id,
    method: 'get'
  });
};

/**
 * 新增客服信息
 * @param data
 */
export const addSysService = (data: SysServiceForm) => {
  return request({
    url: '/system/sysService',
    method: 'post',
    data: data
  });
};

/**
 * 修改客服信息
 * @param data
 */
export const updateSysService = (data: SysServiceForm) => {
  return request({
    url: '/system/sysService',
    method: 'put',
    data: data
  });
};

/**
 * 删除客服信息
 * @param id
 */
export const delSysService = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/sysService/' + id,
    method: 'delete'
  });
};
