import request from '@/config/axios'

export interface InspectionTaskVO {
  id?: number
  deviceId: string
  deviceName: string
  name: string
  frequencyType: 'DAILY' | 'WEEKLY' | 'MONTHLY'
  weekdays?: number[]
  monthDays?: number[]
  windowStart: string
  windowEnd: string
  effectiveStart: string
  effectiveEnd?: string
  assigneeUserId?: string
  assigneeUserName?: string
  status?: number
  description?: string
  creator?: string
  createTime?: string
  updater?: string
  updateTime?: string
}

export interface InspectionTaskPageReqVO {
  pageNo: string
  pageSize: string
  deviceId?: string
  deviceName?: string
  name?: string
  frequencyType?: string
  status?: string
}

export interface InspectionTaskPageRespVO {
  list: InspectionTaskVO[]
  total: number
}

// 创建点检任务
export const createInspectionTask = (data: InspectionTaskVO) => {
  return request.post({
    url: '/iot/inspection/task/create',
    data
  })
}

// 更新点检任务
export const updateInspectionTask = (data: InspectionTaskVO) => {
  return request.put({
    url: '/iot/inspection/task/update',
    data
  })
}

// 获取点检任务详情
export const getInspectionTask = (id: number) => {
  return request.get({
    url: '/iot/inspection/task/get',
    params: { id }
  })
}

// 分页查询点检任务
export const getInspectionTaskPage = (params: InspectionTaskPageReqVO) => {
  return request.get({
    url: '/iot/inspection/task/page',
    params
  })
}

// 删除点检任务
export const deleteInspectionTask = (id: number) => {
  return request.delete({
    url: '/iot/inspection/task/delete',
    params: { id }
  })
}
