diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/getter/aliyun.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/getter/aliyun.ts index 3b39cc635..e20c2c85e 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/getter/aliyun.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/getter/aliyun.ts @@ -1,8 +1,9 @@ -import { IsTaskPlugin, PageSearch, pluginGroups, RunStrategy, Step, TaskInput, TaskOutput } from "@certd/pipeline"; -import type { CertInfo } from "../acme.js"; -import { CertReader } from "../cert-reader.js"; -import { CertApplyBasePlugin } from "../base.js"; +import { IsTaskPlugin, PageSearch, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline"; import { AliyunAccess, createRemoteSelectInputDefine } from "@certd/plugin-lib"; +import type { CertInfo } from "../acme.js"; +import { CertApplyBasePlugin } from "../base.js"; +import { CertReader } from "../cert-reader.js"; +import dayjs from "dayjs"; export { CertReader }; export type { CertInfo }; @@ -36,17 +37,32 @@ export class CertApplyGetFormAliyunPlugin extends CertApplyBasePlugin { title: "证书订单ID", helper: "订阅模式的证书订单Id", typeName: "CertApplyGetFormAliyun", + component: { + name: "RemoteAutoComplete", + vModel: "value", + }, action: CertApplyGetFormAliyunPlugin.prototype.onGetOrderList.name, }) ) - orderId!: number; + orderId!: string; async onInit(): Promise {} async doCertApply(): Promise { const access = await this.getAccess(this.accessId); const client = await access.getClient("cas.aliyuncs.com"); - const certDetail = await this.getCertDetail(client, this.orderId); + this.logger.info(`开始获取证书,orderId:${this.orderId}`); + let orderId: any = this.orderId; + if (!orderId) { + throw new Error("请先输入证书订单ID"); + } + if (typeof orderId !== "string") { + orderId = parseInt(orderId); + } + const certState = await this.getCertificateState(client, orderId); + this.logger.info(`获取到证书Id:${JSON.stringify(certState.CertId)}`); + const certDetail = await this.getCertDetail(client, certState.CertId); + this.logger.info(`获取到证书:${certDetail.getAllDomains()}, 过期时间:${dayjs(certDetail.expires).format("YYYY-MM-DD HH:mm:ss")}`); return certDetail; } @@ -82,7 +98,7 @@ export class CertApplyGetFormAliyunPlugin extends CertApplyBasePlugin { }); } - async getCertificateState(client: any, orderId: any) { + async getCertificateState(client: any, orderId: any): Promise<{ CertId: string; Type: string; Domain: string }> { const res = await client.doRequest({ // 接口名称 action: "DescribeCertificateState", @@ -103,7 +119,7 @@ export class CertApplyGetFormAliyunPlugin extends CertApplyBasePlugin { }, }); - return res.CertId; + return res; } async onGetOrderList(req: PageSearch) {