chore: project query

This commit is contained in:
xiaojunnuo
2026-02-13 00:41:40 +08:00
parent 99db1b1cc3
commit 67f347197e
24 changed files with 183 additions and 89 deletions
@@ -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) {