mirror of
https://github.com/certd/certd.git
synced 2026-05-16 21:27:34 +08:00
feat: cert download
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Inject, Provide, Scope, ScopeEnum } from "@midwayjs/decorator";
|
||||
import { Inject, Provide, Scope, ScopeEnum } from '@midwayjs/decorator';
|
||||
import { InjectEntityModel } from '@midwayjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseService } from '../../../basic/base-service';
|
||||
@@ -6,6 +6,7 @@ import { HistoryEntity } from '../entity/history';
|
||||
import { PipelineEntity } from '../entity/pipeline';
|
||||
import { HistoryDetail } from '../entity/vo/history-detail';
|
||||
import { HistoryLogService } from './history-log-service';
|
||||
import { FileItem, Pipeline, RunnableCollection } from '@certd/pipeline';
|
||||
|
||||
/**
|
||||
* 证书申请
|
||||
@@ -78,4 +79,29 @@ export class HistoryService extends BaseService<HistoryEntity> {
|
||||
shouldDeleteCount -= deleteCountBatch;
|
||||
}
|
||||
}
|
||||
|
||||
async getLastHistory(pipelineId: number) {
|
||||
return await this.repository.findOne({
|
||||
where: {
|
||||
pipelineId,
|
||||
},
|
||||
order: {
|
||||
id: 'DESC',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async getFiles(history: HistoryEntity) {
|
||||
const status: Pipeline = JSON.parse(history.pipeline);
|
||||
const files: FileItem[] = [];
|
||||
RunnableCollection.each([status], runnable => {
|
||||
if (runnable.runnableType !== 'step') {
|
||||
return;
|
||||
}
|
||||
if (runnable.status?.files != null) {
|
||||
files.push(...runnable.status.files);
|
||||
}
|
||||
});
|
||||
return files;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user