import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SafetyLogForm, SafetyLogQuery, SafetyLogVO } from '@/api/safety/safetyLog/types';

/**
 * 查询安全日志列表
 * @param query
 * @returns {*}
 */

export const listSafetyLog = (query?: SafetyLogQuery): AxiosPromise<SafetyLogVO[]> => {
  return request({
    url: '/safety/safetyLog/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询安全日志详细
 * @param id
 */
export const getSafetyLog = (id: string | number): AxiosPromise<SafetyLogVO> => {
  return request({
    url: '/safety/safetyLog/' + id,
    method: 'get'
  });
};

/**
 * 新增安全日志
 * @param data
 */
export const addSafetyLog = (data: SafetyLogForm) => {
  return request({
    url: '/safety/safetyLog',
    method: 'post',
    data: data
  });
};

/**
 * 修改安全日志
 * @param data
 */
export const updateSafetyLog = (data: SafetyLogForm) => {
  return request({
    url: '/safety/safetyLog',
    method: 'put',
    data: data
  });
};

/**
 * 删除安全日志
 * @param id
 */
export const delSafetyLog = (id: string | number | Array<string | number>) => {
  return request({
    url: '/safety/safetyLog/' + id,
    method: 'delete'
  });
};
