import request from '@/utils/request'

// 查询任务列表
export function listTask(mapName) {
  return request({
    url: `/v1/path/list`,
    method: 'get',
    params: { map: mapName },
  })
}

// 查询任务详细
export function getTask(mapName, taskName) {
  return request({
    url: `/v1/path`,
    method: 'get',
    params: { map: mapName, path: taskName },
  })
}

// 新增任务
export function addTask(data) {
  return request({
    url: '/v1/path',
    method: 'post',
    data: data,
  })
}

// 更新任务
export function updateTask(data) {
  return request({
    url: '/v1/path',
    method: 'put',
    data: data,
  })
}

// 删除任务
export function delTask(data) {
  return request({
    url: '/v1/path',
    method: 'delete',
    data: data,
  })
}

// 更新任务状态
export function updateTaskStatus(taskId, status) {
  return request({
    url: '/v1/path/status',
    method: 'put',
    params: { taskId, status },
  })
}

// 获取任务执行记录
export function getTaskLogs(params) {
  return request({
    url: '/v1/path/logs',
    method: 'get',
    params: params,
  })
}

// 获取设备今日执行记录
export function getTodayExecutionLogs(deviceId) {
  return request({
    url: '/v1/path/logs/today',
    method: 'get',
    params: { deviceId },
  })
}
