import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PlcAddressVO, PlcAddressForm, PlcAddressId, PlcAddressIds, PlcAddressQuery } from '@/api/wcs/plcAddress/types';

/**
 * 查询PLC地址配置列表
 * @param query
 * @returns {*}
 */

export const listPlcAddress = (query?: PlcAddressQuery): AxiosPromise<PlcAddressVO[]> => {
  return request({
    url: '/wcs/plcAddress/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询PLC地址配置详细
 * @param id
 */
export const getPlcAddress = (id: PlcAddressId): AxiosPromise<PlcAddressVO> => {
  return request({
    url: '/wcs/plcAddress/' + id,
    method: 'get'
  });
};

/**
 * 批量查询PLC地址配置详细
 * @param ids
 */
export const getPlcAddressByIds = (ids: PlcAddressIds): AxiosPromise<PlcAddressVO[]> => {
  return request({
    url: '/wcs/plcAddress/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计PLC地址配置数量
 * @param query
 */
export const countPlcAddress = (query?: PlcAddressQuery): AxiosPromise<number> => {
  return request({
    url: '/wcs/plcAddress/count',
    method: 'get',
    params: query
  });
};

/**
 * 判断是否存在符合条件的PLC地址配置
 * @param query
 */
export const existsPlcAddress = (query?: PlcAddressQuery): AxiosPromise<boolean> => {
  return request({
    url: '/wcs/plcAddress/exists',
    method: 'get',
    params: query
  });
};

/**
 * 新增PLC地址配置
 * @param data
 */
export const addPlcAddress = (data: PlcAddressForm) => {
  return request({
    url: '/wcs/plcAddress',
    method: 'post',
    data: data
  });
};

/**
 * 修改PLC地址配置
 * @param data
 */
export const updatePlcAddress = (data: PlcAddressForm) => {
  return request({
    url: '/wcs/plcAddress',
    method: 'put',
    data: data
  });
};

/**
 * 删除PLC地址配置
 * @param id
 */
export const delPlcAddress = (id: PlcAddressId | PlcAddressIds) => {
  return request({
    url: '/wcs/plcAddress/' + id,
    method: 'delete'
  });
};
