import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CategoryVO, CategoryForm, CategoryQuery } from '@/api/smarttrace/category/types';

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

export const listCategory = (query?: CategoryQuery): AxiosPromise<CategoryVO[]> => {
  return request({
    url: '/smarttrace/category/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询分类详细
 * @param id
 */
export const getCategory = (id: string | number): AxiosPromise<CategoryVO> => {
  return request({
    url: '/smarttrace/category/getInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增分类
 * @param data
 */
export const addCategory = (data: CategoryForm) => {
  return request({
    url: '/smarttrace/category/add',
    method: 'post',
    data: data
  });
};

/**
 * 修改分类
 * @param data
 */
export const updateCategory = (data: CategoryForm) => {
  return request({
    url: '/smarttrace/category/edit',
    method: 'post',
    data: data
  });
};

/**
 * 删除分类
 * @param id
 */
export const delCategory = (id: string | number | Array<string | number>) => {
  return request({
    url: '/smarttrace/category/remove/' + id,
    method: 'get'
  });
};
