mirror of
https://github.com/certd/certd.git
synced 2026-04-23 11:37:23 +08:00
perf: 所有授权增加测试按钮
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {AccessInput, BaseAccess, IsAccess} from '@certd/pipeline';
|
||||
import {AccessInput, BaseAccess, IsAccess, Pager, PageRes, PageSearch} from '@certd/pipeline';
|
||||
import { DomainRecord } from '@certd/plugin-lib';
|
||||
|
||||
/**
|
||||
* 这个注解将注册一个授权配置
|
||||
@@ -32,6 +33,59 @@ export class JDCloudAccess extends BaseAccess {
|
||||
})
|
||||
secretAccessKey = '';
|
||||
|
||||
|
||||
@AccessInput({
|
||||
title: "测试",
|
||||
component: {
|
||||
name: "api-test",
|
||||
action: "TestRequest"
|
||||
},
|
||||
helper: "点击测试接口是否正常"
|
||||
})
|
||||
testRequest = true;
|
||||
|
||||
accessToken: { expiresAt: number, token: string }
|
||||
|
||||
async onTestRequest() {
|
||||
await this.getDomainListPage({
|
||||
pageNo: 1,
|
||||
pageSize: 1,
|
||||
});
|
||||
return "ok"
|
||||
}
|
||||
|
||||
|
||||
async getJDDomainService() {
|
||||
const {JDDomainService} = await import("@certd/jdcloud")
|
||||
const service = new JDDomainService({
|
||||
credentials: {
|
||||
accessKeyId: this.accessKeyId,
|
||||
secretAccessKey: this.secretAccessKey
|
||||
},
|
||||
regionId: "cn-north-1" //地域信息,某个api调用可以单独传参regionId,如果不传则会使用此配置中的regionId
|
||||
});
|
||||
return service;
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
const pager = new Pager(req);
|
||||
const service = await this.getJDDomainService();
|
||||
const domainRes = await service.describeDomains({
|
||||
domainName: req.searchKey,
|
||||
pageNumber: pager.pageNo,
|
||||
pageSize: pager.pageSize,
|
||||
})
|
||||
let list = domainRes.result?.dataList || []
|
||||
list = list.map((item: any) => ({
|
||||
id: item.domainId,
|
||||
domain: item.domainName,
|
||||
}));
|
||||
return {
|
||||
total:domainRes.result.totalCount || list.length,
|
||||
list,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new JDCloudAccess();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { PageRes, PageSearch } from "@certd/pipeline";
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
import { JDCloudAccess } from "./access.js";
|
||||
import { Pager, PageRes, PageSearch } from "@certd/pipeline";
|
||||
|
||||
@IsDnsProvider({
|
||||
name: "jdcloud",
|
||||
@@ -85,34 +85,11 @@ export class JDCloudDnsProvider extends AbstractDnsProvider {
|
||||
}
|
||||
|
||||
private async getJDDomainService() {
|
||||
const {JDDomainService} = await import("@certd/jdcloud")
|
||||
const service = new JDDomainService({
|
||||
credentials: {
|
||||
accessKeyId: this.access.accessKeyId,
|
||||
secretAccessKey: this.access.secretAccessKey
|
||||
},
|
||||
regionId: "cn-north-1" //地域信息,某个api调用可以单独传参regionId,如果不传则会使用此配置中的regionId
|
||||
});
|
||||
return service;
|
||||
return await this.access.getJDDomainService();
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
const pager = new Pager(req);
|
||||
const service = await this.getJDDomainService();
|
||||
const domainRes = await service.describeDomains({
|
||||
domainName: req.searchKey,
|
||||
pageNumber: pager.pageNo,
|
||||
pageSize: pager.pageSize,
|
||||
})
|
||||
let list = domainRes.result?.dataList || []
|
||||
list = list.map((item: any) => ({
|
||||
id: item.domainId,
|
||||
domain: item.domainName,
|
||||
}));
|
||||
return {
|
||||
total:domainRes.result.totalCount || list.length,
|
||||
list,
|
||||
};
|
||||
return await this.access.getDomainListPage(req);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user