import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ControlCommandLogVO, ControlCommandLogForm, ControlCommandLogId, ControlCommandLogIds, ControlCommandLogQuery } from '@/api/ems/base/controlCommandLog/types';

/**
 * 查询回写命令日志列表
 * @param query
 * @returns {*}
 */

export const listControlCommandLog = (query?: ControlCommandLogQuery): AxiosPromise<ControlCommandLogVO[]> => {
  return request({
    url: '/ems/base/controlCommandLog/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询回写命令日志详细
 * @param id
 */
export const getControlCommandLog = (id: ControlCommandLogId): AxiosPromise<ControlCommandLogVO> => {
  return request({
    url: '/ems/base/controlCommandLog/' + id,
    method: 'get'
  });
};

/**
 * 批量查询回写命令日志详细
 * @param ids
 */
export const getControlCommandLogByIds = (ids: ControlCommandLogIds): AxiosPromise<ControlCommandLogVO[]> => {
  return request({
    url: '/ems/base/controlCommandLog/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计回写命令日志数量
 * @param query
 */
export const countControlCommandLog = (query?: ControlCommandLogQuery): AxiosPromise<number> => {
  return request({
    url: '/ems/base/controlCommandLog/count',
    method: 'get',
    params: query
  });
};

/**
 * 判断是否存在符合条件的回写命令日志
 * @param query
 */
export const existsControlCommandLog = (query?: ControlCommandLogQuery): AxiosPromise<boolean> => {
  return request({
    url: '/ems/base/controlCommandLog/exists',
    method: 'get',
    params: query
  });
};

/**
 * 新增回写命令日志
 * @param data
 */
export const addControlCommandLog = (data: ControlCommandLogForm) => {
  return request({
    url: '/ems/base/controlCommandLog',
    method: 'post',
    data: data
  });
};

/**
 * 修改回写命令日志
 * @param data
 */
export const updateControlCommandLog = (data: ControlCommandLogForm) => {
  return request({
    url: '/ems/base/controlCommandLog',
    method: 'put',
    data: data
  });
};

/**
 * 删除回写命令日志
 * @param id
 */
export const delControlCommandLog = (id: ControlCommandLogId | ControlCommandLogIds) => {
  return request({
    url: '/ems/base/controlCommandLog/' + id,
    method: 'delete'
  });
};
