mirror of
https://github.com/certd/certd.git
synced 2026-04-24 12:27:25 +08:00
perf: 阿里云waf cname站点选择支持翻页及域名查询
This commit is contained in:
@@ -3,7 +3,7 @@ import { IContext } from "../core/index.js";
|
||||
export type UserContext = IContext;
|
||||
export type PipelineContext = IContext;
|
||||
|
||||
export type PageReq = {
|
||||
export type PageSearch = {
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
searchKey?: string;
|
||||
@@ -17,3 +17,26 @@ export type PageRes = {
|
||||
total?: string;
|
||||
list: any[];
|
||||
};
|
||||
|
||||
export class Pager {
|
||||
offset: number;
|
||||
limit: number;
|
||||
constructor(req: PageSearch) {
|
||||
this.offset = req.offset ?? 0;
|
||||
this.limit = req.limit || 50;
|
||||
}
|
||||
|
||||
getPageNo() {
|
||||
const size = this.limit;
|
||||
const offset = this.offset;
|
||||
let page = Math.floor(offset / size);
|
||||
if (offset % size === 0) {
|
||||
page++;
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
setPageNo(pageNo: number) {
|
||||
this.offset = (pageNo - 1) * (this.limit ?? 50);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user