import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SafetyInspectionForm, SafetyInspectionQuery, SafetyInspectionVO } from '@/api/safety/safetyInspection/types';

/**
 * 查询安全巡检工单列表
 * @param query
 * @returns {*}
 */

export const listSafetyInspection = (query?: SafetyInspectionQuery): AxiosPromise<SafetyInspectionVO[]> => {
  return request({
    url: '/safety/safetyInspection/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询安全巡检工单详细
 * @param id
 */
export const getSafetyInspection = (id: string | number): AxiosPromise<SafetyInspectionVO> => {
  return request({
    url: '/safety/safetyInspection/' + id,
    method: 'get'
  });
};

/**
 * 新增安全巡检工单
 * @param data
 */
export const addSafetyInspection = (data: SafetyInspectionForm) => {
  return request({
    url: '/safety/safetyInspection',
    method: 'post',
    data: data
  });
};

/**
 * 修改安全巡检工单
 * @param data
 */
export const updateSafetyInspection = (data: SafetyInspectionForm) => {
  return request({
    url: '/safety/safetyInspection',
    method: 'put',
    data: data
  });
};

/**
 * 删除安全巡检工单
 * @param id
 */
export const delSafetyInspection = (id: string | number | Array<string | number>) => {
  return request({
    url: '/safety/safetyInspection/' + id,
    method: 'delete'
  });
};
