mirror of
https://github.com/certd/certd.git
synced 2026-04-16 05:50:50 +08:00
perf: 证书仓库
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user