chore: 优化插件的翻页查询

This commit is contained in:
xiaojunnuo
2025-06-29 19:59:13 +08:00
parent 710e1fc278
commit 66d1886663
6 changed files with 51 additions and 57 deletions
@@ -183,8 +183,8 @@ export class AliyunDeployCertToWaf extends AbstractTaskPlugin {
const params:any = {
RegionId: this.regionId,
InstanceId: instanceId,
PageSize: pager.limit,
PageNumber: pager.getPageNo(),
PageSize: pager.pageSize,
PageNumber: pager.pageNo,
};
if (data.searchKey){
params.Domain = data.searchKey
@@ -206,11 +206,13 @@ export class AliyunDeployCertToWaf extends AbstractTaskPlugin {
});
const list= this.ctx.utils.options.buildGroupOptions(options, this.certDomains);
// const list = [{value:"1",label:"1"},{value:"2",label:"2"}]
// const total = 120
return {
list,
total: total,
offset: pager.offset,
limit: pager.limit
pageNo: pager.pageNo,
pageSize: pager.pageSize
};
}
}
@@ -1,4 +1,4 @@
import { AbstractTaskPlugin, IsTaskPlugin, PageSearch, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
import { AbstractTaskPlugin, IsTaskPlugin, Pager, PageSearch, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert";
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from "@certd/plugin-lib";
import { FarcdnAccess } from "../access.js";
@@ -81,9 +81,10 @@ export class FarcdnRefreshCert extends AbstractTaskPlugin {
async onGetCertList(data:PageSearch = {}) {
const access = await this.getAccess<FarcdnAccess>(this.accessId);
const pager = new Pager(data);
const res = await access.getSSLCertList({
offset: data.offset?? 0,
size: data.limit?? 100,
offset: pager.getOffset(),
size: pager.pageSize,
});
const list = res.list
if (!list || list.length === 0) {
@@ -100,8 +101,8 @@ export class FarcdnRefreshCert extends AbstractTaskPlugin {
return {
list:this.ctx.utils.options.buildGroupOptions(options, this.certDomains),
total:res.total,
offset: res.offset,
limit:res.size
pageNo: pager.pageNo,
pageSize: pager.pageSize
}
}
}
@@ -75,20 +75,16 @@ export class RainyunAccess extends BaseAccess {
}
async getCertList(req:{offset?:number,limit?:number,query?:string}){
const size = req.limit ?? 20;
const offset = req.offset ?? 0;
let page = Math.floor(offset / size);
if(offset % size === 0 ){
page++
}
async getCertList(req:{pageNo?:number,pageSize?:number,query?:string}){
const pageNo = req.pageNo ?? 1;
const pageSize = req.pageSize ?? 20;
const options ={
columnFilters: {
Domain: req.query??""
},
sort:[],
page: page,
perPage: size,
page: pageNo,
perPage: pageSize,
}
const res = await this.doRequest({
@@ -99,8 +95,8 @@ export class RainyunAccess extends BaseAccess {
return {
total: res.TotalRecords,
list: res.Records || [],
limit: size,
offset: offset
pageNo: pageNo,
pageSize: pageSize
}
}
@@ -81,11 +81,11 @@ export class RainyunRefreshCert extends AbstractTaskPlugin {
async onGetCertList(req: PageSearch = {}) {
const access = await this.getAccess<RainyunAccess>(this.accessId);
const offset = req.offset ?? 0;
const limit = req.limit ?? 100;
const pageNo = req.pageNo ?? 1;
const pageSize = req.pageSize ?? 100;
const res = await access.getCertList({
offset,
limit
pageNo,
pageSize
});
const total = res.total;
const list = res.list;
@@ -103,8 +103,8 @@ export class RainyunRefreshCert extends AbstractTaskPlugin {
return {
list: this.ctx.utils.options.buildGroupOptions(options, this.certDomains),
total: total,
offset: offset,
limit: limit
pageNo: pageNo,
pageSize: pageSize
};
}
}