bill-fontend/src/api/list.ts
vertoryao 48fd83ae06 feat(permission): 添加权限管理模块
- 添加角色切换按钮
2023-12-08 17:37:28 +08:00

44 lines
787 B
TypeScript

import axios from 'axios';
import qs from 'query-string';
export interface Pageable {
pageNumber: number;
pageSize: number;
sort: {
sorted: boolean;
unsorted: boolean;
empty: boolean;
};
offset: number;
paged: boolean;
}
export interface ListParams<Record> {
page: number;
size: number;
}
export interface ListRes<Record> {
content: Record[];
totalPages: number;
totalElements: number;
size: number;
number: number;
pageable: Pageable;
}
export function queryList<Record>(
url: string,
params: ListParams<Record> | undefined
) {
if (params) {
return axios.get<ListRes<Record>>(url, {
params,
paramsSerializer: (obj) => {
return qs.stringify(obj);
},
});
};
return axios.get<ListRes<Record>>(url);
}