import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BaseDictionaryVO, BaseDictionaryForm, BaseDictionaryId, BaseDictionaryIds, BaseDictionaryQuery } from '@/api/wcs/baseDictionary/types';

/**
 * 查询字典列表
 * @param query
 * @returns {*}
 */

export const listBaseDictionary = (query?: BaseDictionaryQuery): AxiosPromise<BaseDictionaryVO[]> => {
  return request({
    url: '/wcs/baseDictionary/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询字典详细
 * @param id
 */
export const getBaseDictionary = (id: BaseDictionaryId): AxiosPromise<BaseDictionaryVO> => {
  return request({
    url: '/wcs/baseDictionary/' + id,
    method: 'get'
  });
};

/**
 * 批量查询字典详细
 * @param ids
 */
export const getBaseDictionaryByIds = (ids: BaseDictionaryIds): AxiosPromise<BaseDictionaryVO[]> => {
  return request({
    url: '/wcs/baseDictionary/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计字典数量
 * @param query
 */
export const countBaseDictionary = (query?: BaseDictionaryQuery): AxiosPromise<number> => {
  return request({
    url: '/wcs/baseDictionary/count',
    method: 'get',
    params: query
  });
};

/**
 * 判断是否存在符合条件的字典
 * @param query
 */
export const existsBaseDictionary = (query?: BaseDictionaryQuery): AxiosPromise<boolean> => {
  return request({
    url: '/wcs/baseDictionary/exists',
    method: 'get',
    params: query
  });
};

/**
 * 新增字典
 * @param data
 */
export const addBaseDictionary = (data: BaseDictionaryForm) => {
  return request({
    url: '/wcs/baseDictionary',
    method: 'post',
    data: data
  });
};

/**
 * 修改字典
 * @param data
 */
export const updateBaseDictionary = (data: BaseDictionaryForm) => {
  return request({
    url: '/wcs/baseDictionary',
    method: 'put',
    data: data
  });
};

/**
 * 删除字典
 * @param id
 */
export const delBaseDictionary = (id: BaseDictionaryId | BaseDictionaryIds) => {
  return request({
    url: '/wcs/baseDictionary/' + id,
    method: 'delete'
  });
};
