| 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 | import { PubStatus, PubType } from '../../commont/publish/PublishEnum'; |
| 10 | |
| 11 | export interface CorrectQuery { |
| 12 | page_size: number; |
| 13 | page_no: number; |
| 14 | } |
| 15 | |
| 16 | export interface pubRecordListQuery { |
| 17 | time?: [string, string]; |
| 18 | status?: PubStatus; |
| 19 | type?: PubType; |
| 20 | } |
| 21 | |
| 22 | export interface CorrectResponse<T> { |
| 23 | list: T[]; |
| 24 | total_count: number; |
| 25 | total_page: number; |
| 26 | page_size: number; |
| 27 | page_no: number; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * 返回分页数据 |
| 32 | * @param list 列表 |
| 33 | * @param totalCount 总数 |
| 34 | * @param page 分页参数 |
| 35 | * @returns 分页数据 |
| 36 | */ |
| 37 | export function backPageData<T>( |
| 38 | list: T[], |
| 39 | totalCount: number, |
| 40 | page: CorrectQuery, |
| 41 | ): CorrectResponse<T> { |
| 42 | return { |
| 43 | list, |
| 44 | total_count: totalCount, |
| 45 | total_page: Math.ceil(totalCount / page.page_size), |
| 46 | page_size: page.page_size, |
| 47 | page_no: page.page_no, |
| 48 | }; |
| 49 | } |
| 50 |