import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TaskDetailVO, TaskDetailForm, TaskDetailId, TaskDetailIds, TaskDetailQuery } from '@/api/wcs/taskDetail/types';

/**
 * 查询实时任务明细列表
 * @param query
 * @returns {*}
 */

export const listTaskDetail = (query?: TaskDetailQuery): AxiosPromise<TaskDetailVO[]> => {
  return request({
    url: '/wcs/taskDetail/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询实时任务明细详细
 * @param objId
 */
export const getTaskDetail = (objId: TaskDetailId): AxiosPromise<TaskDetailVO> => {
  return request({
    url: '/wcs/taskDetail/' + objId,
    method: 'get'
  });
};

/**
 * 批量查询实时任务明细详细
 * @param ids
 */
export const getTaskDetailByIds = (ids: TaskDetailIds): AxiosPromise<TaskDetailVO[]> => {
  return request({
    url: '/wcs/taskDetail/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 获取实时任务明细下拉列表（免分页）
 * @param query
 */
export const getTaskDetailList = (query?: TaskDetailQuery) => {
  return request({
    url: '/wcs/taskDetail/getTaskDetailList',
    method: 'get',
    params: query
  });
};

/**
 * 统计实时任务明细数量
 * @param query
 */
export const countTaskDetail = (query?: TaskDetailQuery): AxiosPromise<number> => {
  return request({
    url: '/wcs/taskDetail/count',
    method: 'get',
    params: query
  });
};

/**
 * 判断是否存在符合条件的实时任务明细
 * @param query
 */
export const existsTaskDetail = (query?: TaskDetailQuery): AxiosPromise<boolean> => {
  return request({
    url: '/wcs/taskDetail/exists',
    method: 'get',
    params: query
  });
};

/**
 * 新增实时任务明细
 * @param data
 */
export const addTaskDetail = (data: TaskDetailForm) => {
  return request({
    url: '/wcs/taskDetail',
    method: 'post',
    data: data
  });
};

/**
 * 修改实时任务明细
 * @param data
 */
export const updateTaskDetail = (data: TaskDetailForm) => {
  return request({
    url: '/wcs/taskDetail',
    method: 'put',
    data: data
  });
};

/**
 * 删除实时任务明细
 * @param objId
 */
export const delTaskDetail = (objId: TaskDetailId | TaskDetailIds) => {
  return request({
    url: '/wcs/taskDetail/' + objId,
    method: 'delete'
  });
};
