mirror of
https://github.com/certd/certd.git
synced 2026-07-30 09:17:36 +08:00
chore: 支持手动上传证书并部署
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { BaseService, CodeException, CommonException, Constants, PageReq } from '@certd/lib-server';
|
||||
import { InjectEntityModel } from '@midwayjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { CertInfoEntity } from '../entity/cert-info.js';
|
||||
import { utils } from '@certd/basic';
|
||||
import { CertInfo, CertReader } from '@certd/plugin-cert';
|
||||
import { Provide, Scope, ScopeEnum } from "@midwayjs/core";
|
||||
import { BaseService, CodeException, Constants, PageReq } from "@certd/lib-server";
|
||||
import { InjectEntityModel } from "@midwayjs/typeorm";
|
||||
import { Repository } from "typeorm";
|
||||
import { CertInfoEntity } from "../entity/cert-info.js";
|
||||
import { utils } from "@certd/basic";
|
||||
import { CertInfo, CertReader } from "@certd/plugin-cert";
|
||||
|
||||
export type UploadCertReq = {
|
||||
id?: number;
|
||||
@@ -13,6 +13,7 @@ export type UploadCertReq = {
|
||||
userId?: number;
|
||||
};
|
||||
|
||||
|
||||
@Provide("CertInfoService")
|
||||
@Scope(ScopeEnum.Request, { allowDowngrade: true })
|
||||
export class CertInfoService extends BaseService<CertInfoEntity> {
|
||||
@@ -168,17 +169,4 @@ export class CertInfoService extends BaseService<CertInfoEntity> {
|
||||
return bean;
|
||||
}
|
||||
|
||||
async upload(body: { id?: number; userId?:number ;cert: CertInfo }) {
|
||||
const { id, userId, cert } = body;
|
||||
if (!cert) {
|
||||
throw new CommonException("cert can't be empty");
|
||||
}
|
||||
const res = await this.updateCert({
|
||||
id,
|
||||
certReader: new CertReader(cert),
|
||||
fromType: 'upload',
|
||||
userId
|
||||
});
|
||||
return res.id;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user