import request from '@/config/axios';
import type { TableData } from './types';

/** 获取表格数据 */
export const getSysRoleListApi = (data: any) => {
  return request.postJson({ url: '/system/spi/system/SysRole/SysRoleQueryPage', data });
};

/** 批量删除 */
export const delSysRoleListApi = (list: string[] | number[]): Promise<IResponse> => {
  const _list = list.map(v => {
    return {
      id: v,
    };
  });
  return request.postJson({
    url: '/system/spi/system/SysRole/SysRoleBatchDelete',
    data: {
      list: _list,
    },
  });
};

/** 删除 */
export const delSysRoleApi = (id: string | number): Promise<IResponse> => {
  return request.postJson({ url: '/system/spi/system/SysRoleDelete', data: { id } });
};

/** 保存 */
export const saveSysRoleApi = (data: Partial<TableData>): Promise<IResponse> => {
  return request.postJson({ url: '/system/spi/system/SysRole/SysRoleSave', data });
};

/** 查询单条数据 */
export const querySysRoleApi = (id: string | number): Promise<IResponse> => {
  return request.postJson({ url: '/system/spi/system/SysRoleQueryOne', data: { id } });
};

/** 导入 */
export const importExcelApiUrl = '/system/sui/system/SysRole/SysRoleImportXls';

/** 导出 */
export const exportExcelApi = (params: any) => {
  return request.doExport({ url: '/system/sdi/system/SysRole/SysRoleExportXls', params });
};
