import apiRequest from '@/network/http/apiRequest'

/**
 * 分页查询Task
 * @param data
 * @returns
 */
export function getTaskByPage(data: any) {
  return apiRequest({
    url: '/task/page',
    method: 'GET',
    params: data,
  })
}

/**
 * 列表查询Task
 * @param data
 * @returns
 */
export function getTaskByList(data: any) {
  return apiRequest({
    url: '/task',
    method: 'GET',
    params: data,
  })
}

/**
 * 列表查询Task: 50笔
 * @param data
 * @returns
 */
export function getRecentTaskByList(data: any) {
  return apiRequest({
    url: '/task/recent',
    method: 'GET',
    params: data,
  })
}

/**
 * @param taskId
 * @returns
 */
export function getTaskById(taskId: number) {
  return apiRequest({
    url: `/task/${taskId}`,
    method: 'GET',
  })
}

/**
 * 添加Task
 * @param data
 * @returns
 */
export function createTask(data: any) {
  return apiRequest({
    url: '/task/add',
    method: 'POST',
    data,
  })
}

/**
 * 更新Task
 * @param data
 * @returns
 */
export function updateTask(data: any) {
  return apiRequest({
    url: '/task/update',
    method: 'PUT',
    data,
  })
}

/**
 * 删除Task
 * @param taskId
 * @returns
 */
export function deleteTaskById(taskId: number) {
  return apiRequest({
    url: `/task/${taskId}`,
    method: 'DELETE',
  })
}

/**
 * Handle Task
 * @param taskId
 * @returns
 */
export function handleTask(taskId: number) {
  return apiRequest({
    url: `/task/handle/${taskId}`,
    method: 'PUT',
  })
}

/**
 * Transfer Task
 * @param data
 * @returns
 */
export function transferTask(data: any) {
  return apiRequest({
    url: '/task/transfer',
    method: 'PUT',
    data,
  })
}

/**
 * Cancel Task
 * @param taskId
 * @returns
 */
export function cancelTask(taskId: number) {
  return apiRequest({
    url: `/task/cancel/${taskId}`,
    method: 'PUT',
  })
}
