mirror of
https://github.com/certd/certd.git
synced 2026-05-18 14:27:36 +08:00
chore: project query
This commit is contained in:
@@ -756,6 +756,9 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
id: pipelineId,
|
||||
},
|
||||
});
|
||||
if(!pipelineEntity){
|
||||
return null
|
||||
}
|
||||
return pipelineEntity.projectId;
|
||||
}
|
||||
private async saveHistory(history: RunHistory) {
|
||||
|
||||
@@ -67,7 +67,7 @@ export class TemplateService extends BaseService<TemplateEntity> {
|
||||
|
||||
}
|
||||
|
||||
async detail(id: number, userId: number) {
|
||||
async detail(id: number, userId: number,projectId?:number) {
|
||||
const info = await this.info(id)
|
||||
if (!info) {
|
||||
throw new Error('模板不存在');
|
||||
@@ -75,6 +75,9 @@ export class TemplateService extends BaseService<TemplateEntity> {
|
||||
if (info.userId !== userId) {
|
||||
throw new Error('无权限');
|
||||
}
|
||||
if (projectId && info.projectId !== projectId) {
|
||||
throw new Error('无权限');
|
||||
}
|
||||
let pipeline = null
|
||||
if (info.pipelineId) {
|
||||
const pipelineEntity = await this.pipelineService.info(info.pipelineId);
|
||||
@@ -88,19 +91,22 @@ export class TemplateService extends BaseService<TemplateEntity> {
|
||||
}
|
||||
}
|
||||
|
||||
async batchDelete(ids: number[], userId: number) {
|
||||
async batchDelete(ids: number[], userId: number,projectId?:number) {
|
||||
|
||||
const where: any = {
|
||||
id: In(ids),
|
||||
}
|
||||
if (userId > 0) {
|
||||
if (userId != null) {
|
||||
where.userId = userId
|
||||
}
|
||||
if (projectId) {
|
||||
where.projectId = projectId
|
||||
}
|
||||
const list = await this.getRepository().find({where})
|
||||
ids = list.map(item => item.id)
|
||||
const pipelineIds = list.map(item => item.pipelineId)
|
||||
await this.delete(ids);
|
||||
await this.pipelineService.batchDelete(pipelineIds, userId)
|
||||
await this.pipelineService.batchDelete(pipelineIds, userId, projectId)
|
||||
}
|
||||
|
||||
async createPipelineByTemplate(body: PipelineEntity) {
|
||||
|
||||
Reference in New Issue
Block a user