import request from '@/utils/request';

// 定义接口返回数据类型
export type DictResponse = {
  code: number;
  data: DictItem[];
  message: string;
  success: boolean;
  [property: string]: any;
}

export type DictItem = {
  basePageRequest: null;
  code: string;
  createBy: null;
  createDate: null;
  defaultFlag: null;
  deleteFlag: null;
  description: string;
  dicName: string;
  dictTypeCode: null | string;
  dictTypeName: null | string;
  id: string;
  lastUpdateTime: null;
  orderFlag: string;
  parentCode: string;
  parentType: string;
  tenantId: null;
  tenantName: null;
  updateBy: null;
  updateDate: null;
  useFlag: string;
  [property: string]: any;
}

/**
 * 获取字典列表
 * @param code 字典编码
 * @returns 字典列表
 */
export async function getDictList(code: string): Promise<DictResponse> {
  return request(`/cosco/dictProject/getAllList/${code}`, {
    method: 'GET',
  });
}
