import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ClassificationVO, ClassificationForm, ClassificationQuery } from '@/api/service/classification/types';

/**
 * 查询服务分类列表
 * @param query
 * @returns {*}
 */

export const listClassification = (query?: ClassificationQuery): AxiosPromise<ClassificationVO[]> => {
  return request({
    url: '/service/classification/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询所有服务分类列表
 * @returns {*}
 */
export const listAllClassification = (): AxiosPromise<ClassificationVO[]> => {
  return request({
    url: '/service/classification/listAll',
    method: 'get'
  });
};

/**
 * 查询服务分类详细
 * @param id
 */
export const getClassification = (id: string | number): AxiosPromise<ClassificationVO> => {
  return request({
    url: '/service/classification/' + id,
    method: 'get'
  });
};

/**
 * 新增服务分类
 * @param data
 */
export const addClassification = (data: ClassificationForm) => {
  return request({
    url: '/service/classification',
    method: 'post',
    data: data
  });
};

/**
 * 修改服务分类
 * @param data
 */
export const updateClassification = (data: ClassificationForm) => {
  return request({
    url: '/service/classification',
    method: 'put',
    data: data
  });
};

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