返回 AiToEarn
table.ts
1 /*
2 * @Author: nevin
3 * @Date: 2022-03-17 16:05:38
4 * @LastEditors: nevin
5 * @LastEditTime: 2025-01-23 22:46:37
6 * @Description: 表格状数据
7 */
8
9 export interface CorrectQuery {
10 page_size: number;
11 page_no: number;
12 }
13
14 export interface CorrectResponse<T> {
15 list: T[];
16 total_count: number;
17 total_page: number;
18 page_size: number;
19 page_no: number;
20 }
21
22 /**
23 * 返回分页数据
24 * @param list 列表
25 * @param totalCount 总数
26 * @param page 分页参数
27 * @returns 分页数据
28 */
29 export function backPageData<T>(
30 list: T[],
31 totalCount: number,
32 page: CorrectQuery,
33 ): CorrectResponse<T> {
34 return {
35 list,
36 total_count: totalCount,
37 total_page: Math.ceil(totalCount / page.page_size),
38 page_size: page.page_size,
39 page_no: page.page_no,
40 };
41 }
42
42 lines TYPESCRIPT