import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TasktypeVO, TasktypeForm, TasktypeId, TasktypeIds, TasktypeQuery } from '@/api/wcs/tasktype/types';

/**
 * 查询字典列表
 * @param query
 * @returns {*}
 */

export const listTasktype = (query?: TasktypeQuery): AxiosPromise<TasktypeVO[]> => {
  return request({
    url: '/wcs/tasktype/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询字典详细
 * @param id
 */
export const getTasktype = (id: TasktypeId): AxiosPromise<TasktypeVO> => {
  return request({
    url: '/wcs/tasktype/' + id,
    method: 'get'
  });
};

/**
 * 批量查询字典详细
 * @param ids
 */
export const getTasktypeByIds = (ids: TasktypeIds): AxiosPromise<TasktypeVO[]> => {
  return request({
    url: '/wcs/tasktype/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计字典数量
 * @param query
 */
export const countTasktype = (query?: TasktypeQuery): AxiosPromise<number> => {
  return request({
    url: '/wcs/tasktype/count',
    method: 'get',
    params: query
  });
};

/**
 * 判断是否存在符合条件的字典
 * @param query
 */
export const existsTasktype = (query?: TasktypeQuery): AxiosPromise<boolean> => {
  return request({
    url: '/wcs/tasktype/exists',
    method: 'get',
    params: query
  });
};

/**
 * 新增字典
 * @param data
 */
export const addTasktype = (data: TasktypeForm) => {
  return request({
    url: '/wcs/tasktype',
    method: 'post',
    data: data
  });
};

/**
 * 修改字典
 * @param data
 */
export const updateTasktype = (data: TasktypeForm) => {
  return request({
    url: '/wcs/tasktype',
    method: 'put',
    data: data
  });
};

/**
 * 删除字典
 * @param id
 */
export const delTasktype = (id: TasktypeId | TasktypeIds) => {
  return request({
    url: '/wcs/tasktype/' + id,
    method: 'delete'
  });
};
