2025-04-19 15:00:34 +08:00
|
|
|
import {Body, Controller, Inject, Post, Provide, Query} from '@midwayjs/core';
|
2025-01-15 01:05:34 +08:00
|
|
|
import { PipelineService } from '../../../modules/pipeline/service/pipeline-service.js';
|
2024-10-15 12:59:40 +08:00
|
|
|
import { BaseController, Constants } from '@certd/lib-server';
|
2025-01-15 01:05:34 +08:00
|
|
|
import { StorageService } from '../../../modules/pipeline/service/storage-service.js';
|
2025-04-19 15:00:34 +08:00
|
|
|
import {CertReader} from "@certd/plugin-cert";
|
2024-10-15 12:59:40 +08:00
|
|
|
|
|
|
|
|
@Provide()
|
|
|
|
|
@Controller('/api/pi/cert')
|
|
|
|
|
export class CertController extends BaseController {
|
|
|
|
|
@Inject()
|
|
|
|
|
pipelineService: PipelineService;
|
|
|
|
|
@Inject()
|
|
|
|
|
storeService: StorageService;
|
|
|
|
|
|
|
|
|
|
@Post('/get', { summary: Constants.per.authOnly })
|
|
|
|
|
async getCert(@Query('id') id: number) {
|
|
|
|
|
const userId = this.getUserId();
|
|
|
|
|
await this.pipelineService.checkUserId(id, userId);
|
2024-10-15 17:12:42 +08:00
|
|
|
const privateVars = await this.storeService.getPipelinePrivateVars(id);
|
|
|
|
|
return this.ok(privateVars.cert);
|
2024-10-15 12:59:40 +08:00
|
|
|
}
|
2025-04-19 15:00:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@Post('/readCertDetail', { summary: Constants.per.authOnly })
|
|
|
|
|
async readCertDetail(@Body('crt') crt: string) {
|
|
|
|
|
if (!crt) {
|
|
|
|
|
throw new Error('crt is required');
|
|
|
|
|
}
|
|
|
|
|
const certDetail = CertReader.readCertDetail(crt)
|
|
|
|
|
return this.ok(certDetail);
|
|
|
|
|
}
|
2024-10-15 12:59:40 +08:00
|
|
|
}
|