import { http } from '@/utils/http/axios';

/**
 * @description: 字典列表
 */
export function getDictList(params?) {
  return http.request({
    url: '/dict/page',
    method: 'GET',
    params,
  });
}

/**
 * @description: 根据ID获取详情
 */
export function getDictDetail(id) {
  return http.request({
    url: '/dict/detail/' + id,
    method: 'get',
  });
}

/**
 * @description: 刷新缓存
 */
export function refreshCache() {
  return http.request({
    url: '/dict/refreshCache',
    method: 'get',
  });
}

/**
 * @description: 添加字典
 */
export function dictAdd(data: any) {
  return http.request({
    url: '/dict/add',
    method: 'POST',
    data,
  });
}

/**
 * @description: 更新字典
 */
export function dictUpdate(data: any) {
  return http.request({
    url: '/dict/update',
    method: 'PUT',
    data,
  });
}

/**
 * @description: 删除字典
 */
export function dictDelete(id) {
  return http.request({
    url: '/dict/delete/' + id,
    method: 'DELETE',
  });
}

/**
 * @description: 批量删除字典
 */
export function dictBatchDelete(data: any) {
  return http.request({
    url: '/dict/batchDelete',
    method: 'DELETE',
    data,
  });
}

/**
 * @description: 字典项列表
 */
export function getDictItemList(params?) {
  return http.request({
    url: '/dict/item/page',
    method: 'GET',
    params,
  });
}

/**
 * @description: 根据ID获取详情
 */
export function getDictItemDetail(id) {
  return http.request({
    url: '/dict/item/detail/' + id,
    method: 'get',
  });
}

/**
 * @description: 添加字典项
 */
export function dictItemAdd(data: any) {
  return http.request({
    url: '/dict/item/add',
    method: 'POST',
    data,
  });
}

/**
 * @description: 更新字典项
 */
export function dictItemUpdate(data: any) {
  return http.request({
    url: '/dict/item/update',
    method: 'PUT',
    data,
  });
}

/**
 * @description: 删除字典项
 */
export function dictItemDelete(id) {
  return http.request({
    url: '/dict/item/delete/' + id,
    method: 'DELETE',
  });
}

/**
 * @description: 批量删除字典项
 */
export function dictItemBatchDelete(data: any) {
  return http.request({
    url: '/dict/item/batchDelete',
    method: 'DELETE',
    data,
  });
}
