diff --git a/packages/ui/certd-server/src/controller/user/pipeline/pipeline-controller.ts b/packages/ui/certd-server/src/controller/user/pipeline/pipeline-controller.ts index ca98051e7..d1f88e379 100644 --- a/packages/ui/certd-server/src/controller/user/pipeline/pipeline-controller.ts +++ b/packages/ui/certd-server/src/controller/user/pipeline/pipeline-controller.ts @@ -142,26 +142,36 @@ export class PipelineController extends CrudController { @Post('/batchDelete', { summary: Constants.per.authOnly }) async batchDelete(@Body('ids') ids: number[]) { - await this.service.batchDelete(ids, this.getUserId()); + const isAdmin = await this.authService.isAdmin(this.ctx); + const userId = isAdmin ? undefined : this.getUserId() ; + await this.service.batchDelete(ids, userId); return this.ok({}); } + + @Post('/batchUpdateGroup', { summary: Constants.per.authOnly }) async batchUpdateGroup(@Body('ids') ids: number[], @Body('groupId') groupId: number) { - await this.service.batchUpdateGroup(ids, groupId, this.getUserId()); + const isAdmin = await this.authService.isAdmin(this.ctx); + const userId = isAdmin ? undefined : this.getUserId() ; + await this.service.batchUpdateGroup(ids, groupId, userId); return this.ok({}); } @Post('/batchUpdateTrigger', { summary: Constants.per.authOnly }) async batchUpdateTrigger(@Body('ids') ids: number[], @Body('trigger') trigger: any) { - await this.service.batchUpdateTrigger(ids, trigger, this.getUserId()); + const isAdmin = await this.authService.isAdmin(this.ctx); + const userId = isAdmin ? undefined : this.getUserId() ; + await this.service.batchUpdateTrigger(ids, trigger, userId); return this.ok({}); } @Post('/batchUpdateNotification', { summary: Constants.per.authOnly }) async batchUpdateNotification(@Body('ids') ids: number[], @Body('notification') notification: any) { - await this.service.batchUpdateNotifications(ids, notification, this.getUserId()); + const isAdmin = await this.authService.isAdmin(this.ctx); + const userId = isAdmin ? undefined : this.getUserId() ; + await this.service.batchUpdateNotifications(ids, notification, userId); return this.ok({}); } diff --git a/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts b/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts index 85b959305..f2544a408 100644 --- a/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts +++ b/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts @@ -777,17 +777,29 @@ export class PipelineService extends BaseService { } async batchDelete(ids: number[], userId: number) { + if (!isPlus()) { + throw new NeedVIPException("此功能需要升级专业版"); + } for (const id of ids) { - await this.checkUserId(id, userId); + if (userId) { + await this.checkUserId(id, userId); + } await this.delete(id); } } async batchUpdateGroup(ids: number[], groupId: number, userId: any) { + if (!isPlus()) { + throw new NeedVIPException("此功能需要升级专业版"); + } + const query :any = {} + if(userId && userId>0){ + query.userId = userId; + } await this.repository.update( { id: In(ids), - userId + ...query }, { groupId } ); @@ -795,11 +807,17 @@ export class PipelineService extends BaseService { async batchUpdateTrigger(ids: number[], trigger: any, userId: any) { - + if (!isPlus()) { + throw new NeedVIPException("此功能需要升级专业版"); + } + const query :any = {} + if(userId && userId>0){ + query.userId = userId; + } const list = await this.find({ where: { id: In(ids), - userId + ...query } }); @@ -822,11 +840,17 @@ export class PipelineService extends BaseService { } async batchUpdateNotifications(ids: number[], notification: Notification, userId: any) { - + if (!isPlus()) { + throw new NeedVIPException("此功能需要升级专业版"); + } + const query :any = {} + if(userId && userId>0){ + query.userId = userId; + } const list = await this.find({ where: { id: In(ids), - userId + ...query } });