import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ServiceVO, ServiceForm, ServiceQuery, ServiceOrderVO, ServiceOnStoreVo } from './types';

/**
 * 查询服务项目列表
 * @param query
 * @returns {*}
 */

export const listService = (query?: ServiceQuery): AxiosPromise<ServiceVO[]> => {
  return request({
    url: '/service/list/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询服务项目详细
 * @param id
 */
export const getService = (id: string | number): AxiosPromise<ServiceVO> => {
  return request({
    url: '/service/list/' + id,
    method: 'get'
  });
};

/**
 * 新增服务项目
 * @param data
 */
export const addService = (data: ServiceForm) => {
  return request({
    url: '/service/list',
    method: 'post',
    data: data
  });
};

/**
 * 修改服务项目
 * @param data
 */
export const updateService = (data: ServiceForm) => {
  return request({
    url: '/service/list',
    method: 'put',
    data: data
  });
};

/**
 * 删除服务项目
 * @param id
 */
export const delService = (id: string | number | Array<string | number>) => {
  return request({
    url: '/service/list/' + id,
    method: 'delete'
  });
};

/**
 * 获取所有服务项目
 * @returns {*}
 */
export const listAllService = (): AxiosPromise<ServiceVO[]> => {
  return request({
    url: '/service/list/listAll',
    method: 'get'
  });
};
