perf: 证书仓库

This commit is contained in:
xiaojunnuo
2025-01-15 01:05:34 +08:00
parent 52a4fd3318
commit 91e7f45a1c
48 changed files with 615 additions and 130 deletions

View File

@@ -0,0 +1,42 @@
import { ALL, Body, Controller, Get, Inject, Post, Provide, Query } from '@midwayjs/core';
import { CodeException, Constants, EncryptService } from '@certd/lib-server';
import { CertInfoService } from '../../../modules/monitor/service/cert-info-service.js';
import { CertInfo } from '@certd/plugin-cert';
import { OpenKey } from '../../../modules/open/service/open-key-service.js';
import { BaseOpenController } from '../base-open-controller.js';
export type CertGetReq = {
domains: string;
};
/**
*/
@Provide()
@Controller('/api/v1/cert')
export class OpenCertController extends BaseOpenController {
@Inject()
certInfoService: CertInfoService;
@Inject()
encryptService: EncryptService;
@Get('/get', { summary: Constants.per.open })
@Post('/get', { summary: Constants.per.open })
async get(@Body(ALL) bean: CertGetReq, @Query(ALL) query: CertGetReq) {
const openKey: OpenKey = this.ctx.openKey;
const userId = openKey.userId;
if (!userId) {
return Constants.res.openKeyError;
}
const domains = bean.domains || query.domains;
if (!domains) {
throw new CodeException(Constants.res.openParamError);
}
const domainArr = domains.split(',');
const res: CertInfo = await this.certInfoService.getCertInfo({
userId,
domains: domainArr,
});
return this.ok(res);
}
}