import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DictDetailVO, DictDetailForm, DictDetailQuery } from '@/api/system/dictDetail/types';
import {DictForm, EnableVo} from "@/api/system/dict/types";
import {AllBusinessQuery, AllBusinessVO} from "@/api/business/allBusiness/types";

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

export const listDictDetail = (query?: DictDetailQuery & PageQuery): AxiosPromise<{  records: DictDetailVO[] }> => {
  return request({
    url: '/sys/dict/listDetialByDictId',
    method: 'post',
    data: query
  });
};

/**
 * 查询字典详情详细
 * @param dictDetailId
 */
export const getDictDetail = (dictDetailId: string | number): AxiosPromise<DictDetailVO> => {
  return request({
    url: '/system/dictDetail/' + dictDetailId,
    method: 'get'
  });
};

/**
 * 新增字典详情
 * @param data
 */
export const addDictDetail = (data: DictDetailForm) => {
  return request({
    url: '/sys/dict/saveDictDetail',
    method: 'post',
    data: data
  });
};

/**
 * 修改字典详情
 * @param data
 */
export const updateDictDetail = (data: DictDetailForm) => {
  return request({
    url: '/system/dictDetail',
    method: 'put',
    data: data
  });
};

/**
 * 删除字典详情
 * @param dictDetailId
 */
export const delDictDetail = (dictDetailId: string | number | Array<string | number>) => {
  return request({
    url: '/sys/dict/deleteDictDetail',
    method: 'post',
      data: {ids: dictDetailId}

  });
};

/**
 * 禁用或启用字典
 * @param data
 */
export const enabledDetail = (data: EnableVo) => {
    return request({
        url: '/sys/dict/enabledDetail',
        method: 'post',
        data: data
    });
};
